aboutsummaryrefslogtreecommitdiff
path: root/src/datetime-service.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-04-14 11:25:47 -0500
committerTed Gould <ted@gould.cx>2011-04-14 11:25:47 -0500
commit9c71fd0788fba39dd4864107363492f758465aca (patch)
tree2e551424cedbae7dad9a970d5b9c602f947271bb /src/datetime-service.c
parent8603d94b5950329aeb81bcf255fe7f4173eaf6c3 (diff)
parent0ecb2dd406a7981d197f57b33934b02fbf034b3d (diff)
downloadayatana-indicator-datetime-9c71fd0788fba39dd4864107363492f758465aca.tar.gz
ayatana-indicator-datetime-9c71fd0788fba39dd4864107363492f758465aca.tar.bz2
ayatana-indicator-datetime-9c71fd0788fba39dd4864107363492f758465aca.zip
Check for resume in the service and update the label as well
Diffstat (limited to 'src/datetime-service.c')
-rw-r--r--src/datetime-service.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c
index 08b352a..08ff9ad 100644
--- a/src/datetime-service.c
+++ b/src/datetime-service.c
@@ -1199,6 +1199,40 @@ setup_timer (void)
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 @@ main (int argc, char ** argv)
/* 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);