Blame libgnome-desktop/test-idle-monitor.c

rpm-build 18b009
#include <gtk/gtk.h>
rpm-build 18b009
#define GNOME_DESKTOP_USE_UNSTABLE_API
rpm-build 18b009
#include "libgnome-desktop/gnome-idle-monitor.h"
rpm-build 18b009
rpm-build 18b009
#define IDLE_TIME 1000 * 5 /* 5 seconds */
rpm-build 18b009
rpm-build 18b009
static void
rpm-build 18b009
active_watch_func (GnomeIdleMonitor *monitor,
rpm-build 18b009
		   guint             id,
rpm-build 18b009
		   gpointer          user_data)
rpm-build 18b009
{
rpm-build 18b009
	g_message ("Active watch func called (watch id %d)", id);
rpm-build 18b009
}
rpm-build 18b009
rpm-build 18b009
static void
rpm-build 18b009
ensure_active_watch (GnomeIdleMonitor *monitor)
rpm-build 18b009
{
rpm-build 18b009
	guint watch_id;
rpm-build 18b009
rpm-build 18b009
	watch_id = gnome_idle_monitor_add_user_active_watch (monitor,
rpm-build 18b009
							     active_watch_func,
rpm-build 18b009
							     NULL,
rpm-build 18b009
							     NULL);
rpm-build 18b009
	g_message ("Added active watch ID %d", watch_id);
rpm-build 18b009
}
rpm-build 18b009
rpm-build 18b009
static void
rpm-build 18b009
idle_watch_func (GnomeIdleMonitor      *monitor,
rpm-build 18b009
		 guint                  id,
rpm-build 18b009
		 gpointer               user_data)
rpm-build 18b009
{
rpm-build 18b009
	g_message ("Idle watch func called (watch id %d)", id);
rpm-build 18b009
	ensure_active_watch (monitor);
rpm-build 18b009
}
rpm-build 18b009
rpm-build 18b009
int main (int argc, char **argv)
rpm-build 18b009
{
rpm-build 18b009
	GnomeIdleMonitor *monitor;
rpm-build 18b009
	guint watch_id;
rpm-build 18b009
rpm-build 18b009
	gtk_init (&argc, &argv);
rpm-build 18b009
rpm-build 18b009
	monitor = gnome_idle_monitor_new ();
rpm-build 18b009
	watch_id = gnome_idle_monitor_add_idle_watch (monitor,
rpm-build 18b009
						      IDLE_TIME,
rpm-build 18b009
						      idle_watch_func,
rpm-build 18b009
						      NULL,
rpm-build 18b009
						      NULL);
rpm-build 18b009
	g_message ("Added idle watch ID %d",
rpm-build 18b009
		   watch_id);
rpm-build 18b009
rpm-build 18b009
	ensure_active_watch (monitor);
rpm-build 18b009
rpm-build 18b009
	gtk_main ();
rpm-build 18b009
rpm-build 18b009
	return 0;
rpm-build 18b009
}