1 From bed10b8068d549bf0dd59542c90dec9f6b576e64 Mon Sep 17 00:00:00 2001
2 From: Eric Koegel <eric.koegel@gmail.com>
3 Date: Sun, 6 Apr 2014 18:13:25 +0300
4 Subject: [PATCH 154/219] Update xfce4-session lock-screen setting
6 When xfpm changes it's lock-screen setting, it will also attempt
7 to update xfce4-session. Additionally, xfpm will watch session's
8 lock-screen setting and update its own. This way there is one
9 single setting for both programs in the future, however xfpm will
10 continue to function stand-alone.
12 settings/xfpm-settings.c | 8 +++++++-
13 src/xfpm-xfconf.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++--
14 2 files changed, 57 insertions(+), 3 deletions(-)
16 diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c
17 index 5275247..513503a 100644
18 --- a/settings/xfpm-settings.c
19 +++ b/settings/xfpm-settings.c
20 @@ -728,8 +728,14 @@ critical_level_value_changed_cb (GtkSpinButton *w, XfconfChannel *channel)
22 lock_screen_toggled_cb (GtkWidget *w, XfconfChannel *channel)
24 + XfconfChannel *session_channel = xfconf_channel_get ("xfce4-session");
25 gboolean val = (gint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
28 + if ( !xfconf_channel_set_bool (session_channel, "/shutdown/LockScreen", val) )
30 + g_critical ("Unable to set value for property %s\n", LOCK_SCREEN_ON_SLEEP);
33 if ( !xfconf_channel_set_bool (channel, PROPERTIES_PREFIX LOCK_SCREEN_ON_SLEEP, val) )
35 g_critical ("Unable to set value for property %s\n", LOCK_SCREEN_ON_SLEEP);
36 diff --git a/src/xfpm-xfconf.c b/src/xfpm-xfconf.c
37 index 7e1e086..7ef8ae8 100644
38 --- a/src/xfpm-xfconf.c
39 +++ b/src/xfpm-xfconf.c
40 @@ -44,6 +44,7 @@ static void xfpm_xfconf_finalize (GObject *object);
41 struct XfpmXfconfPrivate
43 XfconfChannel *channel;
44 + XfconfChannel *session_channel;
48 @@ -180,12 +181,37 @@ xfpm_xfconf_property_changed_cb (XfconfChannel *channel, gchar *property,
49 if ( !g_str_has_prefix (property, PROPERTIES_PREFIX) || strlen (property) <= strlen (PROPERTIES_PREFIX) )
52 - XFPM_DEBUG("Property modified: %s\n", property);
53 + XFPM_DEBUG ("Property modified: %s\n", property);
55 g_object_set_property (G_OBJECT (conf), property + strlen (PROPERTIES_PREFIX), value);
59 +xfpm_xfsession_property_changed_cb (XfconfChannel *channel, gchar *property,
60 + GValue *value, XfpmXfconf *conf)
62 + /*FIXME: Set default for this key*/
63 + if ( G_VALUE_TYPE(value) == G_TYPE_INVALID )
66 + XFPM_DEBUG ("property %s\n", property);
68 + if ( g_strcmp0 (property, "/shutdown/LockScreen") != 0)
72 + if ( !G_VALUE_HOLDS (value, G_TYPE_BOOLEAN) )
75 + XFPM_DEBUG ("Property modified: %s\n", property);
77 + /* update xfconf which will update xfpm and keep things in sync */
78 + xfconf_channel_set_bool (conf->priv->channel,
79 + PROPERTIES_PREFIX LOCK_SCREEN_ON_SLEEP,
80 + g_value_get_boolean(value));
84 xfpm_xfconf_class_init (XfpmXfconfClass *klass)
86 GObjectClass *object_class = G_OBJECT_CLASS(klass);
87 @@ -543,6 +569,7 @@ xfpm_xfconf_init (XfpmXfconf *conf)
90 gboolean channel_valid;
91 + gboolean lock_screen;
93 conf->priv = XFPM_XFCONF_GET_PRIVATE (conf);
95 @@ -557,9 +584,27 @@ xfpm_xfconf_init (XfpmXfconf *conf)
98 conf->priv->channel = xfconf_channel_new ("xfce4-power-manager");
99 + conf->priv->session_channel = xfconf_channel_new ("xfce4-session");
101 + /* if xfce4-session is around, sync to it on startup */
102 + if ( xfconf_channel_has_property (conf->priv->session_channel, "/shutdown/LockScreen") )
104 + lock_screen = xfconf_channel_get_bool (conf->priv->session_channel,
105 + "/shutdown/LockScreen",
108 + XFPM_DEBUG("lock screen %s", lock_screen ? "TRUE" : "FALSE");
110 + g_object_set (G_OBJECT (conf), LOCK_SCREEN_ON_SLEEP, lock_screen, NULL);
113 g_signal_connect (conf->priv->channel, "property-changed",
114 G_CALLBACK (xfpm_xfconf_property_changed_cb), conf);
116 + /* watch for session's property change so we can stay in sync */
117 + g_signal_connect (conf->priv->session_channel, "property-changed",
118 + G_CALLBACK (xfpm_xfsession_property_changed_cb), conf);
120 channel_valid = TRUE;
122 xfpm_xfconf_load (conf, channel_valid);
123 @@ -583,7 +628,10 @@ xfpm_xfconf_finalize(GObject *object)
125 if (conf->priv->channel )
126 g_object_unref (conf->priv->channel);
129 + if (conf->priv->session_channel )
130 + g_object_unref (conf->priv->session_channel);
132 G_OBJECT_CLASS(xfpm_xfconf_parent_class)->finalize(object);