[gnome-desktop] idle-monitor: Catch the state changing signals
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop] idle-monitor: Catch the state changing signals
- Date: Tue, 13 Nov 2012 10:04:53 +0000 (UTC)
commit 8b65ef0f8b44dea4a3237dea0362ba2546921e8d
Author: Bastien Nocera <hadess hadess net>
Date: Tue Nov 13 09:24:08 2012 +0100
idle-monitor: Catch the state changing signals
libgnome-desktop/test-idle-monitor.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/libgnome-desktop/test-idle-monitor.c b/libgnome-desktop/test-idle-monitor.c
index d758d7e..6fdf424 100644
--- a/libgnome-desktop/test-idle-monitor.c
+++ b/libgnome-desktop/test-idle-monitor.c
@@ -25,6 +25,35 @@ watch_func (GnomeIdleMonitor *monitor,
}
static void
+became_active_cb (GnomeIdleMonitor *monitor,
+ gpointer user_data)
+{
+ GdkDevice *device;
+ int device_id;
+
+ g_object_get (monitor, "device", &device, NULL);
+ device_id = gdk_x11_device_get_id (device);
+ g_message ("Device '%s' (%d) became active",
+ gdk_device_get_name (device), device_id);
+ g_object_unref (device);
+}
+
+static void
+triggered_idle_cb (GnomeIdleMonitor *monitor,
+ guint watch_id,
+ gpointer user_data)
+{
+ GdkDevice *device;
+ int device_id;
+
+ g_object_get (monitor, "device", &device, NULL);
+ device_id = gdk_x11_device_get_id (device);
+ g_message ("Device '%s' (%d) triggered idle on watch %d",
+ gdk_device_get_name (device), device_id, watch_id);
+ g_object_unref (device);
+}
+
+static void
device_added_cb (GdkDeviceManager *manager,
GdkDevice *device,
gpointer user_data)
@@ -35,6 +64,10 @@ device_added_cb (GdkDeviceManager *manager,
device_id = gdk_x11_device_get_id (device);
monitor = gnome_idle_monitor_new_for_device (device);
+ g_signal_connect (G_OBJECT (monitor), "became-active",
+ G_CALLBACK (became_active_cb), NULL);
+ g_signal_connect (G_OBJECT (monitor), "triggered-idle",
+ G_CALLBACK (triggered_idle_cb), NULL);
watch_id = gnome_idle_monitor_add_watch (monitor,
IDLE_TIME,
watch_func,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]