[gtk+/wip/events: 19/19] tests: Update testgestures example for new widget APIs
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/events: 19/19] tests: Update testgestures example for new widget APIs
- Date: Tue, 13 Mar 2012 01:19:47 +0000 (UTC)
commit 6b23c1ec65b12d02a32ff2b2dee33749b6c63590
Author: Benjamin Otte <otte redhat com>
Date: Mon Mar 12 17:29:27 2012 +0100
tests: Update testgestures example for new widget APIs
We can now use gtk_widget_add_recognizer()
tests/testgestures.c | 33 ++++++++++++++-------------------
1 files changed, 14 insertions(+), 19 deletions(-)
---
diff --git a/tests/testgestures.c b/tests/testgestures.c
index 14eab24..839a9a7 100644
--- a/tests/testgestures.c
+++ b/tests/testgestures.c
@@ -203,47 +203,42 @@ int
main (int argc, char *argv[])
{
GtkEventRecognizer *recognizer;
- GtkWidgetClass *area_class;
GtkWidget *window, *area;
SwipeData swipe_data = { 0, };
PinchPanData pinch_pan_data = { { 0 }, };
gtk_init (&argc, &argv);
- area_class = g_type_class_ref (GTK_TYPE_DRAWING_AREA);
-
- cairo_matrix_init_identity (&pinch_pan_data.matrix);
- cairo_matrix_init_identity (&pinch_pan_data.pending);
- pinch_pan_data.pixbuf = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);
- g_assert (pinch_pan_data.pixbuf);
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+
+ area = gtk_drawing_area_new ();
+ gtk_widget_set_has_window (area, TRUE);
+ gtk_widget_set_size_request (area, 400, 300);
recognizer = gtk_swipe_recognizer_new ();
g_signal_connect (recognizer, "started", G_CALLBACK (update_swipe), &swipe_data);
g_signal_connect (recognizer, "updated", G_CALLBACK (update_swipe), &swipe_data);
g_signal_connect (recognizer, "finished", G_CALLBACK (finish_swipe), &swipe_data);
g_signal_connect (recognizer, "cancelled", G_CALLBACK (cancel_swipe), &swipe_data);
- /* This next line is a hack and you should never do it in real life.
- * Instead, do a subclass. Or get me to add gtk_widget_add_recognizer(). */
#if 0
- gtk_widget_class_add_recognizer (area_class, recognizer);
+ gtk_widget_add_recognizer (area, recognizer);
#endif
+
+ cairo_matrix_init_identity (&pinch_pan_data.matrix);
+ cairo_matrix_init_identity (&pinch_pan_data.pending);
+ pinch_pan_data.pixbuf = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);
+ g_assert (pinch_pan_data.pixbuf);
+
recognizer = gtk_pinch_pan_recognizer_new ();
g_signal_connect (recognizer, "started", G_CALLBACK (update_pinch_pan), &pinch_pan_data);
g_signal_connect (recognizer, "updated", G_CALLBACK (update_pinch_pan), &pinch_pan_data);
g_signal_connect (recognizer, "finished", G_CALLBACK (finish_pinch_pan), &pinch_pan_data);
g_signal_connect (recognizer, "cancelled", G_CALLBACK (cancel_pinch_pan), &pinch_pan_data);
- /* This next line is a hack and you should never do it in real life.
- * Instead, do a subclass. Or get me to add gtk_widget_add_recognizer(). */
#if 1
- gtk_widget_class_add_recognizer (area_class, recognizer);
+ gtk_widget_add_recognizer (area, recognizer);
#endif
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
-
- area = gtk_drawing_area_new ();
- gtk_widget_set_has_window (area, TRUE);
- gtk_widget_set_size_request (area, 400, 300);
g_signal_connect_after (area, "draw", G_CALLBACK (draw_swipe), &swipe_data);
g_signal_connect_after (area, "draw", G_CALLBACK (draw_pinch_pan), &pinch_pan_data);
gtk_container_add (GTK_CONTAINER (window), area);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]