summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2009-08-31 13:51:48 +1000
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2009-11-18 12:18:29 +1100
commit73374dae39eaa3bbd5f0c4e6dce6eefb45923ade (patch)
treeda2d2ce9b568a030009ae8b1d4d6317b796fe086 /examples
parentdba0f0d4d04ff1061dad016dfc78da46b5715460 (diff)
downloadclutter-gtk-73374dae39eaa3bbd5f0c4e6dce6eefb45923ade.tar.gz
Testcase for tracking expose events
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am5
-rw-r--r--examples/expose-test.c68
2 files changed, 73 insertions, 0 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index bf56a46..5302066 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -4,6 +4,7 @@ NULL =
noinst_PROGRAMS = \
animated-notebook \
+ expose-test \
gtk-clutter-events \
gtk-clutter-multistage \
gtk-clutter-standin-test \
@@ -31,6 +32,10 @@ animated_notebook_SOURCES = animated-notebook.c
animated_notebook_DEPENDENCIES = $(common_deps)
animated_notebook_LDADD = $(common_ldadd)
+expose_test_SOURCES = expose-test.c
+expose_test_DEPENDENCIES = $(common_deps)
+expose_test_LDADD = $(common_ldadd)
+
gtk_clutter_test_SOURCES = gtk-clutter-test.c
gtk_clutter_test_DEPENDENCIES = $(common_deps)
gtk_clutter_test_LDADD = $(common_ldadd)
diff --git a/examples/expose-test.c b/examples/expose-test.c
new file mode 100644
index 0000000..b5650d4
--- /dev/null
+++ b/examples/expose-test.c
@@ -0,0 +1,68 @@
+/* Clutter-Gtk Window Test
+ *
+ * (c) 2009, Collabora Ltd.
+ *
+ * Written by Davyd Madeley <davyd.madeley@collabora.co.uk>
+ */
+
+#include <gtk/gtk.h>
+#include <clutter/clutter.h>
+#include <clutter-gtk/clutter-gtk.h>
+
+static void
+button_clicked (GtkButton *button, char *stock_id)
+{
+ g_print ("button clicked: %s\n", stock_id);
+}
+
+static gboolean
+expose_monitor (GtkWidget *widget, GdkEventExpose *event, char *str)
+{
+ g_print ("expose (%s) - (%i, %i, %i, %i)\n",
+ str,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height);
+
+ return FALSE;
+}
+
+static GtkWidget *
+add_button (GtkTable *table, char *stock_id, int row)
+{
+ GtkWidget *button = gtk_button_new_from_stock (stock_id);
+ gtk_table_attach_defaults (GTK_TABLE (table), button,
+ row, row + 1, row, row + 1);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (button_clicked), stock_id);
+
+ g_signal_connect (button, "expose-event",
+ G_CALLBACK (expose_monitor), stock_id);
+
+ return button;
+}
+
+int
+main (int argc, char **argv)
+{
+ gtk_clutter_init (&argc, &argv);
+
+ GtkWidget *window = gtk_clutter_window_new ();
+ GtkWidget *table = gtk_table_new (6, 6, TRUE);
+
+ add_button (GTK_TABLE (table), GTK_STOCK_OK, 0);
+ add_button (GTK_TABLE (table), GTK_STOCK_CANCEL, 1);
+ add_button (GTK_TABLE (table), GTK_STOCK_CLOSE, 2);
+ add_button (GTK_TABLE (table), GTK_STOCK_ABOUT, 3);
+ add_button (GTK_TABLE (table), GTK_STOCK_BOLD, 4);
+ add_button (GTK_TABLE (table), GTK_STOCK_ITALIC, 5);
+
+ g_signal_connect (window, "expose-event",
+ G_CALLBACK (expose_monitor), "window");
+ g_signal_connect (table, "expose-event",
+ G_CALLBACK (expose_monitor), "table");
+
+ gtk_container_add (GTK_CONTAINER (window), table);
+ gtk_widget_show_all (window);
+ gtk_main ();
+}