summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2018-02-07 19:54:11 -0500
committerMatthias Clasen <mclasen@redhat.com>2018-02-07 19:54:11 -0500
commit444deb8f8731ed41dd66b68581107838bfb013cc (patch)
tree8cdba4b9069269835a1d377e71041dba8851b506
parent4c2db9b5f0fd3fff5e13d5e8569615e887c7e149 (diff)
downloadgtk+-444deb8f8731ed41dd66b68581107838bfb013cc.tar.gz
search bar: Stop using ::key-press-eventwip/matthiasc/kill-key-events2
Use a key event controller instead.
-rw-r--r--examples/search-bar.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/search-bar.c b/examples/search-bar.c
index f932ec8922..2dfeddf413 100644
--- a/examples/search-bar.c
+++ b/examples/search-bar.c
@@ -1,11 +1,14 @@
#include <gtk/gtk.h>
static gboolean
-window_key_press_event_cb (GtkWidget *window,
- GdkEvent *event,
- GtkSearchBar *search_bar)
+window_key_pressed (GtkEventController *controller,
+ guint keyval,
+ guint keycode,
+ GdkModifierType state,
+ GtkSearchBar *search_bar)
{
- return gtk_search_bar_handle_event (search_bar, event);
+ return gtk_search_bar_handle_event (search_bar,
+ gtk_get_current_event ());
}
static void
@@ -17,6 +20,7 @@ activate_cb (GtkApplication *app,
GtkWidget *box;
GtkWidget *entry;
GtkWidget *menu_button;
+ GtkEventController *controller;
window = gtk_application_window_new (app);
gtk_widget_show (window);
@@ -37,8 +41,10 @@ activate_cb (GtkApplication *app,
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (search_bar), GTK_ENTRY (entry));
- g_signal_connect (window, "key-press-event",
- G_CALLBACK (window_key_press_event_cb), search_bar);
+ controller = gtk_event_controller_key_new (window);
+ 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);
}
gint