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.
This commit is contained in:
Mohammed Sadiq 2018-06-14 23:23:14 +05:30
parent bdf3b6f64d
commit b2db7bb95b

View File

@ -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