[Xfce4-commits] <xfce4-panel:devel> Allow passing a NULL channel to panel_properties_bind().
Nick Schermer
nick at xfce.org
Tue Aug 11 20:34:39 CEST 2009
Updating branch refs/heads/devel
to 25f2dd879c87472637eb924b39508482258af1c3 (commit)
from e5584101ecfceebbb97fd2292a14a462712aca8a (commit)
commit 25f2dd879c87472637eb924b39508482258af1c3
Author: Nick Schermer <nick at xfce.org>
Date: Mon Jun 1 10:57:40 2009 +0200
Allow passing a NULL channel to panel_properties_bind().
The binding will use the default panel and take care of ref-
counting.
common/panel-xfconf.c | 10 +++++++++-
plugins/actions/actions.c | 17 +----------------
plugins/launcher/launcher.c | 10 +---------
plugins/pager/pager.c | 16 +---------------
plugins/separator/separator.c | 17 +----------------
plugins/systray/systray.c | 12 +-----------
plugins/tasklist/tasklist.c | 14 +-------------
plugins/windowmenu/windowmenu.c | 12 +-----------
8 files changed, 16 insertions(+), 92 deletions(-)
diff --git a/common/panel-xfconf.c b/common/panel-xfconf.c
index 7df31db..1414478 100644
--- a/common/panel-xfconf.c
+++ b/common/panel-xfconf.c
@@ -202,7 +202,7 @@ panel_properties_bind (XfconfChannel *channel,
PropertyBinding *binding;
GHashTable *hash_table;
- panel_return_if_fail (XFCONF_IS_CHANNEL (channel));
+ panel_return_if_fail (channel == NULL || XFCONF_IS_CHANNEL (channel));
panel_return_if_fail (G_IS_OBJECT (object));
panel_return_if_fail (property_base != NULL && *property_base == '/');
panel_return_if_fail (properties != NULL);
@@ -215,6 +215,14 @@ panel_properties_bind (XfconfChannel *channel,
else
hash_table = xfconf_channel_get_properties (channel, property_base);
+ if (G_LIKELY (channel == NULL))
+ {
+ /* use the default channel if none is set by the user and take
+ * care of refcounting */
+ channel = panel_properties_get_channel ();
+ g_object_weak_ref (G_OBJECT (object), (GWeakNotify) g_object_unref, channel);
+ }
+
/* walk the properties array */
for (prop = properties; prop->property != NULL; prop++)
{
diff --git a/plugins/actions/actions.c b/plugins/actions/actions.c
index 2112750..c9e387c 100644
--- a/plugins/actions/actions.c
+++ b/plugins/actions/actions.c
@@ -88,9 +88,6 @@ struct _ActionsPlugin
/* parent type */
XfcePanelPlugin __parent__;
- /* xfconf channel */
- XfconfChannel *channel;
-
/* widgets */
GtkWidget *box;
GtkWidget *first_button;
@@ -310,11 +307,8 @@ actions_plugin_construct (XfcePanelPlugin *panel_plugin)
{ NULL, G_TYPE_NONE }
};
- /* open the xfconf channel */
- plugin->channel = panel_properties_get_channel ();
-
/* bind all properties */
- panel_properties_bind (plugin->channel, G_OBJECT (plugin),
+ panel_properties_bind (NULL, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
properties, FALSE);
@@ -331,14 +325,6 @@ actions_plugin_construct (XfcePanelPlugin *panel_plugin)
static void
actions_plugin_free_data (XfcePanelPlugin *panel_plugin)
{
- ActionsPlugin *plugin = XFCE_ACTIONS_PLUGIN (panel_plugin);
-
- panel_return_if_fail (XFCONF_IS_CHANNEL (plugin->channel));
-
- /* release the xfonf channel */
- if (G_LIKELY (plugin->channel != NULL))
- g_object_unref (G_OBJECT (plugin->channel));
-
/* shutdown xfconf */
xfconf_shutdown ();
}
@@ -383,7 +369,6 @@ actions_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
guint i;
panel_return_if_fail (XFCE_IS_ACTIONS_PLUGIN (plugin));
- panel_return_if_fail (XFCONF_IS_CHANNEL (plugin->channel));
/* load the dialog from the glade file */
builder = gtk_builder_new ();
diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c
index 42a7414..5e1d9ac 100644
--- a/plugins/launcher/launcher.c
+++ b/plugins/launcher/launcher.c
@@ -107,8 +107,6 @@ struct _LauncherPlugin
{
XfcePanelPlugin __parent__;
- XfconfChannel *channel;
-
GtkWidget *box;
GtkWidget *button;
GtkWidget *arrow;
@@ -513,11 +511,8 @@ launcher_plugin_construct (XfcePanelPlugin *panel_plugin)
{ NULL, G_TYPE_NONE }
};
- /* open the xfconf channel */
- plugin->channel = panel_properties_get_channel ();
-
/* bind all properties */
- panel_properties_bind (plugin->channel, G_OBJECT (plugin),
+ panel_properties_bind (NULL, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
properties, FALSE);
@@ -559,9 +554,6 @@ launcher_plugin_free_data (XfcePanelPlugin *panel_plugin)
{
LauncherPlugin *plugin = XFCE_LAUNCHER_PLUGIN (panel_plugin);
- /* release the xfconf channel */
- g_object_unref (G_OBJECT (plugin->channel));
-
/* destroy the menu and timeout */
launcher_plugin_menu_destroy (plugin);
diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index d2f0104..78f80df 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -70,9 +70,6 @@ struct _PagerPlugin
/* the wnck pager */
GtkWidget *wnck_pager;
- /* xfconf channel */
- XfconfChannel *channel;
-
/* the active wnck screen */
WnckScreen *wnck_screen;
@@ -152,7 +149,6 @@ pager_plugin_init (PagerPlugin *plugin)
plugin->show_names = FALSE;
plugin->rows = 1;
plugin->wnck_pager = NULL;
- plugin->channel = NULL;
/* show the properties dialog */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
@@ -318,11 +314,8 @@ pager_plugin_construct (XfcePanelPlugin *panel_plugin)
{ NULL, G_TYPE_NONE }
};
- /* open the xfconf channel */
- plugin->channel = panel_properties_get_channel ();
-
/* bind all properties */
- panel_properties_bind (plugin->channel, G_OBJECT (plugin),
+ panel_properties_bind (NULL, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
properties, FALSE);
@@ -339,16 +332,10 @@ pager_plugin_free_data (XfcePanelPlugin *panel_plugin)
{
PagerPlugin *plugin = XFCE_PAGER_PLUGIN (panel_plugin);
- panel_return_if_fail (XFCONF_IS_CHANNEL (plugin->channel));
-
/* disconnect screen changed signal */
g_signal_handlers_disconnect_by_func (G_OBJECT (plugin),
pager_plugin_screen_changed, NULL);
- /* release the xfonf channel */
- if (G_LIKELY (plugin->channel != NULL))
- g_object_unref (G_OBJECT (plugin->channel));
-
/* shutdown xfconf */
xfconf_shutdown ();
}
@@ -444,7 +431,6 @@ pager_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
GObject *dialog, *object;
panel_return_if_fail (XFCE_IS_PAGER_PLUGIN (plugin));
- panel_return_if_fail (XFCONF_IS_CHANNEL (plugin->channel));
/* load the dialog from the glade file */
builder = gtk_builder_new ();
diff --git a/plugins/separator/separator.c b/plugins/separator/separator.c
index 50ab2f2..9c73680 100644
--- a/plugins/separator/separator.c
+++ b/plugins/separator/separator.c
@@ -77,9 +77,6 @@ struct _SeparatorPlugin
/* parent type */
XfcePanelPlugin __parent__;
- /* xfconf channel */
- XfconfChannel *channel;
-
/* separator style */
SeparatorPluginStyle style;
};
@@ -283,11 +280,8 @@ separator_plugin_construct (XfcePanelPlugin *panel_plugin)
{ NULL, G_TYPE_NONE }
};
- /* set the xfconf channel */
- plugin->channel = panel_properties_get_channel ();
-
/* connect all properties */
- panel_properties_bind (plugin->channel, G_OBJECT (plugin),
+ panel_properties_bind (NULL, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
properties, FALSE);
@@ -300,14 +294,6 @@ separator_plugin_construct (XfcePanelPlugin *panel_plugin)
static void
separator_plugin_free_data (XfcePanelPlugin *panel_plugin)
{
- SeparatorPlugin *plugin = XFCE_SEPARATOR_PLUGIN (panel_plugin);
-
- panel_return_if_fail (XFCONF_IS_CHANNEL (plugin->channel));
-
- /* release the xfonf channel */
- if (G_LIKELY (plugin->channel != NULL))
- g_object_unref (G_OBJECT (plugin->channel));
-
/* shutdown xfconf */
xfconf_shutdown ();
}
@@ -341,7 +327,6 @@ separator_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
GObject *object;
panel_return_if_fail (XFCE_IS_SEPARATOR_PLUGIN (plugin));
- panel_return_if_fail (XFCONF_IS_CHANNEL (plugin->channel));
/* load the dialog from the glade file */
builder = gtk_builder_new ();
diff --git a/plugins/systray/systray.c b/plugins/systray/systray.c
index d7878d9..3a22d90 100644
--- a/plugins/systray/systray.c
+++ b/plugins/systray/systray.c
@@ -81,9 +81,6 @@ struct _SystrayPlugin
/* systray manager */
SystrayManager *manager;
- /* xfconf channnel */
- XfconfChannel *channel;
-
/* widgets */
GtkWidget *frame;
GtkWidget *box;
@@ -305,11 +302,8 @@ systray_plugin_construct (XfcePanelPlugin *panel_plugin)
{ NULL, G_TYPE_NONE }
};
- /* open the xfconf channel */
- plugin->channel = panel_properties_get_channel ();
-
/* bind all properties */
- panel_properties_bind (plugin->channel, G_OBJECT (plugin),
+ panel_properties_bind (NULL, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
properties, FALSE);
@@ -336,10 +330,6 @@ systray_plugin_free_data (XfcePanelPlugin *panel_plugin)
if (G_LIKELY (plugin->manager))
g_object_unref (G_OBJECT (plugin->manager));
- /* release the xfconf channel */
- if (G_LIKELY (plugin->channel))
- g_object_unref (G_OBJECT (plugin->channel));
-
/* shutdown xfconf */
xfconf_shutdown ();
}
diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c
index 3dc436a..2609dea 100644
--- a/plugins/tasklist/tasklist.c
+++ b/plugins/tasklist/tasklist.c
@@ -52,9 +52,6 @@ struct _TasklistPlugin
{
XfcePanelPlugin __parent__;
- /* the xfconf channel */
- XfconfChannel *channel;
-
/* the tasklist widget */
GtkWidget *tasklist;
GtkWidget *handle;
@@ -144,11 +141,8 @@ tasklist_plugin_construct (XfcePanelPlugin *panel_plugin)
/* expand the plugin */
xfce_panel_plugin_set_expand (panel_plugin, TRUE);
- /* open the xfconf channel */
- plugin->channel = panel_properties_get_channel ();
-
/* bind all properties */
- panel_properties_bind (plugin->channel, G_OBJECT (plugin->tasklist),
+ panel_properties_bind (NULL, G_OBJECT (plugin->tasklist),
xfce_panel_plugin_get_property_base (panel_plugin),
properties, FALSE);
@@ -161,12 +155,6 @@ tasklist_plugin_construct (XfcePanelPlugin *panel_plugin)
static void
tasklist_plugin_free_data (XfcePanelPlugin *panel_plugin)
{
- TasklistPlugin *plugin = XFCE_TASKLIST_PLUGIN (panel_plugin);
-
- /* release the xfconf channel */
- if (G_LIKELY (plugin->channel))
- g_object_unref (G_OBJECT (plugin->channel));
-
/* shutdown xfconf */
xfconf_shutdown ();
}
diff --git a/plugins/windowmenu/windowmenu.c b/plugins/windowmenu/windowmenu.c
index e4e4d8e..fda591b 100644
--- a/plugins/windowmenu/windowmenu.c
+++ b/plugins/windowmenu/windowmenu.c
@@ -46,9 +46,6 @@ struct _WindowMenuPlugin
{
XfcePanelPlugin __parent__;
- /* the xfconf channel */
- XfconfChannel *channel;
-
/* the screen we're showing */
WnckScreen *screen;
@@ -394,14 +391,11 @@ window_menu_plugin_construct (XfcePanelPlugin *panel_plugin)
{ NULL, G_TYPE_NONE }
};
- /* open the xfconf channel */
- plugin->channel = panel_properties_get_channel ();
-
/* show the icon */
gtk_widget_show (plugin->icon);
/* bind all properties */
- panel_properties_bind (plugin->channel, G_OBJECT (plugin),
+ panel_properties_bind (NULL, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
properties, FALSE);
@@ -441,10 +435,6 @@ window_menu_plugin_free_data (XfcePanelPlugin *panel_plugin)
plugin->screen = NULL;
}
- /* release the xfconf channel */
- if (G_LIKELY (plugin->channel))
- g_object_unref (G_OBJECT (plugin->channel));
-
/* shutdown xfconf */
xfconf_shutdown ();
}
More information about the Xfce4-commits
mailing list