From: Mohammed Sadiq Date: Thu, 14 Jun 2018 17:53:14 +0000 (+0530) Subject: examples: Simplify handling events in search-bar X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~22^2~171 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b2db7bb95b2043f880bbc575ce6cc56e9bac8253;p=gtk4.git examples: Simplify handling events in search-bar In search-bar example, we can use gtk_search_bar_set_key_capture_widget() which would simplify handling keyboard events. --- diff --git a/examples/search-bar.c b/examples/search-bar.c index c2a6f2d805..e75056e70f 100644 --- a/examples/search-bar.c +++ b/examples/search-bar.c @@ -20,7 +20,6 @@ activate_cb (GtkApplication *app, GtkWidget *box; GtkWidget *entry; GtkWidget *menu_button; - GtkEventController *controller; window = gtk_application_window_new (app); gtk_widget_show (window); @@ -41,12 +40,7 @@ activate_cb (GtkApplication *app, gtk_box_pack_start (GTK_BOX (box), menu_button); gtk_search_bar_connect_entry (GTK_SEARCH_BAR (search_bar), GTK_ENTRY (entry)); - - controller = gtk_event_controller_key_new (); - g_object_set_data_full (G_OBJECT (window), "controller", controller, g_object_unref); - g_signal_connect (controller, "key-pressed", - G_CALLBACK (window_key_pressed), search_bar); - gtk_widget_add_controller (window, controller); + gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (search_bar), window); } gint