[nautilus] Convert desktop preferences to gsettings



commit 8c13219e9a44e90e1e74ea20a440dc763b5892ed
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Jul 21 16:55:09 2010 +0200

    Convert desktop preferences to gsettings

 libnautilus-private/nautilus-desktop-directory.c  |   14 ++++++------
 libnautilus-private/nautilus-file-utilities.c     |   10 ++++----
 libnautilus-private/nautilus-global-preferences.c |   19 ----------------
 libnautilus-private/nautilus-global-preferences.h |    6 ++--
 src/file-manager/fm-desktop-icon-view.c           |   15 +++++++-----
 src/nautilus-application.c                        |   24 +++++++++-----------
 src/nautilus-main.c                               |    7 ------
 src/nautilus-pathbar.c                            |   10 +++++---
 src/nautilus-places-sidebar.c                     |   11 ++++++---
 9 files changed, 48 insertions(+), 68 deletions(-)
---
diff --git a/libnautilus-private/nautilus-desktop-directory.c b/libnautilus-private/nautilus-desktop-directory.c
index be28cfc..075f5e3 100644
--- a/libnautilus-private/nautilus-desktop-directory.c
+++ b/libnautilus-private/nautilus-desktop-directory.c
@@ -427,10 +427,10 @@ desktop_finalize (GObject *object)
 	g_hash_table_destroy (desktop->details->monitors);
 	g_free (desktop->details);
 
-	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
-					 desktop_directory_changed_callback,
-					 desktop);
-	
+	g_signal_handlers_disconnect_by_func (nautilus_preferences,
+					      desktop_directory_changed_callback,
+					      desktop);
+
 	G_OBJECT_CLASS (nautilus_desktop_directory_parent_class)->finalize (object);
 }
 
@@ -513,9 +513,9 @@ nautilus_desktop_directory_init (NautilusDesktopDirectory *desktop)
 
 	update_desktop_directory (NAUTILUS_DESKTOP_DIRECTORY (desktop));
 
