[nautilus] Convert click-policy to GSettings



commit 97d62a1d402853f2dd328a53cb7e94581b8e2498
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jul 22 15:52:44 2010 +0200

    Convert click-policy to GSettings

 libnautilus-private/nautilus-global-preferences.c |   20 --------------------
 libnautilus-private/nautilus-global-preferences.h |    2 +-
 libnautilus-private/nautilus-icon-canvas-item.c   |    5 +++--
 src/file-manager/fm-directory-view.c              |    8 ++++++--
 src/file-manager/fm-icon-view.c                   |    6 +++---
 src/file-manager/fm-list-view.c                   |    5 +++--
 src/nautilus-file-management-properties.c         |    8 ++++----
 src/nautilus-history-sidebar.c                    |   20 ++++++++++----------
 8 files changed, 30 insertions(+), 44 deletions(-)
---
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 07b9f96..c5c0011 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -100,17 +100,6 @@ static EelEnumerationEntry file_size_enum_entries[] = {
  	{ "4294967295",     N_("4 GB"),         4294967295U }
 };
 
-static EelEnumerationEntry click_policy_enum_entries[] = {
-	{ "single",
-	  N_("Activate items with a _single click"),
-	  NAUTILUS_CLICK_POLICY_SINGLE
-	},
-	{ "double",
-	  N_("Activate items with a _double click"),
-	  NAUTILUS_CLICK_POLICY_DOUBLE
-	}
-};
-
 static EelEnumerationEntry search_bar_type_enum_entries[] = {
 	{ "search by text",
 	  N_("Search for files by file name only"),
@@ -235,12 +224,6 @@ static const PreferenceDefault preference_defaults[] = {
 	  NULL, NULL,
 	  "speed_tradeoff"
 	},
-	{ NAUTILUS_PREFERENCES_CLICK_POLICY,
-	  PREFERENCE_STRING,
-	  "double",
-	  NULL, NULL,
-	  "click_policy"
-	},
 	{ NAUTILUS_PREFERENCES_INSTALL_MIME_ACTIVATION,
 	  PREFERENCE_BOOLEAN,
 	  GINT_TO_POINTER (TRUE)
@@ -509,9 +492,6 @@ global_preferences_register_enumerations (void)
 	 * populate widgets and route preferences changes between the
 	 * storage (GConf) and the displayed values.
 	 */
-	eel_enumeration_register ("click_policy",
-				  click_policy_enum_entries,
-				  G_N_ELEMENTS (click_policy_enum_entries));
 	eel_enumeration_register ("default_folder_viewer",
 				  default_folder_viewer_enum_entries,
 				  G_N_ELEMENTS (default_folder_viewer_enum_entries));
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index cfe0860..01417ff 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -93,7 +93,7 @@ typedef enum
 #define NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES         "sidebar_panels/tree/show_only_directories"
 
 /* Single/Double click preference  */
-#define NAUTILUS_PREFERENCES_CLICK_POLICY			"preferences/click_policy"
+#define NAUTILUS_PREFERENCES_CLICK_POLICY			"click-policy"
 
 /* Activating executable text files */
 #define NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION		"executable-text-activation"
diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-icon-canvas-item.c
index a31623a..d24cf3b 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.c
+++ b/libnautilus-private/nautilus-icon-canvas-item.c
@@ -273,8 +273,9 @@ nautilus_icon_canvas_item_init (NautilusIconCanvasItem *icon_item)
 	static gboolean setup_auto_enums = FALSE;
 
 	if (!setup_auto_enums) {
-		eel_preferences_add_auto_enum
-			(NAUTILUS_PREFERENCES_CLICK_POLICY,
+		eel_g_settings_add_auto_enum
+			(nautilus_preferences,
+			 NAUTILUS_PREFERENCES_CLICK_POLICY,
 			 &click_policy_auto_value);
 		setup_auto_enums = TRUE;
 	}
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 192b9ba..673e4c9 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -1991,6 +1991,10 @@ fm_directory_view_init (FMDirectoryView *view)
 				      text_attribute_names_changed_callback, view);
 	eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
 				      image_display_policy_changed_callback, view);
+	g_signal_connect_swapped (nautilus_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_CLICK_POLICY,
+				  G_CALLBACK(click_policy_changed_callback),
+				  view);
 	eel_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
 				      click_policy_changed_callback, view);
 	eel_preferences_add_callback (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, 
@@ -2105,8 +2109,8 @@ fm_directory_view_finalize (GObject *object)
 					 text_attribute_names_changed_callback, view);
 	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
 					 image_display_policy_changed_callback, view);
