summaryrefslogtreecommitdiff
path: root/community/gnome-settings-daemon-compat/sessionisactive-port.patch
blob: dc5fd260e6bc62e53ab9555af41d64ee623fab8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From 32b0b2d85629ae765543df1d940a5ca3c37dcec1 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Tue, 06 Nov 2012 22:47:05 +0000
Subject: [wip] Port to gnome-session's SessionIsActive property

Rather than maintaining the systemd code here, monitor gnome-session's
SessionIsActive property.  This allows us to drop the compile-time
dependency on systemd.

The power plugin is declared dependent on systemd at runtime, but the
rest of the code should operate in more "basic functionality" mode.
---
(limited to 'plugins/automount')

diff --git a/plugins/automount/gsd-automount-manager.c b/plugins/automount/gsd-automount-manager.c
index 7912f19..d8e9e07 100644
--- a/plugins/automount/gsd-automount-manager.c
+++ b/plugins/automount/gsd-automount-manager.c
@@ -42,7 +42,7 @@ struct GsdAutomountManagerPrivate
 	GVolumeMonitor *volume_monitor;
 	unsigned int automount_idle_id;
 
-        GnomeSettingsSession *session;
+        GDBusProxy *session;
         gboolean session_is_active;
         gboolean screensaver_active;
         guint ss_watch_id;
@@ -288,17 +288,21 @@ mount_added_callback (GVolumeMonitor *monitor,
 
 
 static void
-session_state_changed (GnomeSettingsSession *session, GParamSpec *pspec, gpointer user_data)
+session_props_changed (GDBusProxy *session, GVariant *v, char **props, gpointer user_data)
 {
         GsdAutomountManager *manager = user_data;
         GsdAutomountManagerPrivate *p = manager->priv;
+        GVariant *active_v = NULL;
+        gboolean is_active;
 
-        if (gnome_settings_session_get_state (session) == GNOME_SETTINGS_SESSION_STATE_ACTIVE) {
-                p->session_is_active = TRUE;
-        }
-        else {
-                p->session_is_active = FALSE;
-        }
+        active_v = g_dbus_proxy_get_cached_property (session, "SessionIsActive");
+        if (!active_v)
+                return;
+
+        g_variant_get (active_v, "b", &is_active);
+        g_variant_unref (active_v);
+        g_printerr ("AUTOMOUNT: session is active: %d -> %d\n", p->session_is_active, is_active);
+        p->session_is_active = is_active;
 
         if (!p->session_is_active) {
                 if (p->volume_queue != NULL) {
@@ -311,10 +315,10 @@ session_state_changed (GnomeSettingsSession *session, GParamSpec *pspec, gpointe
 static void
 do_initialize_session (GsdAutomountManager *manager)
 {
-        manager->priv->session = gnome_settings_session_new ();
-        g_signal_connect (manager->priv->session, "notify::state",
-                          G_CALLBACK (session_state_changed), manager);
-        session_state_changed (manager->priv->session, NULL, manager);
+        manager->priv->session = gnome_settings_session_get_session_proxy ();
+        g_signal_connect (manager->priv->session, "g-properties-changed",
+                          G_CALLBACK (session_props_changed), manager);
+        session_props_changed (manager->priv->session, NULL, NULL, manager);
 }
 
 #define SCREENSAVER_NAME "org.gnome.ScreenSaver"
--
cgit v0.9.1