-	eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
-				      desktop_directory_changed_callback,
-				      desktop);
+	g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
+				  G_CALLBACK(desktop_directory_changed_callback),
+				  desktop);
 }
 
 static void
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index b91fd3c..1034683 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -433,7 +433,7 @@ nautilus_get_xdg_dir (const char *type)
 static char *
 get_desktop_path (void)
 {
-	if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
+	if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
 		return g_strdup (g_get_home_dir());
 	} else {
 		return nautilus_get_xdg_dir ("DESKTOP");
@@ -455,7 +455,7 @@ nautilus_get_desktop_directory (void)
 	desktop_directory = get_desktop_path ();
 
 	/* Don't try to create a home directory */
-	if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
+	if (!g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
 		if (!g_file_test (desktop_directory, G_FILE_TEST_EXISTS)) {
 			g_mkdir (desktop_directory, DEFAULT_DESKTOP_DIRECTORY_MODE);
 			/* FIXME bugzilla.gnome.org 41286: 
@@ -676,9 +676,9 @@ nautilus_is_desktop_directory_file (GFile *dir,
 {
 
 	if (!desktop_dir_changed_callback_installed) {
-		eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
-					      desktop_dir_changed_callback,
-					      NULL);
+		g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
+					  G_CALLBACK(desktop_dir_changed_callback),
+					  NULL);
 		desktop_dir_changed_callback_installed = TRUE;
 	}
 		
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 4e3164b..fb075a2 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -48,7 +48,6 @@ static const char *EXTRA_MONITOR_PATHS[] = { "/desktop/gnome/file_views",
 /* Forward declarations */
 static void     global_preferences_install_defaults      (void);
 static void     global_preferences_register_enumerations (void);
-static gpointer default_font_callback                    (void);
 static gpointer default_home_link_name                   (void);
 static gpointer default_computer_link_name               (void);
 static gpointer default_trash_link_name                  (void);
@@ -307,14 +306,6 @@ static const PreferenceDefault preference_defaults[] = {
 	  PREFERENCE_BOOLEAN,
 	  GINT_TO_POINTER (FALSE)
 	},
-	{ NAUTILUS_PREFERENCES_SHOW_DESKTOP,
-	  PREFERENCE_BOOLEAN,
-	  GINT_TO_POINTER (TRUE)
-	},
-	{ NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
-	  PREFERENCE_BOOLEAN,
-	  GINT_TO_POINTER (FALSE)
-	},
 	{ NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE,
 	  PREFERENCE_STRING,
 	  "search_by_text",
@@ -381,10 +372,6 @@ static const PreferenceDefault preference_defaults[] = {
 	  NULL, NULL,
 	  "default_folder_viewer"
 	},
-	{ NAUTILUS_PREFERENCES_DESKTOP_FONT,
-	  PREFERENCE_STRING,
-	  NULL, default_font_callback, g_free
-	},
 
 	/* Icon View Default Preferences */
 	{ NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
@@ -704,12 +691,6 @@ global_preferences_install_defaults (void)
 	}
 }
 
-static gpointer
-default_font_callback (void)
-{
-	return g_strdup ("sans 12");
-}
-
 /*
  * Public functions
  */
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index 0013a56..a46921a 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -62,9 +62,9 @@ G_BEGIN_DECLS
 #define NAUTILUS_PREFERENCES_ENABLE_DELETE			"enable-delete"
 
 /* Desktop options */
-#define NAUTILUS_PREFERENCES_SHOW_DESKTOP			"preferences/show_desktop"
-#define NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR                "preferences/desktop_is_home_dir"
-#define NAUTILUS_PREFERENCES_DESKTOP_FONT			"preferences/desktop_font"
+#define NAUTILUS_PREFERENCES_SHOW_DESKTOP			"show-desktop"
+#define NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR                "desktop-is-home-dir"
+#define NAUTILUS_PREFERENCES_DESKTOP_FONT			"desktop-font"
 
 /* Display  */
 #define NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES  		"/desktop/gnome/file_views/show_hidden_files"
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index ff39cb5..f4a9573 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -297,7 +297,10 @@ fm_desktop_icon_view_finalize (GObject *object)
 	eel_preferences_remove_callback (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
 					 lockdown_disable_command_line_changed_callback,
 					 icon_view);
-	
+
+	g_signal_handlers_disconnect_by_func (nautilus_preferences,
+					      desktop_directory_changed_callback,
+					      NULL);
 	g_free (icon_view->details);
 
 	G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -511,11 +514,11 @@ fm_desktop_icon_view_update_icon_container_fonts (FMDesktopIconView *icon_view)
 {
 	NautilusIconContainer *icon_container;
 	char *font;
-	
+
 	icon_container = get_icon_container (icon_view);
 	g_assert (icon_container != NULL);
 
-	font = eel_preferences_get (NAUTILUS_PREFERENCES_DESKTOP_FONT);
+	font = g_settings_get_string (nautilus_preferences, NAUTILUS_PREFERENCES_DESKTOP_FONT);
 
 	nautilus_icon_container_set_font (icon_container, font);
 
@@ -530,9 +533,9 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
 	GtkAdjustment *hadj, *vadj;
 
 	if (desktop_directory == NULL) {
-		eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
-					      desktop_directory_changed_callback,
-					      NULL);
+		g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
+					  G_CALLBACK(desktop_directory_changed_callback),
+					  NULL);
 		desktop_directory_changed_callback (NULL);
 	}
 
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index df97207..90f1526 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -930,10 +930,10 @@ nautilus_application_startup (NautilusApplication *application,
 		char *accel_map_filename;
 
 		if (!no_desktop &&
-		    !eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
+		    !g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
 			no_desktop = TRUE;
 		}
-			
+
 		if (!no_desktop) {
 			if (is_remote) {
 				g_application_invoke_action (application->unique_app,
@@ -951,19 +951,17 @@ nautilus_application_startup (NautilusApplication *application,
 		}
 
 		/* Monitor the preference to show or hide the desktop */
-		eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SHOW_DESKTOP,
-							  desktop_changed_callback,
-							  application,
-							  G_OBJECT (application));
+		g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_SHOW_DESKTOP,
+					  G_CALLBACK(desktop_changed_callback),
+					  G_OBJECT (application));
 
 		/* Monitor the preference to have the desktop */
 		/* point to the Unix home folder */
-		eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
-							  desktop_location_changed_callback,
-							  NULL,
-							  G_OBJECT (application));
+		g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
+					  G_CALLBACK(desktop_location_changed_callback),
+					  G_OBJECT (application));
 
-	  	/* Create the other windows. */
+		/* Create the other windows. */
 		if (urls != NULL || !no_default_window) {
 			if (is_remote) {
 				GVariant *variant;
@@ -1509,9 +1507,9 @@ static void
 desktop_changed_callback (gpointer user_data)
 {
 	NautilusApplication *application;
-	
+
 	application = NAUTILUS_APPLICATION (user_data);
-	if ( eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
+	if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
 		nautilus_application_open_desktop (application);
 	} else {
 		nautilus_application_close_desktop ();
diff --git a/src/nautilus-main.c b/src/nautilus-main.c
index 90f2556..bae6267 100644
--- a/src/nautilus-main.c
+++ b/src/nautilus-main.c
@@ -477,13 +477,6 @@ main (int argc, char *argv[])
 	exit_with_last_window =
 		eel_preferences_get_boolean (NAUTILUS_PREFERENCES_EXIT_WITH_LAST_WINDOW);
 
-	if (no_desktop) {
-		eel_preferences_set_is_invisible
-			(NAUTILUS_PREFERENCES_SHOW_DESKTOP, TRUE);
-		eel_preferences_set_is_invisible
-			(NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR, TRUE);
-	}
-
 	application = NULL;
 
 	/* Do either the self-check or the real work. */
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 06db317..0698fe5 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -303,10 +303,9 @@ nautilus_path_bar_init (NautilusPathBar *path_bar)
 	path_bar->root_path = g_file_new_for_path ("/");
 	desktop_is_home = g_file_equal (path_bar->home_path, path_bar->desktop_path);
 
-	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
-						  desktop_location_changed_callback,
-						  path_bar,
-						  G_OBJECT (path_bar));
+	g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
+				  G_CALLBACK(desktop_location_changed_callback),
+				  path_bar);
 
         g_signal_connect_swapped (path_bar->up_slider_button, "clicked", G_CALLBACK (nautilus_path_bar_scroll_up), path_bar);
         g_signal_connect_swapped (path_bar->down_slider_button, "clicked", G_CALLBACK (nautilus_path_bar_scroll_down), path_bar);
@@ -426,6 +425,9 @@ nautilus_path_bar_finalize (GObject *object)
 
 	g_signal_handlers_disconnect_by_func (nautilus_trash_monitor_get (),
 					      trash_state_changed_cb, path_bar);
+	g_signal_handlers_disconnect_by_func (nautilus_preferences,
+					      desktop_location_changed_callback,
+					      path_bar);
 
         G_OBJECT_CLASS (nautilus_path_bar_parent_class)->finalize (object);
 }
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index 49ff2ef..bfb9a3e 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -2631,10 +2631,9 @@ nautilus_places_sidebar_init (NautilusPlacesSidebar *sidebar)
 	eel_gtk_tree_view_set_activate_on_single_click (sidebar->tree_view,
 							TRUE);
 
-	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
-						  desktop_location_changed_callback,
-						  sidebar,
-						  G_OBJECT (sidebar));
+	g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
+				  G_CALLBACK(desktop_location_changed_callback),
+				  sidebar);
 
 	g_signal_connect_object (nautilus_trash_monitor_get (),
 				 "trash_state_changed",
@@ -2674,6 +2673,10 @@ nautilus_places_sidebar_dispose (GObject *object)
 
 	eel_remove_weak_pointer (&(sidebar->go_to_after_mount_slot));
 
+	g_signal_handlers_disconnect_by_func (nautilus_preferences,
+					      desktop_location_changed_callback,
+					      sidebar);
+
 	G_OBJECT_CLASS (nautilus_places_sidebar_parent_class)->dispose (object);
 }
 



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