summaryrefslogtreecommitdiff
path: root/plugins/color/gsd-color-manager.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2012-11-06 17:47:05 -0500
committerColin Walters <walters@verbum.org>2012-11-06 21:05:03 -0500
commit32b0b2d85629ae765543df1d940a5ca3c37dcec1 (patch)
tree8445fb219a417458ade23b9ad71d2946e553afea /plugins/color/gsd-color-manager.c
parent882d41ae99ed71e7cff1b9dffde44c7111d8d893 (diff)
downloadgnome-settings-daemon-wip/gnome-session-isactive.tar.gz
[wip] Port to gnome-session's SessionIsActive propertywip/gnome-session-isactive
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.
Diffstat (limited to 'plugins/color/gsd-color-manager.c')
-rw-r--r--plugins/color/gsd-color-manager.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/plugins/color/gsd-color-manager.c b/plugins/color/gsd-color-manager.c
index 999b88c4..df6d32ef 100644
--- a/plugins/color/gsd-color-manager.c
+++ b/plugins/color/gsd-color-manager.c
@@ -47,7 +47,7 @@
struct GsdColorManagerPrivate
{
- GnomeSettingsSession *session;
+ GDBusProxy *session;
CdClient *client;
GSettings *settings;
GcmProfileStore *profile_store;
@@ -55,7 +55,7 @@ struct GsdColorManagerPrivate
GnomeRRScreen *x11_screen;
GHashTable *edid_cache;
GdkWindow *gdk_window;
- GnomeSettingsSessionState session_state;
+ gboolean session_is_active;
GHashTable *device_assign_hash;
};
@@ -2213,17 +2213,26 @@ gcm_session_sensor_removed_cb (CdClient *client,
}
static void
-gcm_session_active_changed_cb (GnomeSettingsSession *session,
- GParamSpec *pspec,
+gcm_session_active_changed_cb (GDBusProxy *session,
+ GVariant *changed,
+ char **invalidated,
GsdColorManager *manager)
{
- GnomeSettingsSessionState state_new;
GsdColorManagerPrivate *priv = manager->priv;
+ GVariant *active_v = NULL;
+ gboolean is_active;
/* not yet connected to the daemon */
if (!cd_client_get_connected (priv->client))
return;
+ 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);
+
/* When doing the fast-user-switch into a new account, load the
* new users chosen profiles.
*
@@ -2231,15 +2240,13 @@ gcm_session_active_changed_cb (GnomeSettingsSession *session,
* loaded, then we'll get a change from unknown to active
* and we want to avoid reprobing the devices for that.
*/
- state_new = gnome_settings_session_get_state (session);
- if (priv->session_state != GNOME_SETTINGS_SESSION_STATE_UNKNOWN &&
- state_new == GNOME_SETTINGS_SESSION_STATE_ACTIVE) {
+ if (is_active && !priv->session_is_active) {
g_warning ("Done switch to new account, reload devices");
cd_client_get_devices (manager->priv->client, NULL,
gcm_session_get_devices_cb,
manager);
}
- priv->session_state = state_new;
+ priv->session_is_active = is_active;
}
static void
@@ -2259,11 +2266,9 @@ gsd_color_manager_init (GsdColorManager *manager)
priv = manager->priv = GSD_COLOR_MANAGER_GET_PRIVATE (manager);
/* track the active session */
- priv->session = gnome_settings_session_new ();
- priv->session_state = gnome_settings_session_get_state (priv->session);
- g_signal_connect (priv->session, "notify::state",
- G_CALLBACK (gcm_session_active_changed_cb),
- manager);
+ priv->session = gnome_settings_session_get_session_proxy ();
+ g_signal_connect (priv->session, "g-properties-changed",
+ G_CALLBACK (gcm_session_active_changed_cb), manager);
/* set the _ICC_PROFILE atoms on the root screen */
priv->gdk_window = gdk_screen_get_root_window (gdk_screen_get_default ());