[gnome-settings-daemon] color: Don't check SessionIsActive if it didn't change



commit eb488d7c35c120215f188b09057c86b2ff85b114
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Nov 12 10:22:04 2012 +0100

    color: Don't check SessionIsActive if it didn't change

 plugins/color/gsd-color-manager.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/plugins/color/gsd-color-manager.c b/plugins/color/gsd-color-manager.c
index 9545cc7..ae4fcc3 100644
--- a/plugins/color/gsd-color-manager.c
+++ b/plugins/color/gsd-color-manager.c
@@ -2212,6 +2212,18 @@ gcm_session_sensor_removed_cb (CdClient *client,
                          CA_PROP_EVENT_DESCRIPTION, _("Color calibration device removed"), NULL);
 }
 
+static gboolean
+has_changed (char       **strv,
+	     const char  *str)
+{
+        guint i;
+        for (i = 0; strv[i] != NULL; i++) {
+                if (g_str_equal (str, strv[i]))
+                        return TRUE;
+        }
+        return FALSE;
+}
+
 static void
 gcm_session_active_changed_cb (GDBusProxy      *session,
                                GVariant        *changed,
@@ -2222,14 +2234,15 @@ gcm_session_active_changed_cb (GDBusProxy      *session,
         GVariant *active_v = NULL;
         gboolean is_active;
 
+        if (has_changed (invalidated, "SessionIsActive"))
+                return;
+
         /* 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_return_if_fail (active_v != NULL);
         is_active = g_variant_get_boolean (active_v);
         g_variant_unref (active_v);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]