[nautilus] Convert icon-view preferences to gsettings



commit df9c8ce6b162f37fe9372ee8b9e5c4798c9033e0
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jul 22 21:45:02 2010 +0200

    Convert icon-view preferences to gsettings

 libnautilus-private/nautilus-file.c               |   12 ++-
 libnautilus-private/nautilus-global-preferences.c |   74 +++-----------
 libnautilus-private/nautilus-global-preferences.h |   23 +++--
 libnautilus-private/nautilus-icon-container.c     |   22 +++--
 libnautilus-private/nautilus-thumbnails.c         |    5 +-
 src/file-manager/fm-desktop-icon-view.c           |   24 +++--
 src/file-manager/fm-directory-view.c              |   12 ++-
 src/file-manager/fm-icon-container.c              |   14 ++-
 src/file-manager/fm-icon-view.c                   |  110 ++++++++++++++-------
 src/nautilus-file-management-properties.c         |   50 +++++-----
 10 files changed, 180 insertions(+), 166 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index ee3165f..17d87dc 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -4045,7 +4045,7 @@ nautilus_file_should_show_thumbnail (NautilusFile *file)
 	if (mime_type == NULL) {
 		mime_type = "application/octet-stream";
 	}
-	
+
 	/* If the thumbnail has already been created, don't care about the size
 	 * of the original file.
 	 */
