summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <vuntz@gnome.org>2012-01-30 14:10:35 +0100
committerVincent Untz <vuntz@gnome.org>2012-01-30 15:05:41 +0100
commit0e17e7b82ff81d678dee17ad44f472672fb41327 (patch)
tree9d8e040b4f24d6ca0343ff08901f0150d593293c
parent040a3b358840a8ef32f9f64792bb41a5327cd81c (diff)
downloadlibwnck-0e17e7b82ff81d678dee17ad44f472672fb41327.tar.gz
tests: Add test-shutdown tool
It's just a small binary to test wnck_shutdown().
-rw-r--r--libwnck/Makefile.am5
-rw-r--r--libwnck/test-shutdown.c61
2 files changed, 65 insertions, 1 deletions
diff --git a/libwnck/Makefile.am b/libwnck/Makefile.am
index d220ba2..2bdc47a 100644
--- a/libwnck/Makefile.am
+++ b/libwnck/Makefile.am
@@ -7,7 +7,8 @@ noinst_PROGRAMS = \
test-wnck \
test-selector \
test-tasklist \
- test-urgent
+ test-urgent \
+ test-shutdown
AM_CPPFLAGS = \
$(LIBWNCK_CFLAGS) \
@@ -101,6 +102,7 @@ test_tasklist_SOURCES = test-tasklist.c
test_selector_SOURCES = test-selector.c
test_pager_SOURCES = test-pager.c
test_urgent_SOURCES = test-urgent.c
+test_shutdown_SOURCES = test-shutdown.c
wnckprop_LDADD = $(LIBWNCK_LIBS) $(XLIB_LIBS) ./$(lib_LTLIBRARIES)
wnck_urgency_monitor_LDADD = $(LIBWNCK_LIBS) ./$(lib_LTLIBRARIES)
@@ -109,6 +111,7 @@ test_tasklist_LDADD = $(LIBWNCK_LIBS) ./$(lib_LTLIBRARIES)
test_selector_LDADD = $(LIBWNCK_LIBS) ./$(lib_LTLIBRARIES)
test_pager_LDADD = $(LIBWNCK_LIBS) ./$(lib_LTLIBRARIES)
test_urgent_LDADD = $(LIBWNCK_LIBS)
+test_shutdown_LDADD = $(LIBWNCK_LIBS) ./$(lib_LTLIBRARIES)
wnck-marshal.h: wnck-marshal.list
$(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=_wnck_marshal $< --header > $@
diff --git a/libwnck/test-shutdown.c b/libwnck/test-shutdown.c
new file mode 100644
index 0000000..0f09d42
--- /dev/null
+++ b/libwnck/test-shutdown.c
@@ -0,0 +1,61 @@
+/* vim: set sw=2 et: */
+
+#include <libwnck/libwnck.h>
+
+static void
+on_active_window_changed (WnckScreen *screen,
+ WnckWindow *previously_active_window,
+ gpointer data)
+{
+ WnckWindow *active_window;
+
+ active_window = wnck_screen_get_active_window (screen);
+
+ if (active_window)
+ g_print ("active: %s\n", wnck_window_get_name (active_window));
+ else
+ g_print ("no active window\n");
+}
+
+static gboolean
+quit_loop (gpointer data)
+{
+ GMainLoop *loop = data;
+ g_main_loop_quit (loop);
+
+ return FALSE;
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ GMainLoop *loop;
+ WnckScreen *screen;
+
+ gdk_init (&argc, &argv);
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ while (TRUE)
+ {
+ screen = wnck_screen_get_default ();
+
+ g_print ("libwnck is active for 5 seconds; change the active window to get notifications\n");
+ g_signal_connect (screen, "active-window-changed",
+ G_CALLBACK (on_active_window_changed), NULL);
+ g_timeout_add_seconds (5, quit_loop, loop);
+ g_main_loop_run (loop);
+
+ g_print ("libwnck is shutting down for 5 seconds; no notification will happen anymore\n");
+ wnck_shutdown ();
+ g_timeout_add_seconds (5, quit_loop, loop);
+ g_main_loop_run (loop);
+
+ g_print ("libwnck is getting reinitialized...\n");
+ }
+
+ g_main_loop_unref (loop);
+
+ return 0;
+}