-	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
-					 click_policy_changed_callback, view);
+	g_signal_handlers_disconnect_by_func (nautilus_preferences,
+					      click_policy_changed_callback, view);
 	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST,
 					 sort_directories_first_changed_callback, view);
 	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index e1775a2..033ca4c 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -2487,8 +2487,8 @@ static void
 fm_icon_view_emblems_changed (FMDirectoryView *directory_view)
 {
 	g_assert (FM_IS_ICON_VIEW (directory_view));
-	
-	nautilus_icon_container_request_update_all (get_icon_container (FM_ICON_VIEW (directory_view)));	
+
+	nautilus_icon_container_request_update_all (get_icon_container (FM_ICON_VIEW (directory_view)));
 }
 
 static void
@@ -2685,7 +2685,7 @@ fm_icon_view_update_click_mode (FMIconView *icon_view)
 	icon_container = get_icon_container (icon_view);
 	g_assert (icon_container != NULL);
 
-	click_mode = eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY);
+	click_mode = g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_CLICK_POLICY);
 
 	nautilus_icon_container_set_single_click_mode (icon_container,
 						       click_mode == NAUTILUS_CLICK_POLICY_SINGLE);
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index 724461e..fb35d94 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -3045,8 +3045,9 @@ fm_list_view_class_init (FMListViewClass *class)
 	fm_directory_view_class->using_manual_layout = fm_list_view_using_manual_layout;
 	fm_directory_view_class->set_is_active = real_set_is_active;
 
-	eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
-				       &click_policy_auto_value);
+	eel_g_settings_add_auto_enum (nautilus_preferences,
+				      NAUTILUS_PREFERENCES_CLICK_POLICY,
+				      &click_policy_auto_value);
 	eel_preferences_add_auto_string (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER,
 					 (const char **) &default_sort_order_auto_value);
 	eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c
index dc0f3ed..4b4eed8 100644
--- a/src/nautilus-file-management-properties.c
+++ b/src/nautilus-file-management-properties.c
@@ -912,10 +912,10 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
 			   (const char **) date_format_values);
 
 
-	eel_preferences_builder_connect_string_enum_radio_button (builder,
-								  (const char **) click_behavior_components,
-								  NAUTILUS_PREFERENCES_CLICK_POLICY,
-								  (const char **) click_behavior_values);
+	bind_builder_radio (builder, nautilus_preferences,
+			    (const char **) click_behavior_components,
+			    NAUTILUS_PREFERENCES_CLICK_POLICY,
+			    (const char **) click_behavior_values);
 	bind_builder_radio (builder, nautilus_preferences,
 			    (const char **) executable_text_components,
 			    NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
diff --git a/src/nautilus-history-sidebar.c b/src/nautilus-history-sidebar.c
index 08c6a9d..b85112f 100644
--- a/src/nautilus-history-sidebar.c
+++ b/src/nautilus-history-sidebar.c
@@ -208,9 +208,9 @@ static void
 update_click_policy (NautilusHistorySidebar *sidebar)
 {
 	int policy;
-	
-	policy = eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY);
-	
+
+	policy = g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_CLICK_POLICY);
+
 	eel_gtk_tree_view_set_activate_on_single_click
 		(sidebar->tree_view, policy == NAUTILUS_CLICK_POLICY_SINGLE);
 }
@@ -288,9 +288,10 @@ nautilus_history_sidebar_init (NautilusHistorySidebar *sidebar)
 	g_signal_connect (tree_view, "button-press-event", 
 			  G_CALLBACK (button_press_event_callback), sidebar);
 
-	eel_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
-				      click_policy_changed_callback,
-				      sidebar);
+	g_signal_connect_swapped (nautilus_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_CLICK_POLICY,
+				  G_CALLBACK(click_policy_changed_callback),
+				  sidebar);
 	update_click_policy (sidebar);
 }
 
@@ -298,12 +299,11 @@ static void
 nautilus_history_sidebar_finalize (GObject *object)
 {
 	NautilusHistorySidebar *sidebar;
-	
+
 	sidebar = NAUTILUS_HISTORY_SIDEBAR (object);
 
-	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
-					 click_policy_changed_callback,
-					 sidebar);
+	g_signal_handlers_disconnect_by_func (nautilus_preferences,
+					      click_policy_changed_callback, sidebar);
 
 	G_OBJECT_CLASS (nautilus_history_sidebar_parent_class)->finalize (object);
 }



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