[nautilus] Convert disable-command-line lockdown to gsettings



commit 3c8b43bf6c10e83d0bd8fd97e0dae7032339ba72
Author: Tomas Bzatek <tbzatek redhat com>
Date:   Thu Aug 5 16:12:39 2010 +0200

    Convert disable-command-line lockdown to gsettings

 libnautilus-private/nautilus-global-preferences.c |    1 +
 libnautilus-private/nautilus-global-preferences.h |    3 +-
 src/file-manager/fm-desktop-icon-view.c           |   29 ++++++---------------
 src/file-manager/fm-directory-view.c              |   29 ++++----------------
 4 files changed, 17 insertions(+), 45 deletions(-)
---
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 35c346f..287344a 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -81,6 +81,7 @@ nautilus_global_preferences_init (void)
 	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");
+	gnome_lockdown_preferences = g_settings_new("org.gnome.desktop.lockdown");
 
 	nautilus_gconf_client = gconf_client_get_default ();
 
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index c6e2fa3..cc4bef8 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -205,7 +205,7 @@ typedef enum
 #define NAUTILUS_PREFERENCES_DESKTOP_NETWORK_NAME          "network-icon-name"
 
 /* Lockdown */
-#define NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE         "/desktop/gnome/lockdown/disable_command_line"
+#define NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE         "disable-command-line"
 
 void nautilus_global_preferences_init                      (void);
 char *nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void);
@@ -218,6 +218,7 @@ GSettings *nautilus_desktop_preferences;
 GSettings *nautilus_tree_sidebar_preferences;
 GSettings *nautilus_media_preferences;
 GSettings *nautilus_window_state;
+GSettings *gnome_lockdown_preferences;
 
 GConfClient *nautilus_gconf_client;
 
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index abd124a..9864cbd 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -78,8 +78,6 @@ struct FMDesktopIconViewDetails
 	gulong delayed_init_signal;
 	guint reload_desktop_timeout;
 	gboolean pending_rescan;
-
-	guint lockdown_notification_id;
 };
 
 static void     fm_desktop_icon_view_init                   (FMDesktopIconView      *desktop_icon_view);
@@ -109,15 +107,6 @@ desktop_directory_changed_callback (gpointer callback_data)
 	desktop_directory = nautilus_get_desktop_directory ();
 }
 
-static void
-lockdown_disable_command_line_changed_callback (GConfClient* client,
-						guint cnxn_id,
-						GConfEntry *entry,
-						gpointer callback_data)
-{
-	fm_directory_view_update_menus (FM_DIRECTORY_VIEW (callback_data));
-}
-
 static NautilusIconContainer *
 get_icon_container (FMDesktopIconView *icon_view)
 {
@@ -308,8 +297,9 @@ fm_desktop_icon_view_finalize (GObject *object)
 					      desktop_directory_changed_callback,
 					      NULL);
 
-	gconf_client_notify_remove (nautilus_gconf_client,
-				    icon_view->details->lockdown_notification_id);
+	g_signal_handlers_disconnect_by_func (gnome_lockdown_preferences,
+					      fm_directory_view_update_menus,
+					      icon_view);
 
 	g_free (icon_view->details);
 
@@ -620,13 +610,10 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
 	default_zoom_level_changed (desktop_icon_view);
 	fm_desktop_icon_view_update_icon_container_fonts (desktop_icon_view);
 
-	desktop_icon_view->details->lockdown_notification_id =
-		gconf_client_notify_add (nautilus_gconf_client,
-					 NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE,
-					 lockdown_disable_command_line_changed_callback,
-					 desktop_icon_view,
-					 NULL,
-					 NULL);
+	g_signal_connect_swapped (gnome_lockdown_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
+				  G_CALLBACK (fm_directory_view_update_menus),
+				  desktop_icon_view);
 }
 
 static void
@@ -714,7 +701,7 @@ real_update_menus (FMDirectoryView *view)
 	desktop_view = FM_DESKTOP_ICON_VIEW (view);
 
 	/* New Launcher */
-	disable_command_line = gconf_client_get_bool (nautilus_gconf_client, NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE, NULL);
+	disable_command_line = g_settings_get_boolean (gnome_lockdown_preferences, NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE);
 	action = gtk_action_group_get_action (desktop_view->details->desktop_action_group,
 					      FM_ACTION_NEW_LAUNCHER_DESKTOP);
 	gtk_action_set_visible (action,
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 3f2e4cb..2abf97d 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -252,7 +252,6 @@ struct FMDirectoryViewDetails
 	gboolean allow_moves;
 
 	GdkPoint context_menu_position;
-	guint lockdown_notification_id;
 };
 
 typedef struct {
@@ -1624,18 +1623,6 @@ sort_directories_first_changed_callback (gpointer callback_data)
 }
 
 static void
-lockdown_disable_command_line_changed_callback (GConfClient* client,
-						guint cnxn_id,
-						GConfEntry *entry,
-						gpointer callback_data)
-{
-	FMDirectoryView *view;
-
-	view = FM_DIRECTORY_VIEW (callback_data);
-	schedule_update_menus (view);
-}
-
-static void
 set_up_scripts_directory_global (void)
 {
 	char *scripts_directory_path;
@@ -2005,13 +1992,9 @@ fm_directory_view_init (FMDirectoryView *view)
 	g_signal_connect_swapped (nautilus_preferences,
 				  "changed::" NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, 
 				  G_CALLBACK(sort_directories_first_changed_callback), view);
-	view->details->lockdown_notification_id =
-		gconf_client_notify_add (nautilus_gconf_client,
-					 NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE,
-					 lockdown_disable_command_line_changed_callback,
-					 view,
-					 NULL,
-					 NULL);
+	g_signal_connect_swapped (gnome_lockdown_preferences,
+				  "changed::" NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
+				  G_CALLBACK (schedule_update_menus), view);
 }
 
 static void
@@ -2126,8 +2109,8 @@ fm_directory_view_finalize (GObject *object)
 	g_signal_handlers_disconnect_by_func (nautilus_preferences,
 					      sort_directories_first_changed_callback, view);
 
-	gconf_client_notify_remove (nautilus_gconf_client,
-				    view->details->lockdown_notification_id);
+	g_signal_handlers_disconnect_by_func (gnome_lockdown_preferences,
+					      schedule_update_menus, view);
 
 	unschedule_pop_up_location_context_menu (view);
 	if (view->details->location_popup_event != NULL) {
@@ -8761,7 +8744,7 @@ real_update_menus (FMDirectoryView *view)
 
 	real_update_paste_menu (view, selection, selection_count);
 
-	disable_command_line = gconf_client_get_bool (nautilus_gconf_client, NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE, NULL);
+	disable_command_line = g_settings_get_boolean (gnome_lockdown_preferences, NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE);
 	action = gtk_action_group_get_action (view->details->dir_action_group,
 					      FM_ACTION_NEW_LAUNCHER);
 	gtk_action_set_visible (action, vfolder_directory && !disable_command_line);



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