gtk+ r21749 - in trunk: . tests
- From: tml svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r21749 - in trunk: . tests
- Date: Sat, 1 Nov 2008 11:57:42 +0000 (UTC)
Author: tml
Date: Sat Nov 1 11:57:42 2008
New Revision: 21749
URL: http://svn.gnome.org/viewvc/gtk+?rev=21749&view=rev
Log:
2008-11-01 Tor Lillqvist <tml novell com>
* tests/testclientmessage.c: New interactive test program to
verify client message functionality.
* tests/Makefile.am: Add it.
Added:
trunk/tests/testclientmessage.c
Modified:
trunk/ChangeLog
trunk/tests/Makefile.am
Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am (original)
+++ trunk/tests/Makefile.am Sat Nov 1 11:57:42 2008
@@ -35,6 +35,7 @@
testcombo \
testcombochange \
testcellrenderertext \
+ testclientmessage \
testdnd \
testellipsise \
testentrycompletion \
@@ -113,6 +114,7 @@
testcombo_DEPENDENCIES = $(TEST_DEPS)
testcombochange_DEPENDENCIES = $(TEST_DEPS)
testcellrenderertext_DEPENDENCIES = $(TEST_DEPS)
+testclientmessage_DEPENDENCIES = $(TEST_DEPS)
testdnd_DEPENDENCIES = $(TEST_DEPS)
testellipsise_DEPENDENCIES = $(TEST_DEPS)
testentrycompletion_DEPENDENCIES = $(TEST_DEPS)
@@ -166,6 +168,7 @@
testcombo_LDADD = $(LDADDS)
testcombochange_LDADD = $(LDADDS)
testcellrenderertext_LDADD = $(LDADDS)
+testclientmessage_LDADD = $(LDADDS)
testdnd_LDADD = $(LDADDS)
testellipsise_LDADD = $(LDADDS)
testentrycompletion_LDADD = $(LDADDS)
Added: trunk/tests/testclientmessage.c
==============================================================================
--- (empty file)
+++ trunk/tests/testclientmessage.c Sat Nov 1 11:57:42 2008
@@ -0,0 +1,122 @@
+/* testclientmessage.c
+ * Copyright (C) 2008 Novell, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+static GdkAtom my_type;
+static GdkAtom random_type;
+
+static void
+send_known (void)
+{
+ GdkEvent *event = gdk_event_new (GDK_CLIENT_EVENT);
+ static int counter = 42;
+ int i;
+
+ event->client.window = NULL;
+ event->client.message_type = my_type;
+ event->client.data_format = 32;
+ event->client.data.l[0] = counter++;
+ for (i = 1; i < 5; i++)
+ event->client.data.l[i] = 0;
+
+ gdk_screen_broadcast_client_message (gdk_display_get_default_screen (gdk_display_get_default ()), event);
+
+ gdk_event_free (event);
+}
+
+void
+send_random (void)
+{
+ GdkEvent *event = gdk_event_new (GDK_CLIENT_EVENT);
+ static int counter = 1;
+ int i;
+
+ event->client.window = NULL;
+ event->client.message_type = random_type;
+ event->client.data_format = 32;
+ event->client.data.l[0] = counter++;
+ for (i = 1; i < 5; i++)
+ event->client.data.l[i] = 0;
+
+ gdk_screen_broadcast_client_message (gdk_display_get_default_screen (gdk_display_get_default ()), event);
+
+ gdk_event_free (event);
+}
+
+static GdkFilterReturn
+filter_func (GdkXEvent *xevent,
+ GdkEvent *event,
+ gpointer data)
+{
+ g_print ("Got matching client message!\n");
+ return GDK_FILTER_REMOVE;
+}
+
+int
+main (int argc, char **argv)
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ GtkWidget *button;
+
+ gtk_init (&argc, &argv);
+
+ my_type = gdk_atom_intern ("GtkTestClientMessage", FALSE);
+ random_type = gdk_atom_intern (g_strdup_printf ("GtkTestClientMessage-%d",
+ g_rand_int_range (g_rand_new (), 1, 99)),
+ FALSE);
+
+ g_print ("using client message type %s\n", gdk_atom_name (my_type));
+
+ window = g_object_connect (g_object_new (gtk_window_get_type (),
+ "type", GTK_WINDOW_TOPLEVEL,
+ "title", "testclientmessage",
+ "border_width", 10,
+ NULL),
+ "signal::destroy", gtk_main_quit, NULL,
+ NULL);
+ vbox = g_object_new (gtk_vbox_get_type (),
+ "GtkWidget::parent", window,
+ "GtkWidget::visible", TRUE,
+ NULL);
+ button = g_object_connect (g_object_new (gtk_button_get_type (),
+ "GtkButton::label", "send known client message",
+ "GtkWidget::parent", vbox,
+ "GtkWidget::visible", TRUE,
+ NULL),
+ "signal::clicked", send_known, NULL,
+ NULL);
+ button = g_object_connect (g_object_new (gtk_button_get_type (),
+ "GtkButton::label", "send random client message",
+ "GtkWidget::parent", vbox,
+ "GtkWidget::visible", TRUE,
+ NULL),
+ "signal::clicked", send_random, NULL,
+ NULL);
+ gdk_display_add_client_message_filter (gdk_display_get_default (),
+ my_type,
+ filter_func,
+ NULL);
+ gtk_widget_show (window);
+
+ gtk_main ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]