diff options
author | Stefano Karapetsas <[email protected]> | 2012-09-05 14:00:24 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-09-05 14:00:24 +0200 |
commit | 8e8764286d4a3f65839dfdd4019b4f22fe3eabe4 (patch) | |
tree | 5578c080dc56f6698edd565b9313c8d3ce334838 /src/caja-file-management-properties.c | |
parent | cf3e02237f89593e6e03065ced3af2835e915ee0 (diff) | |
download | caja-8e8764286d4a3f65839dfdd4019b4f22fe3eabe4.tar.bz2 caja-8e8764286d4a3f65839dfdd4019b4f22fe3eabe4.tar.xz |
convert date-format to gsettings
add eel_g_settings_add_auto_enum in eel/eel-glib-extensions.c
Diffstat (limited to 'src/caja-file-management-properties.c')
-rw-r--r-- | src/caja-file-management-properties.c | 53 |
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, |