diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-02-07 19:42:47 -0500 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-04-05 19:26:53 +0200 |
commit | f231ac65419ad4e05ae2e1c6c0fd71053695c8c3 (patch) | |
tree | cc2ec93d791e65413913b593e7d3fe5a3184cb09 /gtk/gtkshortcutswindow.c | |
parent | c971ca7c344a5b56e718a42c1b85017b3647bc6e (diff) | |
download | gtk+-f231ac65419ad4e05ae2e1c6c0fd71053695c8c3.tar.gz |
Shortcuts window: stop using ::key-press-event
Use a key event controller instead.
Diffstat (limited to 'gtk/gtkshortcutswindow.c')
-rw-r--r-- | gtk/gtkshortcutswindow.c | 23 |
1 files changed, 16 insertions, 7 deletions
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); |