[gnome-screensaver] Update clock on resume



commit da2148e09ee162481a0ffbc106a37e81ff7af790
Author: Colin Walters <walters verbum org>
Date:   Fri Aug 12 10:37:17 2011 -0400

    Update clock on resume
    
    It's very confusing to the user if they unsuspend their laptop and see
    the wrong time.  Ideally, we would have it updated before we even
    unblank the screen, but this is much better than what we had before.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=656405

 configure.ac        |    1 +
 src/gs-window-x11.c |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 20d3115..b2716f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,6 +61,7 @@ PKG_CHECK_MODULES(GNOME_SCREENSAVER,
         gtk+-3.0 >= $GTK_REQUIRED_VERSION
         dbus-glib-1 >= $DBUS_REQUIRED_VERSION
         gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION
+	upower-glib >= 0.9.13
         gsettings-desktop-schemas >= $GSETTINGS_DESKTOP_SCHEMAS_REQUIRED_VERSION)
 AC_SUBST(GNOME_SCREENSAVER_CFLAGS)
 AC_SUBST(GNOME_SCREENSAVER_LIBS)
diff --git a/src/gs-window-x11.c b/src/gs-window-x11.c
index c96c9fa..2996e81 100644
--- a/src/gs-window-x11.c
+++ b/src/gs-window-x11.c
@@ -32,6 +32,8 @@
 #include <gtk/gtk.h>
 #include <gtk/gtkx.h>
 
+#include <upower.h>
+
 #include <gdesktop-enums.h>
 
 #include "gs-window.h"
@@ -103,6 +105,8 @@ struct GSWindowPrivate
         guint      clock_update_id;
 
         gint64     clock_update_time;
+        
+        UpClient  *upower_client;
 
         gint       lock_pid;
         gint       lock_watch_id;
@@ -2263,6 +2267,14 @@ queue_clock_update (GSWindow *window)
         }
 }
 
+static void
+on_upower_resume (UpClient    *client,
+                  UpSleepKind  kind,
+                  gpointer     user_data)
+{
+        update_clock (GS_WINDOW (user_data));
+}
+
 static char *
 get_user_display_name (void)
 {
@@ -2429,6 +2441,11 @@ gs_window_init (GSWindow *window)
         window->priv->clock_format = g_settings_get_enum (window->priv->clock_settings, "clock-format");
         g_signal_connect (window->priv->clock_settings, "changed::clock-format",
                           G_CALLBACK (update_clock_format), window);
+        
+        window->priv->upower_client = up_client_new ();
+        g_signal_connect (window->priv->upower_client, "notify-resume",
+                          G_CALLBACK (on_upower_resume), window);
+        
         update_clock (window);
         queue_clock_update (window);
 



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