← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~mterry/indicator-datetime/update-after-resume into lp:indicator-datetime

 

Michael Terry has proposed merging lp:~mterry/indicator-datetime/update-after-resume into lp:indicator-datetime.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)
Related bugs:
  Bug #759854 in Indicator Date and Time: "Today's date doesn't change"
  https://bugs.launchpad.net/indicator-datetime/+bug/759854

For more details, see:
https://code.launchpad.net/~mterry/indicator-datetime/update-after-resume/+merge/57574
-- 
https://code.launchpad.net/~mterry/indicator-datetime/update-after-resume/+merge/57574
Your team ayatana-commits is subscribed to branch lp:indicator-datetime.
=== modified file 'src/datetime-service.c'
--- src/datetime-service.c	2011-04-13 03:18:26 +0000
+++ src/datetime-service.c	2011-04-13 19:34:25 +0000
@@ -1199,6 +1199,40 @@
 	return;
 }
 
+static void
+session_active_change_cb (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,
+                          GVariant * parameters, gpointer user_data)
+{
+	// Just returned from suspend
+	if (g_strcmp0(signal_name, "SystemIdleHintChanged") == 0) {
+		gboolean idle = FALSE;
+		g_variant_get(parameters, "(b)", &idle);
+		if (!idle) {
+			datetime_interface_update(DATETIME_INTERFACE(user_data));
+			update_datetime(NULL);
+			setup_timer();
+		}
+	}
+	return;
+}
+
+/* for hooking into console kit signal on wake from suspend */
+static void
+system_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
+{
+	GError * error = NULL;
+	
+	GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
+
+	if (error != NULL) {
+		g_warning("Could not grab DBus proxy for ConsoleKit: %s", error->message);
+		g_error_free(error);
+		return;
+	}
+
+	g_signal_connect(proxy, "g-signal", G_CALLBACK(session_active_change_cb), user_data);
+}
+
 /* Callback from getting the address */
 static void
 geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, GeoclueAccuracy * accuracy, GError * error, gpointer user_data)
@@ -1433,6 +1467,15 @@
 	/* Setup the timer */
 	setup_timer();
 
+	/* And watch for system resumes */
+	g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
+		                  G_DBUS_PROXY_FLAGS_NONE,
+		                  NULL,
+		                  "org.freedesktop.ConsoleKit",
+		                  "/org/freedesktop/ConsoleKit/Manager",
+		                  "org.freedesktop.ConsoleKit.Manager",
+		                  NULL, system_proxy_cb, dbus);
+
 	mainloop = g_main_loop_new(NULL, FALSE);
 	g_main_loop_run(mainloop);
 

=== modified file 'src/indicator-datetime.c'
--- src/indicator-datetime.c	2011-04-11 14:15:16 +0000
+++ src/indicator-datetime.c	2011-04-13 19:34:25 +0000
@@ -171,9 +171,7 @@
 static void guess_label_size              (IndicatorDatetime * self);
 static void setup_timer                   (IndicatorDatetime * self, GDateTime * datetime);
 static void update_time                   (IndicatorDatetime * self);
-static void session_active_change_cb      (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);
 static void receive_signal                (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);
-static void system_proxy_cb  (GObject * object, GAsyncResult * res, gpointer user_data);
 static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
 static gint generate_strftime_bitmask     (const char *time_str);
 static void timezone_update_labels        (indicator_item_t * mi_data);
@@ -396,34 +394,8 @@
 		                  service_proxy_cb,
                                   self);
 
-	g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
-		                  G_DBUS_PROXY_FLAGS_NONE,
-		                  NULL,
-		                  "org.freedesktop.ConsoleKit",
-		                  "/org/freedesktop/ConsoleKit/Manager",
-		                  "org.freedesktop.ConsoleKit.Manager",
-		                  NULL, system_proxy_cb, self);
 	return;
 }
-/* for hooking into console kit signal on wake from suspend */
-static void
-system_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
-{
-	GError * error = NULL;
-	
-	IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
-	g_return_if_fail(self != NULL);
-	
-	GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
-
-	if (error != NULL) {
-		g_warning("Could not grab DBus proxy for %s: %s", SERVICE_NAME, error->message);
-		g_error_free(error);
-		return;
-	}
-	g_signal_connect(proxy, "g-signal", G_CALLBACK(session_active_change_cb), self);
-
-}
 
 /* Callback from trying to create the proxy for the serivce, this
    could include starting the service.  Sometime it'll fail and
@@ -855,18 +827,6 @@
 	return;
 }
 
-static void
-session_active_change_cb (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,
-                GVariant * parameters, gpointer user_data)
-{
-	// Just returned from suspend
-	IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
-	if (g_strcmp0(signal_name, "SystemIdleHintChanged") == 0 && g_variant_get_boolean(parameters) == FALSE) {
-		update_time(self);
-	}
-	return;
-}
-
 /* Receives all signals from the service, routed to the appropriate functions */
 static void
 receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,


Follow ups