diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-01-15 23:53:45 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-01-16 14:14:10 -0500 |
commit | a2bce67d3b09e03dffef7d69e333fe140cc3e73b (patch) | |
tree | 433d4e5a89d32105d8f5385b00be41161d0b2a05 /tests/testtreeedit.c | |
parent | 64c3db931d74d74c563405c204915581ef120a03 (diff) | |
download | gtk+-a2bce67d3b09e03dffef7d69e333fe140cc3e73b.tar.gz |
tests: Stop using ::button-press-event
A gesture will do here.
Diffstat (limited to 'tests/testtreeedit.c')
-rw-r--r-- | tests/testtreeedit.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/testtreeedit.c b/tests/testtreeedit.c index 65329136db..ce5a872c2e 100644 --- a/tests/testtreeedit.c +++ b/tests/testtreeedit.c @@ -133,19 +133,16 @@ edited (GtkCellRendererText *cell, gtk_tree_path_free (path); } -static gboolean -button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer callback_data) +static void +pressed_cb (GtkGesture *gesture, + int n_press, + double x, + double y, + GtkWidget *widget) { - double x, y; - - gdk_event_get_coords ((GdkEvent *)event, &x, &y); - /* Deselect if people click outside any row. */ - if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, NULL, NULL, NULL, NULL)) { - gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget))); - } - - /* Let the default code run in any case; it won't reselect anything. */ - return FALSE; + /* Deselect if people click outside any row. */ + if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, NULL, NULL, NULL, NULL)) + gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget))); } typedef struct { @@ -230,7 +227,8 @@ main (gint argc, gchar **argv) GtkTreeViewColumn *column; GtkCellArea *area; CallbackData callback[4]; - + GtkGesture *gesture; + gtk_init (); if (g_getenv ("RTL")) @@ -253,7 +251,9 @@ main (gint argc, gchar **argv) tree_model = create_model (); tree_view = gtk_tree_view_new_with_model (tree_model); - g_signal_connect (tree_view, "button_press_event", G_CALLBACK (button_press_event), NULL); + gesture = gtk_gesture_multi_press_new (tree_view); + g_signal_connect (gesture, "pressed", G_CALLBACK (pressed_cb), tree_view); + g_object_set_data_full (G_OBJECT (tree_view), "gesture", gesture, g_object_unref); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), TRUE); column = gtk_tree_view_column_new (); |