@@ -8049,7 +8049,8 @@ thumbnail_limit_changed_callback (gpointer user_data)
 static void
 thumbnail_size_changed_callback (gpointer user_data)
 {
-	cached_thumbnail_size = eel_preferences_get_integer (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE);
+	cached_thumbnail_size = g_settings_get_int (nautilus_icon_view_preferences,
+						    NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE);
 
 	/* Tell the world that icons might have changed. We could invent a narrower-scope
 	 * signal to mean only "thumbnails might have changed" if this ends up being slow
@@ -8164,9 +8165,10 @@ nautilus_file_class_init (NautilusFileClass *class)
 				  G_CALLBACK (thumbnail_limit_changed_callback),
 				  NULL);
 	thumbnail_size_changed_callback (NULL);
-	eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE,
-				      thumbnail_size_changed_callback,
-				      NULL);
+	g_signal_connect_swapped (nautilus_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE,
+				  G_CALLBACK (thumbnail_size_changed_callback),
+				  NULL);
 	show_thumbnails_changed_callback (NULL);
 	g_signal_connect_swapped (nautilus_preferences,
 				  "changed::" NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 4dbb9a3..d284fff 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -178,58 +178,12 @@ static const PreferenceDefault preference_defaults[] = {
 	 * for FTP. If we make this fast enough for FTP in particular,
 	 * we should change this default to ALWAYS.
 	 */
-	{ NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
-	  PREFERENCE_STRING_ARRAY,
-	  "size,date_modified,type",
-	  NULL, NULL,
-	  NULL
-	},
 	{ NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
 	  PREFERENCE_BOOLEAN,
 	  GINT_TO_POINTER (TRUE)
 	},
 
 	/* Icon View Default Preferences */
-	{ NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
-	  PREFERENCE_STRING,
-	  "name",
-	  NULL, NULL,
-	  "default_icon_view_sort_order"
-	},
-	{ NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT,
-	  PREFERENCE_STRING,
-	  "name",
-	  NULL, NULL,
-	  "default_icon_view_sort_order"
-	},
-	{ NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
-	  PREFERENCE_BOOLEAN,
-	  GINT_TO_POINTER (FALSE)
-	},
-	{ NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT,
-	  PREFERENCE_BOOLEAN,
-	  GINT_TO_POINTER (FALSE)
-	},
-	{ NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
-	  PREFERENCE_BOOLEAN,
-	  GINT_TO_POINTER (FALSE)
-	},
-	{ NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
-	  PREFERENCE_STRING,
-	  "standard",
-	  NULL, NULL,
-	  "default_zoom_level"
-	},
-	{ NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE,
-	  PREFERENCE_INTEGER,
-	  GINT_TO_POINTER (96)
-	},
-	{ NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
-	  PREFERENCE_STRING_ARRAY,
-	  "3",
-	  NULL,NULL,
-	  NULL,
-	},
 	/* Compact Icon View Default Preferences */
 	{ NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL,
 	  PREFERENCE_STRING,
@@ -502,19 +456,20 @@ nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void)
  * preferences presensts them as single option menu.  So we
  * use the following preference as a proxy for the other two.
  * In nautilus-global-preferences.c we install callbacks for
- * the proxy preference and update the other 2 when it changes 
+ * the proxy preference and update the other 2 when it changes
  */
 static void
 default_icon_view_sort_order_or_manual_layout_changed_callback (gpointer callback_data)
 {
- 	int default_sort_order_or_manual_layout;
- 	int default_sort_order;
+	int default_sort_order_or_manual_layout;
+	int default_sort_order;
 
- 	default_sort_order_or_manual_layout = 
- 		eel_preferences_get_enum (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT);
+	default_sort_order_or_manual_layout =
+		g_settings_get_enum (nautilus_icon_view_preferences,
+				     NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT);
 
-	eel_preferences_set_boolean (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
-				     default_sort_order_or_manual_layout == PREFERENCES_SORT_ORDER_MANUALLY);
+	g_settings_set_boolean (nautilus_icon_view_preferences, NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
+				default_sort_order_or_manual_layout == PREFERENCES_SORT_ORDER_MANUALLY);
 
 	if (default_sort_order_or_manual_layout != PREFERENCES_SORT_ORDER_MANUALLY) {
 		default_sort_order = default_sort_order_or_manual_layout;
@@ -522,8 +477,9 @@ default_icon_view_sort_order_or_manual_layout_changed_callback (gpointer callbac
 		g_return_if_fail (default_sort_order >= NAUTILUS_FILE_SORT_BY_DISPLAY_NAME);
 		g_return_if_fail (default_sort_order <= NAUTILUS_FILE_SORT_BY_EMBLEMS);
 
-		eel_preferences_set_enum (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
-					  default_sort_order);
+		g_settings_set_enum (nautilus_icon_view_preferences,
+				     NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
+				     default_sort_order);
 	}
 }
 
@@ -554,11 +510,13 @@ nautilus_global_preferences_init (void)
 	nautilus_preferences = g_settings_new("org.gnome.nautilus.preferences");
 	nautilus_media_preferences = g_settings_new("org.gnome.media-handling");
 	nautilus_window_state = g_settings_new("org.gnome.nautilus.window-state");
+	nautilus_icon_view_preferences = g_settings_new("org.gnome.nautilus.icon-view");
 
 	/* Set up storage for values accessed in this file */
-	eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT,
-				      default_icon_view_sort_order_or_manual_layout_changed_callback, 
-				      NULL);
+	g_signal_connect_swapped (nautilus_icon_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT,
+				  G_CALLBACK (default_icon_view_sort_order_or_manual_layout_changed_callback), 
+				  NULL);
 
 	/* Preload everything in a big batch */
 	eel_gconf_preload_cache ("/apps/nautilus/preferences",
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index 89630aa..fdd4690 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -135,13 +135,13 @@ enum
 
 
 /* Icon View */
-#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER	"icon_view/default_sort_in_reverse_order"
-#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER		"icon_view/default_sort_order"
-#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT	"icon_view/default_use_tighter_layout"
-#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL		"icon_view/default_zoom_level"
-#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT	"icon_view/default_use_manual_layout"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER	"default-sort-in-reverse-order"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER		"default-sort-order"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT	"default-use-tighter-layout"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL		"default-zoom-level"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT	"default-use-manual-layout"
 
-#define NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS      	"icon_view/labels_beside_icons"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS		"labels-beside-icons"
 
 
 /* The icon view uses 2 variables to store the sort order and
@@ -149,18 +149,18 @@ enum
  * preferences presensts them as single option menu.  So we
  * use the following preference as a proxy for the other two.
  * In nautilus-global-preferences.c we install callbacks for
- * the proxy preference and update the other 2 when it changes 
+ * the proxy preference and update the other 2 when it changes
  */
-#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT "icon_view/default_sort_order_or_manual_layout"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT "default-sort-order-or-manual-layout"
 
 /* Which text attributes appear beneath icon names */
-#define NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS				"icon_view/captions"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS				"captions"
 
 /* The default size for thumbnail icons */
-#define NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE			"icon_view/thumbnail_size"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE			"thumbnail-size"
 
 /* ellipsization preferences */
-#define NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT		"icon_view/text_ellipsis_limit"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT		"text-ellipsis-limit"
 #define NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT		"desktop/text_ellipsis_limit"
 
 /* Compact View */
@@ -227,6 +227,7 @@ void nautilus_global_preferences_init                      (void);
 char *nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void);
 
 GSettings *nautilus_preferences;
+GSettings *nautilus_icon_view_preferences;
 GSettings *nautilus_media_preferences;
 GSettings *nautilus_window_state;
 
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index c658b53..d4bb109 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -214,6 +214,7 @@ static void	     nautilus_icon_container_set_rtl_positions (NautilusIconContaine
 static double	     get_mirror_x_position                     (NautilusIconContainer *container,
 								NautilusIcon *icon,
 								double x);
+static void         text_ellipsis_limit_changed_container_callback  (gpointer callback_data);
 
 static int compare_icons_horizontal (NautilusIconContainer *container,
 				     NautilusIcon *icon_a,
@@ -4050,6 +4051,10 @@ finalize (GObject *object)
 
 	details = NAUTILUS_ICON_CONTAINER (object)->details;
 
+	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
+					      text_ellipsis_limit_changed_container_callback,
+					      object);
+
 	g_hash_table_destroy (details->icon_set);
 	details->icon_set = NULL;
 
@@ -5652,9 +5657,10 @@ nautilus_icon_container_constructor (GType                  type,
 							  text_ellipsis_limit_changed_container_callback,
 							  container, G_OBJECT (container));
 	} else {
-		eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
-							  text_ellipsis_limit_changed_container_callback,
-							  container, G_OBJECT (container));
+		g_signal_connect_swapped (nautilus_icon_view_preferences,
+					  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
+					  G_CALLBACK (text_ellipsis_limit_changed_container_callback),
+					  container);
 	}
 
 	return object;
