[nautilus] Convert compact view prefs to gsettings



commit 80a26e69ad2383d3aca093ed993e7ff3f8a1bc5b
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jul 22 22:58:54 2010 +0200

    Convert compact view prefs to gsettings

 libnautilus-private/nautilus-global-preferences.c |    9 +-----
 libnautilus-private/nautilus-global-preferences.h |    5 ++-
 src/file-manager/fm-icon-view.c                   |   33 ++++++++++++++-------
 src/nautilus-file-management-properties.c         |   14 ++++----
 4 files changed, 33 insertions(+), 28 deletions(-)
---
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 755f9b1..da255e5 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -159,14 +159,6 @@ typedef struct
  * YOU SHOULD EDIT THE SCHEMAS FILE TO CHANGE DEFAULTS.
  */
 static const PreferenceDefault preference_defaults[] = {
-	/* Icon View Default Preferences */
-	/* Compact Icon View Default Preferences */
-	{ NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL,
-	  PREFERENCE_STRING,
-	  "standard",
-	  NULL, NULL,
-	  "default_zoom_level"
-	},
 
 	/* List View Default Preferences */
 	{ NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER,
@@ -396,6 +388,7 @@ nautilus_global_preferences_init (void)
 	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");
+	nautilus_compact_view_preferences = g_settings_new("org.gnome.nautilus.compact-view");
 	nautilus_desktop_preferences = g_settings_new("org.gnome.nautilus.desktop");
 	nautilus_tree_sidebar_preferences = g_settings_new("org.gnome.nautilus.sidebar-panels.tree");
 
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index e2b6f9c..76e8e17 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -164,8 +164,8 @@ enum
 #define NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT		"text-ellipsis-limit"
 
 /* Compact View */
-#define NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL		"compact_view/default_zoom_level"
-#define NAUTILUS_PREFERENCES_COMPACT_VIEW_ALL_COLUMNS_SAME_WIDTH	"compact_view/all_columns_have_same_width"
+#define NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL		"default-zoom-level"
+#define NAUTILUS_PREFERENCES_COMPACT_VIEW_ALL_COLUMNS_SAME_WIDTH	"all-columns-have-same-width"
 
 /* List View */
 #define NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER	"list_view/default_sort_in_reverse_order"
@@ -228,6 +228,7 @@ char *nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (v
 
 GSettings *nautilus_preferences;
 GSettings *nautilus_icon_view_preferences;
+GSettings *nautilus_compact_view_preferences;
 GSettings *nautilus_desktop_preferences;
 GSettings *nautilus_tree_sidebar_preferences;
 GSettings *nautilus_media_preferences;
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 87ffc78..cb52aba 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -196,6 +196,7 @@ static void default_use_tighter_layout_changed_callback    (gpointer callback_da
 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 all_columns_same_width_changed_callback	   (gpointer callback_data);
 
 static void fm_icon_view_iface_init (NautilusViewIface *iface);
 
@@ -260,6 +261,12 @@ fm_icon_view_finalize (GObject *object)
 	g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences,
 					      labels_beside_icons_changed_callback,
 					      icon_view);
+	g_signal_handlers_disconnect_by_func (nautilus_compact_view_preferences,
+					      default_zoom_level_changed_callback,
+					      icon_view);
+	g_signal_handlers_disconnect_by_func (nautilus_compact_view_preferences,
+					      all_columns_same_width_changed_callback,
+					      icon_view);
 
 	G_OBJECT_CLASS (fm_icon_view_parent_class)->finalize (object);
 }
@@ -1150,8 +1157,9 @@ get_default_zoom_level (FMIconView *icon_view)
 		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);
+		eel_g_settings_add_auto_enum (nautilus_compact_view_preferences,
+					      NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL,
+					      (int *) &default_compact_zoom_level);
 	}
 
 	return CLAMP (DEFAULT_ZOOM_LEVEL(icon_view), NAUTILUS_ZOOM_LEVEL_SMALLEST, NAUTILUS_ZOOM_LEVEL_LARGEST);
@@ -1185,7 +1193,8 @@ set_columns_same_width (FMIconView *icon_view)
 	gboolean all_columns_same_width;
 
 	if (fm_icon_view_is_compact (icon_view)) {
-		all_columns_same_width = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_COMPACT_VIEW_ALL_COLUMNS_SAME_WIDTH);
+		all_columns_same_width = g_settings_get_boolean (nautilus_compact_view_preferences,
+								 NAUTILUS_PREFERENCES_COMPACT_VIEW_ALL_COLUMNS_SAME_WIDTH);
 		nautilus_icon_container_set_all_columns_same_width (get_icon_container (icon_view), all_columns_same_width);
 	}
 }
@@ -1198,7 +1207,7 @@ fm_icon_view_begin_loading (FMDirectoryView *view)
 	NautilusFile *file;
 	int level;
 	char *sort_name;
-	
+
 	g_return_if_fail (FM_IS_ICON_VIEW (view));
 
 	icon_view = FM_ICON_VIEW (view);
@@ -3123,12 +3132,14 @@ fm_icon_view_init (FMIconView *icon_view)
 				  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,
-						  icon_view, G_OBJECT (icon_view));
-	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_COMPACT_VIEW_ALL_COLUMNS_SAME_WIDTH,
-						  all_columns_same_width_changed_callback,
-						  icon_view, G_OBJECT (icon_view));
+	g_signal_connect_swapped (nautilus_compact_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL,
+				  G_CALLBACK (default_zoom_level_changed_callback),
+				  icon_view);
+	g_signal_connect_swapped (nautilus_compact_view_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_COMPACT_VIEW_ALL_COLUMNS_SAME_WIDTH,
+				  G_CALLBACK (all_columns_same_width_changed_callback),
+				  icon_view);
 
 	g_signal_connect_object (get_icon_container (icon_view), "handle_netscape_url",
 				 G_CALLBACK (icon_view_handle_netscape_url), icon_view, 0);
@@ -3139,7 +3150,7 @@ fm_icon_view_init (FMIconView *icon_view)
 	g_signal_connect_object (get_icon_container (icon_view), "handle_raw",
 				 G_CALLBACK (icon_view_handle_raw), icon_view, 0);
 
-	icon_view->details->clipboard_handler_id = 
+	icon_view->details->clipboard_handler_id =
 		g_signal_connect (nautilus_clipboard_monitor_get (),
 		                  "clipboard_info",
 		                  G_CALLBACK (icon_view_notify_clipboard_info), icon_view);
diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c
index fe7d25e..4e71e7b 100644
--- a/src/nautilus-file-management-properties.c
+++ b/src/nautilus-file-management-properties.c
@@ -931,9 +931,9 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
 	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);
+	bind_builder_bool (builder, nautilus_compact_view_preferences,
+			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALL_COLUMNS_SAME_WIDTH,
+			   NAUTILUS_PREFERENCES_COMPACT_VIEW_ALL_COLUMNS_SAME_WIDTH);
 	bind_builder_bool (builder, nautilus_preferences,
 			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET,
 			   NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
@@ -969,10 +969,10 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
 			   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,
-							       (const char **) zoom_values);
+	bind_builder_enum (builder, nautilus_compact_view_preferences,
+			   NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_VIEW_ZOOM_WIDGET,
+			   NAUTILUS_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL,
+			   (const char **) zoom_values);
 	eel_preferences_builder_connect_string_enum_combo_box (builder,
 							       NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET,
 							       NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,



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