From f231ac65419ad4e05ae2e1c6c0fd71053695c8c3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 7 Feb 2018 19:42:47 -0500 Subject: Shortcuts window: stop using ::key-press-event Use a key event controller instead. --- gtk/gtkshortcutswindow.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'gtk/gtkshortcutswindow.c') diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c index 771a71018e..91551946b9 100644 --- a/gtk/gtkshortcutswindow.c +++ b/gtk/gtkshortcutswindow.c @@ -41,6 +41,10 @@ #include "gtktogglebutton.h" #include "gtktypebuiltins.h" #include "gtkwidgetprivate.h" +#include "gtkeventcontrollerkey.h" +#include "gtkprivate.h" +#include "gtkintl.h" +#include "gtkmain.h" /** * SECTION:gtkshortcutswindow @@ -111,6 +115,7 @@ typedef struct GtkListBox *list_box; GtkBox *search_gestures; GtkBox *search_shortcuts; + GtkEventController *controller; GtkWindow *window; gulong keys_changed_id; @@ -646,6 +651,7 @@ gtk_shortcuts_window_finalize (GObject *object) g_clear_object (&priv->search_image_group); g_clear_object (&priv->search_text_group); + g_clear_object (&priv->controller); G_OBJECT_CLASS (gtk_shortcuts_window_parent_class)->finalize (object); } @@ -852,14 +858,16 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass) } static gboolean -window_key_press_event_cb (GtkWidget *window, - GdkEvent *event, - gpointer data) +window_key_pressed (GtkEventController *controller, + guint keyval, + guint keycode, + GdkModifierType state, + gpointer data) { - GtkShortcutsWindow *self = GTK_SHORTCUTS_WINDOW (window); + GtkShortcutsWindow *self = GTK_SHORTCUTS_WINDOW (gtk_event_controller_get_widget (controller)); GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); - return gtk_search_bar_handle_event (priv->search_bar, event); + return gtk_search_bar_handle_event (priv->search_bar, gtk_get_current_event ()); } static void @@ -878,8 +886,9 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self) gtk_window_set_resizable (GTK_WINDOW (self), FALSE); gtk_window_set_type_hint (GTK_WINDOW (self), GDK_SURFACE_TYPE_HINT_DIALOG); - g_signal_connect (self, "key-press-event", - G_CALLBACK (window_key_press_event_cb), NULL); + priv->controller = gtk_event_controller_key_new (GTK_WIDGET (self)); + g_signal_connect (priv->controller, "key-pressed", + G_CALLBACK (window_key_pressed), NULL); priv->keywords = g_hash_table_new_full (NULL, NULL, NULL, g_free); priv->search_items_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); -- cgit v1.2.1