diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-01-06 12:29:29 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-01-16 14:14:10 -0500 |
commit | 6d1dbec9dd457a33b0fadfb425d4c368fab4caba (patch) | |
tree | 7109645cf477e5bd80afb1ade28f18c55499aabf | |
parent | e3e00a2673541bc4dcedd5a21bf5bab44ed3a7e5 (diff) | |
download | gtk+-6d1dbec9dd457a33b0fadfb425d4c368fab4caba.tar.gz |
tests: Stop using ::focus-in/out-event
The has-focus property works just as well here.
-rw-r--r-- | tests/testiconview-keynav.c | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/tests/testiconview-keynav.c b/tests/testiconview-keynav.c index 4fb3272477..69a9b95869 100644 --- a/tests/testiconview-keynav.c +++ b/tests/testiconview-keynav.c @@ -178,33 +178,28 @@ keynav_failed (GtkWidget *view, return FALSE; } -static gboolean -focus_out (GtkWidget *view, - GdkEventFocus *event, - gpointer data) +static void +focus_changed (GtkWidget *view, + GParamSpec *pspec, + gpointer data) { - gtk_icon_view_unselect_all (GTK_ICON_VIEW (view)); - - return FALSE; -} + if (gtk_widget_has_focus (view)) + { + GtkTreePath *path; -static gboolean -focus_in (GtkWidget *view, - GdkEventFocus *event, - gpointer data) -{ - GtkTreePath *path; + if (!gtk_icon_view_get_cursor (GTK_ICON_VIEW (view), &path, NULL)) + { + path = gtk_tree_path_new_from_indices (0, -1); + gtk_icon_view_set_cursor (GTK_ICON_VIEW (view), path, NULL, FALSE); + } - if (!gtk_icon_view_get_cursor (GTK_ICON_VIEW (view), &path, NULL)) + gtk_icon_view_select_path (GTK_ICON_VIEW (view), path); + gtk_tree_path_free (path); + } + else { - path = gtk_tree_path_new_from_indices (0, -1); - gtk_icon_view_set_cursor (GTK_ICON_VIEW (view), path, NULL, FALSE); + gtk_icon_view_unselect_all (GTK_ICON_VIEW (view)); } - - gtk_icon_view_select_path (GTK_ICON_VIEW (view), path); - gtk_tree_path_free (path); - - return FALSE; } #define CSS \ @@ -254,18 +249,10 @@ main (int argc, char *argv[]) NULL); views.view2 = get_view (FALSE); - g_signal_connect (views.view1, "keynav-failed", - G_CALLBACK (keynav_failed), &views); - g_signal_connect (views.view2, "keynav-failed", - G_CALLBACK (keynav_failed), &views); - g_signal_connect (views.view1, "focus-in-event", - G_CALLBACK (focus_in), NULL); - g_signal_connect (views.view1, "focus-out-event", - G_CALLBACK (focus_out), NULL); - g_signal_connect (views.view2, "focus-in-event", - G_CALLBACK (focus_in), NULL); - g_signal_connect (views.view2, "focus-out-event", - G_CALLBACK (focus_out), NULL); + g_signal_connect (views.view1, "keynav-failed", G_CALLBACK (keynav_failed), &views); + g_signal_connect (views.view2, "keynav-failed", G_CALLBACK (keynav_failed), &views); + g_signal_connect (views.view1, "notify::has-focus", G_CALLBACK (focus_changed), &views); + g_signal_connect (views.view2, "notify::has-focus", G_CALLBACK (focus_changed), &views); gtk_container_add (GTK_CONTAINER (vbox), views.header1); gtk_container_add (GTK_CONTAINER (vbox), views.view1); |