@@ -6256,7 +6262,8 @@ text_ellipsis_limit_changed_callback (gpointer callback_data)
 	const EelEnumeration *eenum;
 	const EelEnumerationEntry *entry;
 
-	pref = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT);
+	pref = g_settings_get_strv (nautilus_icon_view_preferences,
+				    NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT);
 
 	/* set default */
 	get_text_ellipsis_limit_for_zoom (pref, NULL, &one_limit);
@@ -6327,9 +6334,10 @@ nautilus_icon_container_init (NautilusIconContainer *container)
 	nautilus_icon_container_theme_changed (container);
 
 	if (!setup_prefs) {
-		eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
-					      text_ellipsis_limit_changed_callback,
-					      NULL);
+		g_signal_connect_swapped (nautilus_icon_view_preferences,
+					  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
+					  G_CALLBACK (text_ellipsis_limit_changed_callback),
+					  NULL);
 		text_ellipsis_limit_changed_callback (NULL);
 
 		eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT,
diff --git a/libnautilus-private/nautilus-thumbnails.c b/libnautilus-private/nautilus-thumbnails.c
index df9b438..1941b37 100644
--- a/libnautilus-private/nautilus-thumbnails.c
+++ b/libnautilus-private/nautilus-thumbnails.c
@@ -425,8 +425,9 @@ get_pixbuf_from_data (const unsigned char *buffer,
 	GError *error;
 
 	if (thumbnail_icon_size == 0) {
-		eel_preferences_add_auto_integer (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE,
-						  &thumbnail_icon_size);
+		eel_g_settings_add_auto_int (nautilus_icon_view_preferences,
+					     NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE,
+					     &thumbnail_icon_size);
 	}
 
 	loader = gdk_pixbuf_loader_new ();
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index f4a9573..97c5dae 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -289,10 +289,10 @@ fm_desktop_icon_view_finalize (GObject *object)
 	FMDesktopIconView *icon_view;
 
 	icon_view = FM_DESKTOP_ICON_VIEW (object);
-	
-	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
-					 default_zoom_level_changed,
-					 icon_view);
+
+	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
+					      default_zoom_level_changed,
+					      icon_view);
 
 	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
 					 lockdown_disable_command_line_changed_callback,
