[gnome-panel/wip/3.0-freeze-break] panel: Add panel_layout_is_writable()



commit 1a3cf428830de916ea51e2b06ddb4db29d128b18
Author: Vincent Untz <vuntz gnome org>
Date:   Fri Mar 25 18:58:36 2011 +0100

    panel: Add panel_layout_is_writable()
    
    This replaces a similar gconf-based function.

 gnome-panel/applet.c             |    2 +-
 gnome-panel/panel-addto.c        |    7 ++++---
 gnome-panel/panel-applet-frame.c |    6 +++---
 gnome-panel/panel-context-menu.c |    6 +++---
 gnome-panel/panel-layout.c       |    9 +++++++++
 gnome-panel/panel-layout.h       |    4 +++-
 gnome-panel/panel-profile.c      |   24 ------------------------
 gnome-panel/panel.c              |   22 +++++++++++-----------
 8 files changed, 34 insertions(+), 46 deletions(-)
---
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index b1cf158..956d8f3 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -499,7 +499,7 @@ panel_applet_get_edit_menu (AppletInfo *info)
 	panel_widget = panel_applet_get_panel_widget (info);
 
 	movable = panel_applet_can_freely_move (info);
-	removable = panel_profile_id_lists_are_writable ();
+	removable = panel_layout_is_writable ();
 
 	menuitem = gtk_menu_item_new_with_mnemonic (_("_Move"));
 	g_signal_connect (menuitem, "activate",
diff --git a/gnome-panel/panel-addto.c b/gnome-panel/panel-addto.c
index 439574d..050c110 100644
--- a/gnome-panel/panel-addto.c
+++ b/gnome-panel/panel-addto.c
@@ -42,6 +42,7 @@
 #include "panel-toplevel.h"
 #include "panel-menu-button.h"
 #include "panel-globals.h"
+#include "panel-layout.h"
 #include "panel-lockdown.h"
 #include "panel-util.h"
 #include "panel-profile.h"
@@ -484,7 +485,7 @@ panel_addto_make_applet_model (PanelAddtoDialog *dialog)
 	if (dialog->filter_applet_model != NULL)
 		return;
 
-	if (panel_profile_id_lists_are_writable ()) {
+	if (panel_layout_is_writable ()) {
 		dialog->applet_list = panel_addto_query_applets (dialog->applet_list);
 		dialog->applet_list = panel_addto_prepend_internal_applets (dialog->applet_list);
 	}
@@ -498,7 +499,7 @@ panel_addto_make_applet_model (PanelAddtoDialog *dialog)
 				    G_TYPE_POINTER,
 				    G_TYPE_STRING);
 
-	if (panel_profile_id_lists_are_writable ()) {
+	if (panel_layout_is_writable ()) {
 		panel_addto_append_special_applets (dialog, model);
 		if (dialog->applet_list)
 			panel_addto_append_item (dialog, model, NULL);
@@ -1164,7 +1165,7 @@ panel_addto_selection_changed (GtkTreeSelection *selection,
 				  TRUE);
 
 	/* only allow dragging applets if we can add applets */
-	if (panel_profile_id_lists_are_writable ()) {
+	if (panel_layout_is_writable ()) {
 		switch (data->type) {
 		case PANEL_ADDTO_LAUNCHER:
 			panel_addto_setup_launcher_drag (GTK_TREE_VIEW (dialog->tree_view),
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index de25e05..cf6ef69 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -470,7 +470,7 @@ panel_applet_frame_sync_menu_state (PanelLockdown *lockdown,
 	panel_widget = PANEL_WIDGET (gtk_widget_get_parent (GTK_WIDGET (frame)));
 
 	movable = panel_applet_can_freely_move (frame->priv->applet_info);
-	removable = panel_profile_id_lists_are_writable ();
+	removable = panel_layout_is_writable ();
 	locked_down = panel_lockdown_get_panels_locked_down_s ();
 
 	PANEL_APPLET_FRAME_GET_CLASS (frame)->sync_menu_state (frame, movable, removable, locked_down);
@@ -708,7 +708,7 @@ panel_applet_frame_reload_response (GtkWidget        *dialog,
 		/* if we can't write to applets list we can't really delete
 		   it, so we'll just ignore this.  FIXME: handle this
 		   more correctly I suppose. */
-		if (panel_profile_id_lists_are_writable ())
+		if (panel_layout_is_writable ())
 			panel_layout_delete_object (panel_applet_get_id (info));
 	}
 
@@ -865,7 +865,7 @@ panel_applet_frame_loading_failed_response (GtkWidget *dialog,
 
 	if (response == LOADING_FAILED_RESPONSE_DELETE &&
 	    !panel_lockdown_get_panels_locked_down_s () &&
-	    panel_profile_id_lists_are_writable ()) {
+	    panel_layout_is_writable ()) {
 		GSList *item;
 
 		item = g_slist_find_custom (no_reload_applets, id,
diff --git a/gnome-panel/panel-context-menu.c b/gnome-panel/panel-context-menu.c
index bf36c66..6cee28c 100644
--- a/gnome-panel/panel-context-menu.c
+++ b/gnome-panel/panel-context-menu.c
@@ -108,7 +108,7 @@ panel_context_menu_setup_delete_panel_item (GtkWidget *menu,
 	sensitive =
 		!panel_toplevel_is_last (panel_widget->toplevel) &&
 		!panel_lockdown_get_panels_locked_down_s () &&
-		panel_profile_id_lists_are_writable ();
+		panel_layout_is_writable ();
 
 	gtk_widget_set_sensitive (menuitem, sensitive);
 }
@@ -128,7 +128,7 @@ panel_context_menu_build_edition (PanelWidget *panel_widget,
         g_signal_connect (G_OBJECT (menuitem), "activate",
 	      	       	  G_CALLBACK (panel_addto_present), panel_widget);
 
-	if (!panel_profile_id_lists_are_writable ())
+	if (!panel_layout_is_writable ())
 		gtk_widget_set_sensitive (menuitem, FALSE);
 
 	menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Properties"));
@@ -165,7 +165,7 @@ panel_context_menu_build_edition (PanelWidget *panel_widget,
 			  G_CALLBACK (panel_context_menu_create_new_panel), 
 			  NULL);
 	gtk_widget_set_sensitive (menuitem, 
-				  panel_profile_id_lists_are_writable ());
+				  panel_layout_is_writable ());
 }
 
 GtkWidget *
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index 0ae0304..e13b1e5 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -600,6 +600,15 @@ panel_layout_toplevel_create (GdkScreen *screen)
 \*******************/
 
 
+gboolean
+panel_layout_is_writable (void)
+{
+        return (g_settings_is_writable (layout_settings,
+                                        PANEL_LAYOUT_TOPLEVEL_ID_LIST_KEY) &&
+                g_settings_is_writable (layout_settings,
+                                        PANEL_LAYOUT_OBJECT_ID_LIST_KEY));
+}
+
 void
 panel_layout_delete_toplevel (const char *toplevel_id)
 {
diff --git a/gnome-panel/panel-layout.h b/gnome-panel/panel-layout.h
index 4f81c6a..2689002 100644
--- a/gnome-panel/panel-layout.h
+++ b/gnome-panel/panel-layout.h
@@ -32,7 +32,9 @@ G_BEGIN_DECLS
 void panel_layout_append_from_file (const char *layout_file,
                                     gboolean    error_fatal);
 
-gboolean panel_layout_load (void);
+gboolean panel_layout_load         (void);
+
+gboolean panel_layout_is_writable  (void);
 
 void panel_layout_toplevel_create (GdkScreen  *screen);
 void panel_layout_delete_toplevel (const char *toplevel_id);
diff --git a/gnome-panel/panel-profile.c b/gnome-panel/panel-profile.c
index 417edff..27bc301 100644
--- a/gnome-panel/panel-profile.c
+++ b/gnome-panel/panel-profile.c
@@ -164,30 +164,6 @@ panel_profile_add_to_list (PanelGConfKeyType  type,
 	panel_profile_save_id_list (type, list, FALSE);
 }
 
-static gboolean
-panel_profile_id_list_is_writable (PanelGConfKeyType type)
-{
-	GConfClient *client;
-	const char  *key;
-	const char  *id_list;
-
-	client = panel_gconf_get_client ();
-
-	id_list = panel_gconf_key_type_to_id_list (type);
-
-	key = panel_gconf_general_key (id_list);
-	return gconf_client_key_is_writable (client, key, NULL);
-}
-
-gboolean
-panel_profile_id_lists_are_writable (void)
-{
-  return
-    panel_profile_id_list_is_writable (PANEL_GCONF_TOPLEVELS) &&
-    panel_profile_id_list_is_writable (PANEL_GCONF_APPLETS)   &&
-    panel_profile_id_list_is_writable (PANEL_GCONF_OBJECTS);
-}
-
 char *
 panel_profile_prepare_object_with_id (PanelObjectType  object_type,
 				      const char      *toplevel_id,
diff --git a/gnome-panel/panel.c b/gnome-panel/panel.c
index 77f527f..54b1b23 100644
--- a/gnome-panel/panel.c
+++ b/gnome-panel/panel.c
@@ -512,7 +512,7 @@ drop_url (PanelWidget *panel,
 
 	g_return_val_if_fail (url != NULL, FALSE);
 
-	if (!panel_profile_id_lists_are_writable ())
+	if (!panel_layout_is_writable ())
 		return FALSE;
 
 	netscape_url = g_strsplit (url, "\n", 2);
@@ -546,7 +546,7 @@ drop_menu (PanelWidget *panel,
 	   const char  *menu_filename,
 	   const char  *menu_path)
 {
-	if (!panel_profile_id_lists_are_writable ())
+	if (!panel_layout_is_writable ())
 		return FALSE;
 
 	return panel_menu_button_create (panel->toplevel,
@@ -570,7 +570,7 @@ drop_uri (PanelWidget *panel,
 	char  *icon;
 	GFile *file;
 
-	if (!panel_profile_id_lists_are_writable ())
+	if (!panel_layout_is_writable ())
 		return FALSE;
 
 	name = panel_util_get_label_for_uri (uri);
@@ -757,7 +757,7 @@ drop_urilist (PanelWidget *panel,
 				   (!strcmp (mime, "application/x-gnome-app-info") ||
 				    !strcmp (mime, "application/x-desktop") ||
 				    !strcmp (mime, "application/x-kde-app-info"))) {
-				if (panel_profile_id_lists_are_writable ())
+				if (panel_layout_is_writable ())
 					panel_launcher_create (panel->toplevel, pos, uri);
 				else
 					success = FALSE;
@@ -766,7 +766,7 @@ drop_urilist (PanelWidget *panel,
 
 				filename = g_file_get_path (file);
 
-				if (panel_profile_id_lists_are_writable ())
+				if (panel_layout_is_writable ())
 					/* executable and local, so add a
 					 * launcher with it */
 					ask_about_launcher (filename, panel,
@@ -808,7 +808,7 @@ drop_internal_icon (PanelWidget *panel,
 	if (!icon_name)
 		return FALSE;
 
-	if (!panel_profile_id_lists_are_writable ())
+	if (!panel_layout_is_writable ())
 		return FALSE;
 
 	if (action == GDK_ACTION_MOVE)
@@ -904,7 +904,7 @@ drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type,
 		}
 
 	} else if (!strncmp (applet_type, "ACTION:", strlen ("ACTION:"))) {
-		if (panel_profile_id_lists_are_writable ()) {
+		if (panel_layout_is_writable ()) {
 			remove_applet = panel_action_button_load_from_drag (
 							panel->toplevel,
 							pos,
@@ -916,7 +916,7 @@ drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type,
 		}
 
 	} else if (!strcmp (applet_type, "MENUBAR:NEW")) {
-		if (panel_profile_id_lists_are_writable ()) {
+		if (panel_layout_is_writable ()) {
 			panel_menu_bar_create (panel->toplevel, pos);
 			success = TRUE;
 		} else {
@@ -924,7 +924,7 @@ drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type,
 		}
 
 	} else if (!strcmp(applet_type,"SEPARATOR:NEW")) {
-		if (panel_profile_id_lists_are_writable ()) {
+		if (panel_layout_is_writable ()) {
 			panel_separator_create (panel->toplevel, pos);
 			success = TRUE;
 		} else {
@@ -932,7 +932,7 @@ drop_internal_applet (PanelWidget *panel, int pos, const char *applet_type,
 		}
 
 	} else if (!strcmp(applet_type,"LAUNCHER:ASK")) {
-		if (panel_profile_id_lists_are_writable ()) {
+		if (panel_layout_is_writable ()) {
 			ask_about_launcher (NULL, panel, pos);
 			success = TRUE;
 		} else {
@@ -1181,7 +1181,7 @@ panel_receive_dnd_data (PanelWidget      *panel,
 			gtk_drag_finish (context, FALSE, FALSE, time_);
 			return;
 		}
-		if (panel_profile_id_lists_are_writable ()) {
+		if (panel_layout_is_writable ()) {
 			panel_applet_frame_create (panel->toplevel, pos, (char *) data);
 			success = TRUE;
 		} else {



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