[libwnck] tests: Add a small utility to make it easy to test urgency hints
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck] tests: Add a small utility to make it easy to test urgency hints
- Date: Wed, 6 Oct 2010 13:13:35 +0000 (UTC)
commit 59dd136ebe15fb349518dd774882fb7bc5020ddd
Author: Vincent Untz <vuntz gnome org>
Date: Wed Oct 6 15:09:41 2010 +0200
tests: Add a small utility to make it easy to test urgency hints
libwnck/Makefile.am | 5 ++-
libwnck/test-urgent.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 100 insertions(+), 1 deletions(-)
---
diff --git a/libwnck/Makefile.am b/libwnck/Makefile.am
index 3db97dd..636bb9b 100644
--- a/libwnck/Makefile.am
+++ b/libwnck/Makefile.am
@@ -6,7 +6,8 @@ noinst_PROGRAMS = \
test-pager \
test-wnck \
test-selector \
- test-tasklist
+ test-tasklist \
+ test-urgent
AM_CPPFLAGS = \
$(LIBWNCK_CFLAGS) \
@@ -95,6 +96,7 @@ test_wnck_SOURCES = test-wnck.c
test_tasklist_SOURCES = test-tasklist.c
test_selector_SOURCES = test-selector.c
test_pager_SOURCES = test-pager.c
+test_urgent_SOURCES = test-urgent.c
wnckprop_LDADD = $(LIBWNCK_LIBS) ./$(lib_LTLIBRARIES)
wnck_urgency_monitor_LDADD = $(LIBWNCK_LIBS) ./$(lib_LTLIBRARIES)
@@ -102,6 +104,7 @@ test_wnck_LDADD = $(LIBWNCK_LIBS) ./$(lib_LTLIBRARIES)
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)
wnck-marshal.h: wnck-marshal.list
$(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=_wnck_marshal $< --header > $@
diff --git a/libwnck/test-urgent.c b/libwnck/test-urgent.c
new file mode 100644
index 0000000..37000b6
--- /dev/null
+++ b/libwnck/test-urgent.c
@@ -0,0 +1,96 @@
+/* vim: set sw=2 et: */
+
+#include <gtk/gtk.h>
+
+static void
+set_urgent (GtkWidget *window,
+ gboolean urgent)
+{
+ GtkWidget *label;
+
+ label = gtk_bin_get_child (GTK_BIN (window));
+
+ if (urgent)
+ {
+ gtk_window_set_urgency_hint (GTK_WINDOW (window), TRUE);
+ gtk_window_set_title (GTK_WINDOW (window), "Test Window - Urgent");
+ gtk_label_set_text (GTK_LABEL (label), "I am urgent!");
+ }
+ else
+ {
+ gtk_window_set_urgency_hint (GTK_WINDOW (window), FALSE);
+ gtk_window_set_title (GTK_WINDOW (window), "Test Window");
+ gtk_label_set_text (GTK_LABEL (label), "I'm not urgent.");
+ }
+}
+
+static gboolean
+make_urgent (GtkWidget *widget)
+{
+ set_urgent (widget, TRUE);
+ g_object_set_data (G_OBJECT (widget), "wnck-timeout", NULL);
+
+ return FALSE;
+}
+
+static gboolean
+focused_in (GtkWidget *widget,
+ GdkEventFocus *event,
+ gpointer user_data)
+{
+ guint id;
+
+ set_urgent (widget, FALSE);
+
+ id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "wnck-timeout"));
+ g_object_set_data (G_OBJECT (widget), "wnck-timeout", NULL);
+
+ if (id)
+ g_source_remove (id);
+
+ return FALSE;
+}
+
+static gboolean
+focused_out (GtkWidget *widget,
+ GdkEventFocus *event,
+ gpointer user_data)
+{
+ guint id;
+
+ id = g_timeout_add_seconds (3, (GSourceFunc) make_urgent, widget);
+ g_object_set_data (G_OBJECT (widget), "wnck-timeout", GUINT_TO_POINTER (id));
+
+ return FALSE;
+}
+
+int
+main (int argc, char **argv)
+{
+ GtkWidget *win;
+ GtkWidget *label;
+
+ gtk_init (&argc, &argv);
+
+ win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ label = gtk_label_new ("");
+ gtk_container_add (GTK_CONTAINER (win), label);
+ gtk_window_set_keep_above (GTK_WINDOW (win), TRUE);
+ gtk_widget_show_all (win);
+
+ g_signal_connect (G_OBJECT (win), "focus-in-event",
+ G_CALLBACK (focused_in),
+ NULL);
+ g_signal_connect (G_OBJECT (win), "focus-out-event",
+ G_CALLBACK (focused_out),
+ NULL);
+ g_signal_connect (G_OBJECT (win), "destroy",
+ G_CALLBACK (gtk_main_quit),
+ NULL);
+
+ set_urgent (win, FALSE);
+
+ gtk_main ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]