@@ -419,8 +419,9 @@ get_default_zoom_level (void)
 
 	if (!auto_storage_added) {
 		auto_storage_added = TRUE;
-		eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
-					       (int *) &default_zoom_level);
+		eel_g_settings_add_auto_enum (nautilus_icon_view_preferences,
+					      NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
+					      (int *) &default_zoom_level);
 	}
 
 	return CLAMP (default_zoom_level, NAUTILUS_ZOOM_LEVEL_SMALLEST, NAUTILUS_ZOOM_LEVEL_LARGEST);
@@ -594,11 +595,12 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
 				 G_CALLBACK (realized_callback), desktop_icon_view, 0);
 	g_signal_connect_object (desktop_icon_view, "unrealize",
 				 G_CALLBACK (unrealized_callback), desktop_icon_view, 0);
-	
-	eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
-				      default_zoom_level_changed,
-				      desktop_icon_view);
-	
+
+	g_signal_connect_swapped (nautilus_icon_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
+				  G_CALLBACK (default_zoom_level_changed),
+				  desktop_icon_view);
+
 	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_FONT,
 						  font_changed_callback, 
 						  desktop_icon_view, G_OBJECT (desktop_icon_view));
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 469aa24..d630d75 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -1987,8 +1987,9 @@ fm_directory_view_init (FMDirectoryView *view)
 	
 	eel_preferences_add_callback (NAUTILUS_PREFERENCES_ENABLE_DELETE,
 				      schedule_update_menus_callback, view);
-	eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
-				      text_attribute_names_changed_callback, view);
+	g_signal_connect_swapped (nautilus_icon_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
+				  G_CALLBACK(text_attribute_names_changed_callback), view);
 	g_signal_connect_swapped (nautilus_preferences,
 				  "changed::" NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
 				  G_CALLBACK (image_display_policy_changed_callback), view);
@@ -2107,14 +2108,15 @@ fm_directory_view_finalize (GObject *object)
 
 	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_ENABLE_DELETE,
 					 schedule_update_menus_callback, view);
-	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
-					 text_attribute_names_changed_callback, view);
+	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
+					      text_attribute_names_changed_callback,
+					      view);
 	g_signal_handlers_disconnect_by_func (nautilus_preferences,
 					      image_display_policy_changed_callback, view);
 	g_signal_handlers_disconnect_by_func (nautilus_preferences,
 					      click_policy_changed_callback, view);
 	g_signal_handlers_disconnect_by_func (nautilus_preferences,
-					 sort_directories_first_changed_callback, view);
+					      sort_directories_first_changed_callback, view);
 	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
 					 lockdown_disable_command_line_changed_callback, view);
 
diff --git a/src/file-manager/fm-icon-container.c b/src/file-manager/fm-icon-container.c
index de6cc8b..546cb56 100644
--- a/src/file-manager/fm-icon-container.c
+++ b/src/file-manager/fm-icon-container.c
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <glib/gi18n.h>
 #include <gio/gio.h>
+#include <eel/eel-glib-extensions.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
 #include <libnautilus-private/nautilus-file-attributes.h>
 #include <libnautilus-private/nautilus-thumbnails.h>
@@ -197,24 +198,25 @@ fm_icon_container_get_icon_text_attributes_from_preferences (void)
 	static GQuark *attributes = NULL;
 
 	if (attributes == NULL) {
-		eel_preferences_add_auto_string_array_as_quarks (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
-								 &attributes);
+		eel_g_settings_add_auto_strv_as_quarks (nautilus_icon_view_preferences,
+							NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
+							&attributes);
 	}
