2
* Copyright (C) 2009 Nick Schermer <nick@xfce.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
#include <dbus/dbus-glib.h>
25
#include <common/panel-private.h>
26
#include <common/panel-xfconf.h>
27
#include <libxfce4panel/xfce-panel-macros.h>
32
panel_properties_store_value (XfconfChannel *channel,
33
const gchar *xfconf_property,
34
GType xfconf_property_type,
36
const gchar *object_property)
38
GValue value = { 0, };
43
panel_return_if_fail (G_IS_OBJECT (object));
44
panel_return_if_fail (XFCONF_IS_CHANNEL (channel));
47
/* check if the types match */
48
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), object_property);
49
panel_assert (pspec != NULL);
50
panel_assert (G_PARAM_SPEC_VALUE_TYPE (pspec) == xfconf_property_type);
53
/* write the property to the xfconf channel */
54
g_value_init (&value, xfconf_property_type);
55
g_object_get_property (G_OBJECT (object), object_property, &value);
56
xfconf_channel_set_property (channel, xfconf_property, &value);
57
g_value_unset (&value);
63
panel_properties_get_channel (GObject *object_for_weak_ref)
66
XfconfChannel *channel;
68
panel_return_val_if_fail (G_IS_OBJECT (object_for_weak_ref), NULL);
70
if (!xfconf_init (&error))
72
g_critical ("Failed to initialize Xfconf: %s", error->message);
77
channel = xfconf_channel_get (XFCE_PANEL_CHANNEL_NAME);
78
g_object_weak_ref (object_for_weak_ref, (GWeakNotify) xfconf_shutdown, NULL);
86
panel_properties_bind (XfconfChannel *channel,
88
const gchar *property_base,
89
const PanelProperty *properties,
90
gboolean save_properties)
92
const PanelProperty *prop;
95
panel_return_if_fail (channel == NULL || XFCONF_IS_CHANNEL (channel));
96
panel_return_if_fail (G_IS_OBJECT (object));
97
panel_return_if_fail (property_base != NULL && *property_base == '/');
98
panel_return_if_fail (properties != NULL);
100
if (G_LIKELY (channel == NULL))
101
channel = panel_properties_get_channel (object);
102
panel_return_if_fail (XFCONF_IS_CHANNEL (channel));
104
/* walk the properties array */
105
for (prop = properties; prop->property != NULL; prop++)
107
property = g_strconcat (property_base, "/", prop->property, NULL);
110
panel_properties_store_value (channel, property, prop->type, object, prop->property);
112
if (G_LIKELY (prop->type != GDK_TYPE_COLOR))
113
xfconf_g_property_bind (channel, property, prop->type, object, prop->property);
115
xfconf_g_property_bind_gdkcolor (channel, property, object, prop->property);
124
panel_properties_unbind (GObject *object)
126
xfconf_g_property_unbind_all (object);
132
panel_properties_value_array_get_type (void)
134
static volatile gsize type__volatile = 0;
137
if (g_once_init_enter (&type__volatile))
139
type = dbus_g_type_get_collection ("GPtrArray", G_TYPE_VALUE);
140
g_once_init_leave (&type__volatile, type);
143
return type__volatile;