[Xfce4-commits] <xfce4-panel:devel> Fix some xfconf problems.

Nick Schermer nick at xfce.org
Tue Sep 8 16:10:01 CEST 2009


Updating branch refs/heads/devel
         to c2e4b8615e200961bc5b66985cd55d00794027a0 (commit)
       from 75bc4d9c66b7e90c8bc6a53439adb8e30c4549c3 (commit)

commit c2e4b8615e200961bc5b66985cd55d00794027a0
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Sep 8 10:46:32 2009 +0200

    Fix some xfconf problems.

 common/panel-xfconf.c     |   16 ++++++----------
 common/panel-xfconf.h     |    2 +-
 panel/panel-application.c |   22 ++++++++++++----------
 3 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/common/panel-xfconf.c b/common/panel-xfconf.c
index 4d0db1c..0332046 100644
--- a/common/panel-xfconf.c
+++ b/common/panel-xfconf.c
@@ -27,11 +27,13 @@
 
 
 XfconfChannel *
-panel_properties_get_channel (void)
+panel_properties_get_channel (GObject *object_for_weak_ref)
 {
   GError        *error = NULL;
   XfconfChannel *channel;
 
+  panel_return_val_if_fail (G_IS_OBJECT (object_for_weak_ref), NULL);
+
   if (!xfconf_init (&error))
     {
       g_critical ("Failed to initialize Xfconf: %s", error->message);
@@ -40,8 +42,7 @@ panel_properties_get_channel (void)
     }
 
   channel = xfconf_channel_get (XFCE_PANEL_PLUGIN_CHANNEL_NAME);
-  /* TODO enable this again when Brian fixed his code
-   * g_object_weak_ref (G_OBJECT (channel), (GWeakNotify) xfconf_shutdown, NULL); */
+  g_object_weak_ref (object_for_weak_ref, xfconf_shutdown, NULL);
 
   return channel;
 }
@@ -64,13 +65,8 @@ panel_properties_bind (XfconfChannel       *channel,
   panel_return_if_fail (properties != NULL);
 
   if (G_LIKELY (channel == NULL))
-    {
-      channel = xfconf_channel_get (XFCE_PANEL_PLUGIN_CHANNEL_NAME);
-      if (G_UNLIKELY (channel == NULL))
-        return;
-      /* TODO enable this again when Brian fixed his code
-       * g_object_weak_ref (G_OBJECT (object), (GWeakNotify) g_object_unref, channel); */
-    }
+    channel = panel_properties_get_channel (object);
+  panel_return_if_fail (XFCONF_IS_CHANNEL (channel));
 
   /* walk the properties array */
   for (prop = properties; prop->property != NULL; prop++)
diff --git a/common/panel-xfconf.h b/common/panel-xfconf.h
index 0551c05..760e431 100644
--- a/common/panel-xfconf.h
+++ b/common/panel-xfconf.h
@@ -33,7 +33,7 @@ struct _PanelProperty
 
 
 
-XfconfChannel *panel_properties_get_channel       (void);
+XfconfChannel *panel_properties_get_channel       (GObject             *object_for_weak_ref);
 
 void           panel_properties_bind              (XfconfChannel       *channel,
                                                    GObject             *object,
diff --git a/panel/panel-application.c b/panel/panel-application.c
index ad8ce36..7bd8361 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -182,8 +182,8 @@ panel_application_init (PanelApplication *application)
   application->drop_data_ready = FALSE;
   application->drop_occurred = FALSE;
 
-  /* get the xfconf channel */
-  application->xfconf = panel_properties_get_channel ();
+  /* get the xfconf channel (singleton) */
+  application->xfconf = panel_properties_get_channel (G_OBJECT (application));
 
   /* check if we need to force all plugins to run external */
   if (xfconf_channel_get_bool (application->xfconf, "/force-all-external", FALSE))
@@ -228,9 +228,6 @@ panel_application_finalize (GObject *object)
   /* cleanup the list of windows */
   g_slist_free (application->windows);
 
-  /* release the xfconf channel */
-  g_object_unref (G_OBJECT (application->xfconf));
-
   /* release the factory */
   g_object_unref (G_OBJECT (application->factory));
 
@@ -326,7 +323,8 @@ panel_application_load (PanelApplication *application)
             {
               /* plugin could not be loaded, remove it from the channel */
               g_snprintf (buf, sizeof (buf), "/panels/plugin-%d", unique_id);
-              xfconf_channel_reset_property (application->xfconf, buf, TRUE);
+              if (xfconf_channel_has_property (application->xfconf, buf))
+                xfconf_channel_reset_property (application->xfconf, buf, TRUE);
 
               /* show warnings */
               g_critical (_("Plugin \"%s-%d\" was not found and has been "
@@ -408,7 +406,8 @@ panel_application_plugin_delete_config (PanelApplication *application,
 
   /* remove the xfconf property */
   property = g_strdup_printf (PANEL_PLUGIN_PROPERTY_BASE, unique_id);
-  xfconf_channel_reset_property (application->xfconf, property, TRUE);
+  if (xfconf_channel_has_property (application->xfconf, property))
+    xfconf_channel_reset_property (application->xfconf, property, TRUE);
   g_free (property);
 
   /* lookup the rc file */
@@ -648,7 +647,8 @@ panel_application_window_destroyed (GtkWidget        *window,
 
       /* remove the properties of this panel */
       g_snprintf (buf, sizeof (buf), "/panels/panel-%u", n);
-      xfconf_channel_reset_property (application->xfconf, buf, TRUE);
+      if (xfconf_channel_has_property (application->xfconf, buf))
+        xfconf_channel_reset_property (application->xfconf, buf, TRUE);
 
       /* either remove the window or add the bindings */
       if (li->data == window)
@@ -1014,7 +1014,8 @@ panel_application_save (PanelApplication *application,
       if (G_UNLIKELY (children == NULL))
         {
           g_snprintf (buf, sizeof (buf), "/panels/panel-%u/plugin-ids", i);
-          xfconf_channel_reset_property (channel, buf, FALSE);
+          if (xfconf_channel_has_property (channel, buf))
+            xfconf_channel_reset_property (channel, buf, FALSE);
           continue;
         }
 
@@ -1180,7 +1181,8 @@ panel_application_new_window (PanelApplication *application,
     {
       /* remove the xfconf properties */
       property = g_strdup_printf ("/panels/panel-%d", g_slist_index (application->windows, window));
-      xfconf_channel_reset_property (application->xfconf, property, TRUE);
+      if (xfconf_channel_has_property (application->xfconf, property))
+        xfconf_channel_reset_property (application->xfconf, property, TRUE);
       g_free (property);
 
       /* set default position */



More information about the Xfce4-commits mailing list