-	
+
 	/* We don't need to sanity check the attributes list even though it came
 	 * from preferences.
 	 *
 	 * There are 2 ways that the values in the list could be bad.
 	 *
-	 * 1) The user picks "bad" values.  "bad" values are those that result in 
+	 * 1) The user picks "bad" values.  "bad" values are those that result in
 	 *    there being duplicate attributes in the list.
 	 *
 	 * 2) Value stored in GConf are tampered with.  Its possible physically do
 	 *    this by pulling the rug underneath GConf and manually editing its
-	 *    config files.  Its also possible to use a third party GConf key 
+	 *    config files.  Its also possible to use a third party GConf key
 	 *    editor and store garbage for the keys in question.
 	 *
-	 * Thankfully, the Nautilus preferences machinery deals with both of 
+	 * Thankfully, the Nautilus preferences machinery deals with both of
 	 * these cases.
 	 *
 	 * In the first case, the preferences dialog widgetry prevents
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 8f6d9ed..87ffc78 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -190,7 +190,12 @@ static void                 preview_audio                             (FMIconVie
 static void                 update_layout_menus                       (FMIconView           *view);
 static NautilusFileSortType get_default_sort_order                    (NautilusFile         *file,
 								       gboolean             *reversed);
-
+static void default_sort_order_changed_callback            (gpointer callback_data);
+static void default_sort_in_reverse_order_changed_callback (gpointer callback_data);
+static void default_use_tighter_layout_changed_callback    (gpointer callback_data);
+static void default_use_manual_layout_changed_callback     (gpointer callback_data);
+static void default_zoom_level_changed_callback            (gpointer callback_data);
+static void labels_beside_icons_changed_callback           (gpointer callback_data);
 
 static void fm_icon_view_iface_init (NautilusViewIface *iface);
 
@@ -237,6 +242,25 @@ fm_icon_view_finalize (GObject *object)
 
 	g_free (icon_view->details);
 
+	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
+					      default_sort_order_changed_callback,
+					      icon_view);
+	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
+					      default_sort_in_reverse_order_changed_callback,
+					      icon_view);
+	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
+					      default_use_tighter_layout_changed_callback,
+					      icon_view);
+	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
+					      default_use_manual_layout_changed_callback,
+					      icon_view);
+	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
+					      default_zoom_level_changed_callback,
+					      icon_view);
+	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
+					      labels_beside_icons_changed_callback,
+					      icon_view);
+
 	G_OBJECT_CLASS (fm_icon_view_parent_class)->finalize (object);
 }
 
@@ -741,10 +765,12 @@ get_default_sort_order (NautilusFile *file, gboolean *reversed)
 
 	if (auto_storaged_added == FALSE) {
 		auto_storaged_added = TRUE;
-		eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
-					       (int *) &default_sort_order);
-		eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
-						  &default_sort_in_reverse_order);
+		eel_g_settings_add_auto_enum (nautilus_icon_view_preferences,
+					      NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
+					      (int *) &default_sort_order);
+		eel_g_settings_add_auto_boolean (nautilus_icon_view_preferences,
+						 NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
+						 &default_sort_in_reverse_order);
 
 	}
 
@@ -757,7 +783,7 @@ get_default_sort_order (NautilusFile *file, gboolean *reversed)
 		}
 
 		retval = CLAMP (default_sort_order, NAUTILUS_FILE_SORT_BY_DISPLAY_NAME,
-				NAUTILUS_FILE_SORT_BY_EMBLEMS);		
+				NAUTILUS_FILE_SORT_BY_EMBLEMS);
 	}
 
 	return retval;
@@ -900,11 +926,12 @@ static gboolean
 get_default_directory_manual_layout (void)
 {
 	static gboolean auto_storaged_added = FALSE;
-	
+
 	if (auto_storaged_added == FALSE) {
 		auto_storaged_added = TRUE;
-		eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
-						       &default_directory_manual_layout);
+		eel_g_settings_add_auto_boolean (nautilus_icon_view_preferences,
+						 NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
+						 &default_directory_manual_layout);
 	}
 
 	return default_directory_manual_layout;
@@ -982,11 +1009,12 @@ static gboolean
 get_default_directory_tighter_layout (void)
 {
 	static gboolean auto_storaged_added = FALSE;
-	
+
 	if (auto_storaged_added == FALSE) {
 		auto_storaged_added = TRUE;
-		eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT,
-						       &default_directory_tighter_layout);
+		eel_g_settings_add_auto_boolean (nautilus_icon_view_preferences,
+						 NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT,
+						 &default_directory_tighter_layout);
 	}
 
 	return default_directory_tighter_layout;
@@ -1119,8 +1147,9 @@ get_default_zoom_level (FMIconView *icon_view)
 
 	if (!auto_storage_added) {
 		auto_storage_added = TRUE;
-		eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
-					       (int *) &default_zoom_level);
+		eel_g_settings_add_auto_enum (nautilus_icon_view_preferences,
+					      NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
+					      (int *) &default_zoom_level);
 		eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL,
 					       (int *) &default_compact_zoom_level);
 	}
@@ -1135,15 +1164,16 @@ set_labels_beside_icons (FMIconView *icon_view)
 
 	if (fm_icon_view_supports_labels_beside_icons (icon_view)) {
 		labels_beside = fm_icon_view_is_compact (icon_view) ||
-				eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS);
-		
+			g_settings_get_boolean (nautilus_icon_view_preferences,
+						NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS);
+
 		if (labels_beside) {
 			nautilus_icon_container_set_label_position
-				(get_icon_container (icon_view), 
+				(get_icon_container (icon_view),
 				 NAUTILUS_ICON_LABEL_POSITION_BESIDE);
 		} else {
 			nautilus_icon_container_set_label_position
-				(get_icon_container (icon_view), 
+				(get_icon_container (icon_view),
 				 NAUTILUS_ICON_LABEL_POSITION_UNDER);
 		}
 	}
@@ -3033,7 +3063,7 @@ static void
 fm_icon_view_iface_init (NautilusViewIface *iface)
 {
 	fm_directory_view_init_view_iface (iface);
-	
+
 	iface->get_view_id = fm_icon_view_get_id;
 	iface->get_first_visible_file = icon_view_get_first_visible_file;
 	iface->scroll_to_file = icon_view_scroll_to_file;
@@ -3068,24 +3098,30 @@ fm_icon_view_init (FMIconView *icon_view)
 		setup_sound_preview = TRUE;
 	}
 
-	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
-						  default_sort_order_changed_callback,
-						  icon_view, G_OBJECT (icon_view));
-	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
-						  default_sort_in_reverse_order_changed_callback,
-						  icon_view, G_OBJECT (icon_view));
-	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT,
-						  default_use_tighter_layout_changed_callback,
-						  icon_view, G_OBJECT (icon_view));
-	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
-						  default_use_manual_layout_changed_callback,
-						  icon_view, G_OBJECT (icon_view));
-	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
-						  default_zoom_level_changed_callback,
-						  icon_view, G_OBJECT (icon_view));
-	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS,
-						  labels_beside_icons_changed_callback,
-						  icon_view, G_OBJECT (icon_view));
+	g_signal_connect_swapped (nautilus_icon_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
+				  G_CALLBACK (default_sort_order_changed_callback),
+				  icon_view);
+	g_signal_connect_swapped (nautilus_icon_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
+				  G_CALLBACK (default_sort_in_reverse_order_changed_callback),
+				  icon_view);
+	g_signal_connect_swapped (nautilus_icon_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT,
+				  G_CALLBACK (default_use_tighter_layout_changed_callback),
+				  icon_view);
+	g_signal_connect_swapped (nautilus_icon_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
+				  G_CALLBACK (default_use_manual_layout_changed_callback),
+				  icon_view);
+	g_signal_connect_swapped (nautilus_icon_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
+				  G_CALLBACK (default_zoom_level_changed_callback),
+				  icon_view);
+	g_signal_connect_swapped (nautilus_icon_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS,
+				  G_CALLBACK (labels_beside_icons_changed_callback),
+				  icon_view);
 
 	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL,
 						  default_zoom_level_changed_callback,
diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c
index 4cddb69..8ef1317 100644
--- a/src/nautilus-file-management-properties.c
+++ b/src/nautilus-file-management-properties.c
@@ -332,7 +332,7 @@ icon_captions_changed_callback (GtkComboBox *combo_box,
 	GPtrArray *captions;
 	GtkBuilder *builder;
 	int i;
-	
+
 	builder = GTK_BUILDER (user_data);
 
 	captions = g_ptr_array_new ();
@@ -355,8 +355,9 @@ icon_captions_changed_callback (GtkComboBox *combo_box,
 	}
 	g_ptr_array_add (captions, NULL);
 
-	eel_preferences_set_string_array (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
-					  (char **)captions->pdata);
+	g_settings_set_strv (nautilus_icon_view_preferences,
+			     NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
+			     (const char **)captions->pdata);
 	g_ptr_array_free (captions, TRUE);
 }
 
@@ -398,7 +399,7 @@ update_icon_captions_from_gconf (GtkBuilder *builder)
 	char **captions;
 	int i, j;
 
-	captions = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
+	captions = g_settings_get_strv (nautilus_icon_view_preferences, NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
 	if (captions == NULL)
 		return;
 
@@ -428,21 +429,22 @@ nautilus_file_management_properties_dialog_setup_icon_caption_page (GtkBuilder *
 	GList *columns;
 	int i;
 	gboolean writable;
-	
-	writable = eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
+
+	writable = g_settings_is_writable (nautilus_icon_view_preferences,
+					   NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
 
 	columns = nautilus_get_common_columns ();
-	
+
 	for (i = 0; icon_captions_components[i] != NULL; i++) {
 		GtkWidget *combo_box;
-		
-		combo_box = GTK_WIDGET (gtk_builder_get_object (builder, 
+
+		combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
 								icon_captions_components[i]));
 
 		create_icon_caption_combo_box_items (GTK_COMBO_BOX (combo_box), columns);
 		gtk_widget_set_sensitive (combo_box, writable);
 
-		g_signal_connect (combo_box, "changed", 
+		g_signal_connect (combo_box, "changed",
 				  G_CALLBACK (icon_captions_changed_callback),
 				  builder);
 	}
@@ -919,12 +921,12 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
 	create_date_format_menu (builder);
 
 	/* setup preferences */
