summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2018-02-07 19:54:11 -0500
committerCarlos Garnacho <carlosg@gnome.org>2018-04-05 19:26:53 +0200
commitb033e30318b547c5f0c67b61338c06905c2c5759 (patch)
tree26f508f8adf9193623af2add7967dd5cab76020f /examples
parentf231ac65419ad4e05ae2e1c6c0fd71053695c8c3 (diff)
downloadgtk+-b033e30318b547c5f0c67b61338c06905c2c5759.tar.gz
search bar: Stop using ::key-press-event
Use a key event controller instead.
Diffstat (limited to 'examples')
-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