]> git.pld-linux.org Git - packages/xfce4-power-manager.git/blob - 0154-Update-xfce4-session-lock-screen-setting.patch
- updated from git, upower 0.99 and systemd support added
[packages/xfce4-power-manager.git] / 0154-Update-xfce4-session-lock-screen-setting.patch
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
5
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.
11 ---
12  settings/xfpm-settings.c |  8 +++++++-
13  src/xfpm-xfconf.c        | 52 ++++++++++++++++++++++++++++++++++++++++++++++--
14  2 files changed, 57 insertions(+), 3 deletions(-)
15
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)
21  void
22  lock_screen_toggled_cb (GtkWidget *w, XfconfChannel *channel)
23  {
24 +    XfconfChannel *session_channel = xfconf_channel_get ("xfce4-session");
25      gboolean val = (gint) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(w));
26 -    
27 +
28 +    if ( !xfconf_channel_set_bool (session_channel, "/shutdown/LockScreen", val) )
29 +    {
30 +       g_critical ("Unable to set value for property %s\n", LOCK_SCREEN_ON_SLEEP);
31 +    }
32 +
33      if ( !xfconf_channel_set_bool (channel, PROPERTIES_PREFIX LOCK_SCREEN_ON_SLEEP, val) )
34      {
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
42  {
43      XfconfChannel      *channel;
44 +    XfconfChannel   *session_channel;
45      GValue              *values;
46  };
47  
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) )
50         return;
51  
52 -    XFPM_DEBUG("Property modified: %s\n", property);
53 +    XFPM_DEBUG ("Property modified: %s\n", property);
54      
55      g_object_set_property (G_OBJECT (conf), property + strlen (PROPERTIES_PREFIX), value);
56  }
57  
58  static void
59 +xfpm_xfsession_property_changed_cb (XfconfChannel *channel, gchar *property,
60 +                                GValue *value, XfpmXfconf *conf)
61 +{
62 +    /*FIXME: Set default for this key*/
63 +    if ( G_VALUE_TYPE(value) == G_TYPE_INVALID )
64 +        return;
65 +
66 +    XFPM_DEBUG ("property %s\n", property);
67 +
68 +    if ( g_strcmp0 (property, "/shutdown/LockScreen") != 0)
69 +        return;
70 +
71 +    /* sanity check */
72 +    if ( !G_VALUE_HOLDS (value, G_TYPE_BOOLEAN) )
73 +        return;
74 +
75 +    XFPM_DEBUG ("Property modified: %s\n", property);
76 +
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));
81 +}
82 +
83 +static void
84  xfpm_xfconf_class_init (XfpmXfconfClass *klass)
85  {
86      GObjectClass *object_class = G_OBJECT_CLASS(klass);
87 @@ -543,6 +569,7 @@ xfpm_xfconf_init (XfpmXfconf *conf)
88  {
89      GError *error = NULL;
90      gboolean channel_valid;
91 +    gboolean lock_screen;
92        
93      conf->priv = XFPM_XFCONF_GET_PRIVATE (conf);
94      
95 @@ -557,9 +584,27 @@ xfpm_xfconf_init (XfpmXfconf *conf)
96      else
97      {
98         conf->priv->channel = xfconf_channel_new ("xfce4-power-manager");
99 +    conf->priv->session_channel = xfconf_channel_new ("xfce4-session");
100 +
101 +    /* if xfce4-session is around, sync to it on startup */
102 +    if ( xfconf_channel_has_property (conf->priv->session_channel, "/shutdown/LockScreen") )
103 +    {
104 +        lock_screen = xfconf_channel_get_bool (conf->priv->session_channel,
105 +                                               "/shutdown/LockScreen",
106 +                                               TRUE);
107 +
108 +        XFPM_DEBUG("lock screen %s", lock_screen ? "TRUE" : "FALSE");
109 +
110 +        g_object_set (G_OBJECT (conf), LOCK_SCREEN_ON_SLEEP, lock_screen, NULL);
111 +    }
112  
113         g_signal_connect (conf->priv->channel, "property-changed",
114                           G_CALLBACK (xfpm_xfconf_property_changed_cb), conf);
115 +
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);
119 +
120         channel_valid = TRUE;
121      }
122      xfpm_xfconf_load (conf, channel_valid);
123 @@ -583,7 +628,10 @@ xfpm_xfconf_finalize(GObject *object)
124      
125      if (conf->priv->channel )
126         g_object_unref (conf->priv->channel);
127 -    
128 +
129 +    if (conf->priv->session_channel )
130 +        g_object_unref (conf->priv->session_channel);
131 +
132      G_OBJECT_CLASS(xfpm_xfconf_parent_class)->finalize(object);
133  }
134  
135 -- 
136 1.9.3
137
This page took 0.102986 seconds and 3 git commands to generate.