-	eel_preferences_builder_connect_bool (builder,
-					      NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_LAYOUT_WIDGET,
-					      NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT);
-	eel_preferences_builder_connect_bool (builder,
-					      NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET,
-					      NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS);
+	bind_builder_bool (builder, nautilus_icon_view_preferences,
+			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_LAYOUT_WIDGET,
+			   NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT);
+	bind_builder_bool (builder, nautilus_icon_view_preferences,
+			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET,
+			   NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS);
 	eel_preferences_builder_connect_bool (builder,
 					      NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALL_COLUMNS_SAME_WIDTH,
 					      NAUTILUS_PREFERENCES_COMPACT_VIEW_ALL_COLUMNS_SAME_WIDTH);
@@ -959,10 +961,10 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET,
 			   NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER,
 			   (const char **) default_view_values);
-	eel_preferences_builder_connect_string_enum_combo_box (builder,
-							       NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET,
-							       NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
-							       (const char **) zoom_values);
+	bind_builder_enum (builder, nautilus_icon_view_preferences,
+			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET,
+			   NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
+			   (const char **) zoom_values);
 	eel_preferences_builder_connect_string_enum_combo_box (builder,
 							       NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_VIEW_ZOOM_WIDGET,
 							       NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL,
@@ -971,10 +973,10 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
 							       NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET,
 							       NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
 							       (const char **) zoom_values);
-	eel_preferences_builder_connect_string_enum_combo_box (builder,
-							       NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET,
-							       NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
-							       (const char **) sort_order_values);
+	bind_builder_enum (builder, nautilus_icon_view_preferences,
+			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET,
+			   NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
+			   (const char **) sort_order_values);
 	eel_preferences_builder_connect_string_enum_combo_box_slave (builder,
 								     NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET,
 								     NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]