[gnome-panel] panel: Also remove per-instance gconf path of applets on removal



commit e00ad6d31ec0d5b5e71ae2af9b7f7cd2a9445071
Author: Vincent Untz <vuntz gnome org>
Date:   Mon Mar 28 14:01:55 2011 +0530

    panel: Also remove per-instance gconf path of applets on removal
    
    We were never removing gconf per-applet configuration of applets on
    removal, which means we'd keep stale data forever; this also means a new
    applet could inherit keys from a previous removed applet.

 gnome-panel/panel-applet-frame.c |   14 +-------------
 gnome-panel/panel-gconf.c        |    9 +++++++++
 gnome-panel/panel-gconf.h        |    3 +++
 gnome-panel/panel-layout.c       |   25 +++++++++++++++++++++++++
 gnome-panel/panel-layout.h       |    1 +
 5 files changed, 39 insertions(+), 13 deletions(-)
---
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index 659c6ea..6b6bdb0 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -72,7 +72,6 @@ G_DEFINE_TYPE (PanelAppletFrame, panel_applet_frame, GTK_TYPE_EVENT_BOX)
 #define PANEL_APPLET_FRAME_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_FRAME, PanelAppletFramePrivate))
 
 #define HANDLE_SIZE 10
-#define PANEL_APPLET_PREFS_KEY "/apps/panel3-applets/%s"
 
 struct _PanelAppletFramePrivate {
 	PanelWidget     *panel;
@@ -860,18 +859,7 @@ panel_applet_frame_activating_get_settings_path (PanelAppletFrameActivating *fra
 gchar *
 panel_applet_frame_activating_get_conf_path (PanelAppletFrameActivating *frame_act)
 {
-	char *ret;
-	char *gconfied_id;
-
-	/* gconf uses '_' and not '-' */
-	gconfied_id = g_strdup (frame_act->id);
-	g_strdelimit (gconfied_id, "-", '_');
-
-	ret = g_strdup_printf (PANEL_APPLET_PREFS_KEY, gconfied_id);
-
-	g_free (gconfied_id);
-
-	return ret;
+	return panel_layout_object_get_gconf_path (frame_act->id);
 }
 
 static void
diff --git a/gnome-panel/panel-gconf.c b/gnome-panel/panel-gconf.c
index f41fc96..0dbbf7e 100644
--- a/gnome-panel/panel-gconf.c
+++ b/gnome-panel/panel-gconf.c
@@ -133,3 +133,12 @@ panel_gconf_notify_add_while_alive (const char            *key,
 
 	return notify_id;
 }
+
+gboolean
+panel_gconf_recursive_unset (const gchar  *dir,
+                             GError     **error)
+{
+        return gconf_client_recursive_unset (panel_gconf_get_client (), dir,
+					     GCONF_UNSET_INCLUDING_SCHEMA_NAMES,
+					     NULL);
+}
diff --git a/gnome-panel/panel-gconf.h b/gnome-panel/panel-gconf.h
index 587aaf3..981bb57 100644
--- a/gnome-panel/panel-gconf.h
+++ b/gnome-panel/panel-gconf.h
@@ -38,6 +38,9 @@ guint		panel_gconf_notify_add_while_alive (const char            *key,
 						    GConfClientNotifyFunc  notify_func,
 						    GObject               *alive_object);
 
+gboolean panel_gconf_recursive_unset (const gchar  *dir,
+                                      GError     **error);
+
 G_END_DECLS
 
 #endif /* __PANEL_GCONF_H__ */
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index 84b1265..bdf3bcc 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -36,6 +36,7 @@
 #include <libpanel-util/panel-gsettings.h>
 
 #include "panel.h"
+#include "panel-gconf.h"
 #include "panel-multiscreen.h"
 #include "panel-object-loader.h"
 #include "panel-schemas.h"
@@ -46,6 +47,7 @@
 static GSettings *layout_settings = NULL;
 
 #define PANEL_LAYOUT_ERROR panel_layout_error_quark ()
+#define PANEL_LAYOUT_OBJECT_GCONF_PATH_TEMPLATE "/apps/panel3-applets/%s"
 
 static void panel_layout_load_toplevel    (const char *toplevel_id);
 static void panel_layout_load_object      (const char *object_id);
@@ -615,6 +617,24 @@ panel_layout_object_create (PanelObjectType   type,
         g_free (id);
 }
 
+char *
+panel_layout_object_get_gconf_path (const char *object_id)
+{
+        char *ret;
+        char *gconfied_id;
+
+        /* gconf uses '_' and not '-' */
+        gconfied_id = g_strdup (object_id);
+        g_strdelimit (gconfied_id, "-", '_');
+
+        ret = g_strdup_printf (PANEL_LAYOUT_OBJECT_GCONF_PATH_TEMPLATE,
+                               gconfied_id);
+
+        g_free (gconfied_id);
+
+        return ret;
+}
+
 GSettings *
 panel_layout_get_instance_settings (GSettings  *settings_object,
                                     const char *schema)
@@ -788,6 +808,11 @@ panel_layout_delete_object (const char *object_id)
         path = g_strdup_printf ("%s%s/",
                                 PANEL_LAYOUT_OBJECT_PATH, id_copy);
         panel_dconf_recursive_reset (path, NULL);
+        g_free (path);
+
+        path = panel_layout_object_get_gconf_path (id_copy);
+        panel_gconf_recursive_unset (path, NULL);
+        g_free (path);
 
         g_free (id_copy);
 }
diff --git a/gnome-panel/panel-layout.h b/gnome-panel/panel-layout.h
index a4bc090..7f6dbd6 100644
--- a/gnome-panel/panel-layout.h
+++ b/gnome-panel/panel-layout.h
@@ -46,6 +46,7 @@ void  panel_layout_object_create        (PanelObjectType   type,
 					 int               position,
 					 gboolean          pack_end);
 
+char      *panel_layout_object_get_gconf_path (const char *object_id);
 GSettings *panel_layout_get_instance_settings (GSettings  *settings_object,
                                                const char *schema);
 



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