summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/caja-file-management-properties.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c
index ec187c1e..9369acaa 100644
--- a/src/caja-file-management-properties.c
+++ b/src/caja-file-management-properties.c
@@ -715,6 +715,51 @@ bind_builder_bool (GtkBuilder *builder,
"active", G_SETTINGS_BIND_DEFAULT);
}
+static gboolean
+enum_get_mapping (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
+{
+ const char **enum_values = user_data;
+ const char *str;
+ int i;
+
+ str = g_variant_get_string (variant, NULL);
+ for (i = 0; enum_values[i] != NULL; i++) {
+ if (strcmp (enum_values[i], str) == 0) {
+ g_value_set_int (value, i);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static GVariant *
+enum_set_mapping (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer user_data)
+{
+ const char **enum_values = user_data;
+
+ return g_variant_new_string (enum_values[g_value_get_int (value)]);
+}
+
+static void
+bind_builder_enum (GtkBuilder *builder,
+ GSettings *settings,
+ const char *widget_name,
+ const char *prefs,
+ const char **enum_values)
+{
+ g_settings_bind_with_mapping (settings, prefs,
+ gtk_builder_get_object (builder, widget_name),
+ "active", G_SETTINGS_BIND_DEFAULT,
+ enum_get_mapping,
+ enum_set_mapping,
+ enum_values, NULL);
+}
+
static void
caja_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *window)
{
@@ -821,10 +866,10 @@ caja_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *wi
CAJA_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET,
CAJA_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
(const char **) preview_values);
- eel_preferences_builder_connect_string_enum_combo_box (builder,
- CAJA_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET,
- CAJA_PREFERENCES_DATE_FORMAT,
- (const char **) date_format_values);
+ bind_builder_enum (builder, caja_preferences,
+ CAJA_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET,
+ CAJA_PREFERENCES_DATE_FORMAT,
+ (const char **) date_format_values);
eel_preferences_builder_connect_string_enum_radio_button (builder,
(const char **) click_behavior_components,