diff options
-rw-r--r-- | eel/eel-glib-extensions.c | 24 | ||||
-rw-r--r-- | eel/eel-glib-extensions.h | 4 | ||||
-rw-r--r-- | libcaja-private/caja-directory.c | 7 | ||||
-rw-r--r-- | libcaja-private/caja-file.c | 6 | ||||
-rw-r--r-- | libcaja-private/caja-global-preferences.c | 17 | ||||
-rw-r--r-- | libcaja-private/caja-global-preferences.h | 2 | ||||
-rw-r--r-- | src/caja-file-management-properties.c | 53 |
7 files changed, 85 insertions, 28 deletions
diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c index 80180054..1014c2b0 100644 --- a/eel/eel-glib-extensions.c +++ b/eel/eel-glib-extensions.c @@ -1024,6 +1024,30 @@ eel_get_filename_charset (const gchar **filename_charset) return cache->is_utf8; } +static void +update_auto_enum (GSettings *settings, + const gchar *key, + gpointer user_data) +{ + int *storage = user_data; + + *storage = g_settings_get_enum (settings, key); +} + +void +eel_g_settings_add_auto_enum (GSettings *settings, + const char *key, + int *storage) +{ + char *signal; + + *storage = g_settings_get_enum (settings, key); + signal = g_strconcat ("changed::", key, NULL); + g_signal_connect (settings, signal, + G_CALLBACK(update_auto_enum), + storage); +} + #if !defined (EEL_OMIT_SELF_CHECK) static void diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h index fc973852..a71c5b4c 100644 --- a/eel/eel-glib-extensions.h +++ b/eel/eel-glib-extensions.h @@ -28,6 +28,7 @@ #define EEL_GLIB_EXTENSIONS_H #include <glib.h> +#include <gio/gio.h> /* A gboolean variant for bit fields. */ typedef guint eel_boolean_bit; @@ -124,5 +125,8 @@ void eel_remove_weak_pointer (gpointer /* Get the filename encoding, returns TRUE if utf8 */ gboolean eel_get_filename_charset (const gchar **filename_charset); +void eel_g_settings_add_auto_enum (GSettings *settings, + const char *key, + int *storage); #endif /* EEL_GLIB_EXTENSIONS_H */ diff --git a/libcaja-private/caja-directory.c b/libcaja-private/caja-directory.c index a3bc7fc0..cedd1a59 100644 --- a/libcaja-private/caja-directory.c +++ b/libcaja-private/caja-directory.c @@ -337,9 +337,10 @@ add_preferences_callbacks (void) eel_preferences_add_callback (CAJA_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, async_data_preference_changed_callback, NULL); - eel_preferences_add_callback (CAJA_PREFERENCES_DATE_FORMAT, - async_data_preference_changed_callback, - NULL); + g_signal_connect_swapped (caja_preferences, + "changed::" CAJA_PREFERENCES_DATE_FORMAT, + G_CALLBACK(async_data_preference_changed_callback), + NULL); } /** diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c index 65bbaa38..988ff2e7 100644 --- a/libcaja-private/caja-file.c +++ b/libcaja-private/caja-file.c @@ -8274,9 +8274,9 @@ caja_file_class_init (CajaFileClass *class) g_type_class_add_private (class, sizeof (CajaFileDetails)); - - eel_preferences_add_auto_enum (CAJA_PREFERENCES_DATE_FORMAT, - &date_format_pref); + eel_g_settings_add_auto_enum (caja_preferences, + CAJA_PREFERENCES_DATE_FORMAT, + &date_format_pref); thumbnail_limit_changed_callback (NULL); eel_preferences_add_callback (CAJA_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, diff --git a/libcaja-private/caja-global-preferences.c b/libcaja-private/caja-global-preferences.c index e9f4f255..703a4c29 100644 --- a/libcaja-private/caja-global-preferences.c +++ b/libcaja-private/caja-global-preferences.c @@ -183,13 +183,6 @@ static EelEnumerationEntry standard_font_size_entries[] = }; /* These are not translated, because the text is not used in the ui */ -static EelEnumerationEntry date_format_entries[] = -{ - { "locale", "Locale Default", CAJA_DATE_FORMAT_LOCALE }, - { "iso", "ISO Format", CAJA_DATE_FORMAT_ISO }, - { "informal", "Informal", CAJA_DATE_FORMAT_INFORMAL } -}; - static EelEnumerationEntry new_tab_position_entries[] = { { "after_current_tab", "After Current Tab", CAJA_NEW_TAB_POSITION_AFTER_CURRENT_TAB }, @@ -391,13 +384,6 @@ static const PreferenceDefault preference_defaults[] = GINT_TO_POINTER (TRUE) }, { - CAJA_PREFERENCES_DATE_FORMAT, - PREFERENCE_STRING, - "locale", - NULL, NULL, - "date_format" - }, - { CAJA_PREFERENCES_DEFAULT_FOLDER_VIEWER, PREFERENCE_INTEGER, GINT_TO_POINTER (CAJA_DEFAULT_FOLDER_VIEWER_ICON_VIEW), @@ -651,9 +637,6 @@ global_preferences_register_enumerations (void) eel_enumeration_register ("standard_font_size", standard_font_size_entries, G_N_ELEMENTS (standard_font_size_entries)); - eel_enumeration_register ("date_format", - date_format_entries, - G_N_ELEMENTS (date_format_entries)); eel_enumeration_register ("new_tab_position", new_tab_position_entries, G_N_ELEMENTS (new_tab_position_entries)); diff --git a/libcaja-private/caja-global-preferences.h b/libcaja-private/caja-global-preferences.h index 23ddd328..cb99bddb 100644 --- a/libcaja-private/caja-global-preferences.h +++ b/libcaja-private/caja-global-preferences.h @@ -69,7 +69,7 @@ G_BEGIN_DECLS /* Display */ #define CAJA_PREFERENCES_SHOW_HIDDEN_FILES "show-hidden-files" #define CAJA_PREFERENCES_SHOW_ADVANCED_PERMISSIONS "show-advanced-permissions" -#define CAJA_PREFERENCES_DATE_FORMAT "preferences/date_format" +#define CAJA_PREFERENCES_DATE_FORMAT "date-format" /* Mouse */ #define CAJA_PREFERENCES_MOUSE_USE_EXTRA_BUTTONS "preferences/mouse_use_extra_buttons" 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, |