[Xfce4-commits] <xfce4-panel:devel> Implement property saving in the bindings.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:34:38 CEST 2009
Updating branch refs/heads/devel
to e5584101ecfceebbb97fd2292a14a462712aca8a (commit)
from 1e5e930fd152b40028036b4b8bfb5b8960e08df8 (commit)
commit e5584101ecfceebbb97fd2292a14a462712aca8a
Author: Nick Schermer <nick at xfce.org>
Date: Mon Jun 1 10:34:35 2009 +0200
Implement property saving in the bindings.
If saving is enabled, the bindings won't restore the value
found in the channel, but instead notify to property on
the object so it gets stored.
common/panel-xfconf.c | 11 +++++++++--
common/panel-xfconf.h | 3 ++-
panel/panel-application.c | 4 ++--
plugins/actions/actions.c | 2 +-
plugins/launcher/launcher.c | 2 +-
plugins/pager/pager.c | 2 +-
plugins/separator/separator.c | 2 +-
plugins/systray/systray.c | 2 +-
plugins/tasklist/tasklist.c | 2 +-
plugins/windowmenu/windowmenu.c | 2 +-
10 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/common/panel-xfconf.c b/common/panel-xfconf.c
index b2920b9..7df31db 100644
--- a/common/panel-xfconf.c
+++ b/common/panel-xfconf.c
@@ -193,7 +193,8 @@ void
panel_properties_bind (XfconfChannel *channel,
GObject *object,
const gchar *property_base,
- const PanelProperty *properties)
+ const PanelProperty *properties,
+ gboolean save_properties)
{
const PanelProperty *prop;
const GValue *value;
@@ -207,7 +208,9 @@ panel_properties_bind (XfconfChannel *channel,
panel_return_if_fail (properties != NULL);
/* get or ref the hash table */
- if (shared_hash_table != NULL)
+ if (save_properties)
+ hash_table = NULL;
+ else if (shared_hash_table != NULL)
hash_table = g_hash_table_ref (shared_hash_table);
else
hash_table = xfconf_channel_get_properties (channel, property_base);
@@ -244,6 +247,10 @@ panel_properties_bind (XfconfChannel *channel,
G_CALLBACK (panel_properties_object_notify), binding,
panel_properties_object_disconnect, 0);
+ /* emit the property so it gets saved */
+ if (save_properties)
+ g_object_notify (G_OBJECT (object), prop->property);
+
/* monitor channel changes */
g_snprintf (buf, sizeof (buf), "property-changed::%s", binding->channel_prop);
g_object_weak_ref (G_OBJECT (channel), panel_properties_channel_destroyed, binding);
diff --git a/common/panel-xfconf.h b/common/panel-xfconf.h
index db58f2f..6d75660 100644
--- a/common/panel-xfconf.h
+++ b/common/panel-xfconf.h
@@ -34,7 +34,8 @@ XfconfChannel *panel_properties_get_channel (void);
void panel_properties_bind (XfconfChannel *channel,
GObject *object,
const gchar *property_base,
- const PanelProperty *properties);
+ const PanelProperty *properties,
+ gboolean save_properties);
void panel_properties_unbind (GObject *object);
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 33deee9..5589bce 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -265,7 +265,7 @@ panel_application_finalize (GObject *object)
static void
panel_application_xfconf_window_bindings (PanelApplication *application,
PanelWindow *window,
- gboolean store_settings)
+ gboolean save_properties)
{
gchar *property_base;
const PanelProperty properties[] =
@@ -293,7 +293,7 @@ panel_application_xfconf_window_bindings (PanelApplication *application,
/* bind all the properties */
panel_properties_bind (application->xfconf, G_OBJECT (window),
- property_base, properties);
+ property_base, properties, save_properties);
/* cleanup */
g_free (property_base);
diff --git a/plugins/actions/actions.c b/plugins/actions/actions.c
index 58a5b7a..2112750 100644
--- a/plugins/actions/actions.c
+++ b/plugins/actions/actions.c
@@ -316,7 +316,7 @@ actions_plugin_construct (XfcePanelPlugin *panel_plugin)
/* bind all properties */
panel_properties_bind (plugin->channel, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
- properties);
+ properties, FALSE);
/* set orientation and size */
actions_plugin_orientation_changed (panel_plugin,
diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c
index 80670f3..42a7414 100644
--- a/plugins/launcher/launcher.c
+++ b/plugins/launcher/launcher.c
@@ -519,7 +519,7 @@ launcher_plugin_construct (XfcePanelPlugin *panel_plugin)
/* bind all properties */
panel_properties_bind (plugin->channel, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
- properties);
+ properties, FALSE);
/* handle and empty plugin */
if (G_UNLIKELY (plugin->items == NULL))
diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index 1c24850..d2f0104 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -324,7 +324,7 @@ pager_plugin_construct (XfcePanelPlugin *panel_plugin)
/* bind all properties */
panel_properties_bind (plugin->channel, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
- properties);
+ properties, FALSE);
/* create the pager */
g_signal_connect (G_OBJECT (plugin), "screen-changed",
diff --git a/plugins/separator/separator.c b/plugins/separator/separator.c
index 4017cff..50ab2f2 100644
--- a/plugins/separator/separator.c
+++ b/plugins/separator/separator.c
@@ -289,7 +289,7 @@ separator_plugin_construct (XfcePanelPlugin *panel_plugin)
/* connect all properties */
panel_properties_bind (plugin->channel, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
- properties);
+ properties, FALSE);
/* make sure the plugin is drawn */
gtk_widget_queue_draw (GTK_WIDGET (panel_plugin));
diff --git a/plugins/systray/systray.c b/plugins/systray/systray.c
index 564930f..d7878d9 100644
--- a/plugins/systray/systray.c
+++ b/plugins/systray/systray.c
@@ -311,7 +311,7 @@ systray_plugin_construct (XfcePanelPlugin *panel_plugin)
/* bind all properties */
panel_properties_bind (plugin->channel, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
- properties);
+ properties, FALSE);
/* monitor screen changes */
g_signal_connect (G_OBJECT (plugin), "screen-changed",
diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c
index 4a0ce0f..3dc436a 100644
--- a/plugins/tasklist/tasklist.c
+++ b/plugins/tasklist/tasklist.c
@@ -150,7 +150,7 @@ tasklist_plugin_construct (XfcePanelPlugin *panel_plugin)
/* bind all properties */
panel_properties_bind (plugin->channel, G_OBJECT (plugin->tasklist),
xfce_panel_plugin_get_property_base (panel_plugin),
- properties);
+ properties, FALSE);
/* show the tasklist */
gtk_widget_show (plugin->tasklist);
diff --git a/plugins/windowmenu/windowmenu.c b/plugins/windowmenu/windowmenu.c
index 9605020..e4e4d8e 100644
--- a/plugins/windowmenu/windowmenu.c
+++ b/plugins/windowmenu/windowmenu.c
@@ -403,7 +403,7 @@ window_menu_plugin_construct (XfcePanelPlugin *panel_plugin)
/* bind all properties */
panel_properties_bind (plugin->channel, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
- properties);
+ properties, FALSE);
/* monitor screen changes */
g_signal_connect (G_OBJECT (plugin), "screen-changed",
More information about the Xfce4-commits
mailing list