[Xfce4-commits] [xfce/xfce4-power-manager] 01/01: Update xfce4-session lock-screen setting

noreply at xfce.org noreply at xfce.org
Sun Apr 6 17:15:49 CEST 2014


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch eric/bugzilla-patches
in repository xfce/xfce4-power-manager.

commit ef5ccd71a62130de6d40b95bb22deb6c51ebb518
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sun Apr 6 18:13:25 2014 +0300

    Update xfce4-session lock-screen setting
    
    When xfpm changes it's lock-screen setting, it will also attempt
    to update xfce4-session. Additionally, xfpm will watch session's
    lock-screen setting and update its own. This way there is one
    single setting for both programs in the future, however xfpm will
    continue to function stand-alone.
---
 settings/xfpm-settings.c |    8 ++++++-
 src/xfpm-xfconf.c        |   52 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c
index 5275247..513503a 100644
--- a/settings/xfpm-settings.c
+++ b/settings/xfpm-settings.c
@@ -728,8 +728,14 @@ critical_level_value_changed_cb (GtkSpinButton *w, XfconfChannel *channel)
 void
 lock_screen_toggled_cb (GtkWidget *w, XfconfChannel *channel)
 {
+    XfconfChannel *session_channel = xfconf_channel_get ("xfce4-session");
     gboolean val = (gint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
-    
+
+    if ( !xfconf_channel_set_bool (session_channel, "/shutdown/LockScreen", val) )
+    {
+	g_critical ("Unable to set value for property %s\n", LOCK_SCREEN_ON_SLEEP);
+    }
+
     if ( !xfconf_channel_set_bool (channel, PROPERTIES_PREFIX LOCK_SCREEN_ON_SLEEP, val) )
     {
 	g_critical ("Unable to set value for property %s\n", LOCK_SCREEN_ON_SLEEP);
diff --git a/src/xfpm-xfconf.c b/src/xfpm-xfconf.c
index 7e1e086..7ef8ae8 100644
--- a/src/xfpm-xfconf.c
+++ b/src/xfpm-xfconf.c
@@ -44,6 +44,7 @@ static void xfpm_xfconf_finalize   (GObject *object);
 struct XfpmXfconfPrivate
 {
     XfconfChannel 	*channel;
+    XfconfChannel   *session_channel;
     GValue              *values;
 };
 
@@ -180,12 +181,37 @@ xfpm_xfconf_property_changed_cb (XfconfChannel *channel, gchar *property,
     if ( !g_str_has_prefix (property, PROPERTIES_PREFIX) || strlen (property) <= strlen (PROPERTIES_PREFIX) )
 	return;
 
-    XFPM_DEBUG("Property modified: %s\n", property);
+    XFPM_DEBUG ("Property modified: %s\n", property);
     
     g_object_set_property (G_OBJECT (conf), property + strlen (PROPERTIES_PREFIX), value);
 }
 
 static void
+xfpm_xfsession_property_changed_cb (XfconfChannel *channel, gchar *property,
+				 GValue *value, XfpmXfconf *conf)
+{
+    /*FIXME: Set default for this key*/
+    if ( G_VALUE_TYPE(value) == G_TYPE_INVALID )
+        return;
+
+    XFPM_DEBUG ("property %s\n", property);
+
+    if ( g_strcmp0 (property, "/shutdown/LockScreen") != 0)
+        return;
+
+    /* sanity check */
+    if ( !G_VALUE_HOLDS (value, G_TYPE_BOOLEAN) )
+        return;
+
+    XFPM_DEBUG ("Property modified: %s\n", property);
+
+    /* update xfconf which will update xfpm and keep things in sync */
+    xfconf_channel_set_bool (conf->priv->channel,
+                             PROPERTIES_PREFIX LOCK_SCREEN_ON_SLEEP,
+                             g_value_get_boolean(value));
+}
+
+static void
 xfpm_xfconf_class_init (XfpmXfconfClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
@@ -543,6 +569,7 @@ xfpm_xfconf_init (XfpmXfconf *conf)
 {
     GError *error = NULL;
     gboolean channel_valid;
+    gboolean lock_screen;
       
     conf->priv = XFPM_XFCONF_GET_PRIVATE (conf);
     
@@ -557,9 +584,27 @@ xfpm_xfconf_init (XfpmXfconf *conf)
     else
     {
 	conf->priv->channel = xfconf_channel_new ("xfce4-power-manager");
+    conf->priv->session_channel = xfconf_channel_new ("xfce4-session");
+
+    /* if xfce4-session is around, sync to it on startup */
+    if ( xfconf_channel_has_property (conf->priv->session_channel, "/shutdown/LockScreen") )
+    {
+        lock_screen = xfconf_channel_get_bool (conf->priv->session_channel,
+                                               "/shutdown/LockScreen",
+                                               TRUE);
+
+        XFPM_DEBUG("lock screen %s", lock_screen ? "TRUE" : "FALSE");
+
+        g_object_set (G_OBJECT (conf), LOCK_SCREEN_ON_SLEEP, lock_screen, NULL);
+    }
 
 	g_signal_connect (conf->priv->channel, "property-changed",
 			  G_CALLBACK (xfpm_xfconf_property_changed_cb), conf);
+
+    /* watch for session's property change so we can stay in sync */
+    g_signal_connect (conf->priv->session_channel, "property-changed",
+              G_CALLBACK (xfpm_xfsession_property_changed_cb), conf);
+
 	channel_valid = TRUE;
     }
     xfpm_xfconf_load (conf, channel_valid);
@@ -583,7 +628,10 @@ xfpm_xfconf_finalize(GObject *object)
     
     if (conf->priv->channel )
 	g_object_unref (conf->priv->channel);
-    
+
+    if (conf->priv->session_channel )
+        g_object_unref (conf->priv->session_channel);
+
     G_OBJECT_CLASS(xfpm_xfconf_parent_class)->finalize(object);
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list