[nautilus] Convert date-format to gsettings
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Convert date-format to gsettings
- Date: Fri, 23 Jul 2010 10:32:27 +0000 (UTC)
commit 202b69146a1fb42e147d1ca6f8694b27d8ada28b
Author: Alexander Larsson <alexl redhat com>
Date: Thu Jul 22 13:37:47 2010 +0200
Convert date-format to gsettings
libnautilus-private/nautilus-directory.c | 7 ++-
libnautilus-private/nautilus-file.c | 9 ++--
libnautilus-private/nautilus-global-preferences.c | 15 ------
libnautilus-private/nautilus-global-preferences.h | 2 +-
src/nautilus-file-management-properties.c | 57 ++++++++++++++++++--
5 files changed, 61 insertions(+), 29 deletions(-)
---
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index ba7bad4..2480fb3 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -327,9 +327,10 @@ add_preferences_callbacks (void)
eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
async_data_preference_changed_callback,
NULL);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_DATE_FORMAT,
- async_data_preference_changed_callback,
- NULL);
+ g_signal_connect_swapped (nautilus_preferences,
+ "changed::" NAUTILUS_PREFERENCES_DATE_FORMAT,
+ G_CALLBACK(async_data_preference_changed_callback),
+ NULL);
}
/**
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 5f3a080..21ab130 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -8146,13 +8146,14 @@ nautilus_file_class_init (NautilusFileClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
-
+
g_type_class_add_private (class, sizeof (NautilusFileDetails));
- eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_DATE_FORMAT,
- &date_format_pref);
-
+ eel_g_settings_add_auto_enum (nautilus_preferences,
+ NAUTILUS_PREFERENCES_DATE_FORMAT,
+ &date_format_pref);
+
thumbnail_limit_changed_callback (NULL);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT,
thumbnail_limit_changed_callback,
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index c2b5e13..7561554 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -166,12 +166,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", NAUTILUS_DATE_FORMAT_LOCALE },
- { "iso", "ISO Format", NAUTILUS_DATE_FORMAT_ISO },
- { "informal", "Informal", NAUTILUS_DATE_FORMAT_INFORMAL }
-};
-
static EelEnumerationEntry new_tab_position_entries[] = {
{ "after_current_tab", "After Current Tab", NAUTILUS_NEW_TAB_POSITION_AFTER_CURRENT_TAB },
{ "end", "End", NAUTILUS_NEW_TAB_POSITION_END }
@@ -348,12 +342,6 @@ static const PreferenceDefault preference_defaults[] = {
PREFERENCE_BOOLEAN,
GINT_TO_POINTER (TRUE)
},
- { NAUTILUS_PREFERENCES_DATE_FORMAT,
- PREFERENCE_STRING,
- "locale",
- NULL, NULL,
- "date_format"
- },
{ NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER,
PREFERENCE_INTEGER,
GINT_TO_POINTER (NAUTILUS_DEFAULT_FOLDER_VIEWER_ICON_VIEW),
@@ -581,9 +569,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/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index ffe14bc..4eb9e17 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -69,7 +69,7 @@ G_BEGIN_DECLS
/* Display */
#define NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES "show-hidden-files"
#define NAUTILUS_PREFERENCES_SHOW_ADVANCED_PERMISSIONS "show-advanced-permissions"
-#define NAUTILUS_PREFERENCES_DATE_FORMAT "preferences/date_format"
+#define NAUTILUS_PREFERENCES_DATE_FORMAT "date-format"
/* Mouse */
#define NAUTILUS_PREFERENCES_MOUSE_USE_EXTRA_BUTTONS "preferences/mouse_use_extra_buttons"
diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c
index a035005..5e2bf54 100644
--- a/src/nautilus-file-management-properties.c
+++ b/src/nautilus-file-management-properties.c
@@ -678,6 +678,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
nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *window)
{
@@ -783,11 +828,11 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET,
NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
(const char **) preview_values);
- eel_preferences_builder_connect_string_enum_combo_box (builder,
- NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET,
- NAUTILUS_PREFERENCES_DATE_FORMAT,
- (const char **) date_format_values);
-
+ bind_builder_enum (builder, nautilus_preferences,
+ NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET,
+ NAUTILUS_PREFERENCES_DATE_FORMAT,
+ (const char **) date_format_values);
+
eel_preferences_builder_connect_string_enum_radio_button (builder,
(const char **) click_behavior_components,
NAUTILUS_PREFERENCES_CLICK_POLICY,
@@ -796,7 +841,7 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
(const char **) executable_text_components,
NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
(const char **) executable_text_values);
-
+
eel_preferences_builder_connect_uint_enum (builder,
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET,
NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]