[libwnck] tests: Add test-shutdown tool
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck] tests: Add test-shutdown tool
- Date: Mon, 30 Jan 2012 14:05:58 +0000 (UTC)
commit 0e17e7b82ff81d678dee17ad44f472672fb41327
Author: Vincent Untz <vuntz gnome org>
Date: Mon Jan 30 14:10:35 2012 +0100
tests: Add test-shutdown tool
It's just a small binary to test wnck_shutdown().
libwnck/Makefile.am | 5 +++-
libwnck/test-shutdown.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
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;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]