From b2db7bb95b2043f880bbc575ce6cc56e9bac8253 Mon Sep 17 00:00:00 2001 From: Mohammed Sadiq Date: Thu, 14 Jun 2018 23:23:14 +0530 Subject: [PATCH] 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. --- examples/search-bar.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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 -- 2.30.2