summaryrefslogtreecommitdiff
path: root/gtk/gtkmenu.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2018-03-11 13:56:32 +0100
committerCarlos Garnacho <carlosg@gnome.org>2018-04-05 19:26:55 +0200
commitd724506abe3f81e49ae4265bb8541b78db22dd73 (patch)
treea72ad88c1d38d7e950e41f2765f2d7e5f417e1c2 /gtk/gtkmenu.c
parentd5e826a66067f29a43d9e09f58029119296de191 (diff)
downloadgtk+-d724506abe3f81e49ae4265bb8541b78db22dd73.tar.gz
gtkmenu: Stop using ::key-press-event
Use GtkEventControllerKey for the task
Diffstat (limited to 'gtk/gtkmenu.c')
-rw-r--r--gtk/gtkmenu.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index b58c4a7310..56b502f8d1 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -115,6 +115,7 @@
#include "gtkwidgetprivate.h"
#include "gtkwindowgroup.h"
#include "gtkwindowprivate.h"
+#include "gtkeventcontrollerkey.h"
#include "a11y/gtkmenuaccessible.h"
@@ -224,8 +225,6 @@ static void gtk_menu_size_allocate (GtkWidget *widget,
static void gtk_menu_show (GtkWidget *widget);
static void gtk_menu_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot);
-static gboolean gtk_menu_key_press (GtkWidget *widget,
- GdkEventKey *event);
static void gtk_menu_motion (GtkEventController *controller,
double x,
double y,
@@ -505,7 +504,6 @@ gtk_menu_class_init (GtkMenuClass *class)
widget_class->size_allocate = gtk_menu_size_allocate;
widget_class->show = gtk_menu_show;
widget_class->snapshot = gtk_menu_snapshot;
- widget_class->key_press_event = gtk_menu_key_press;
widget_class->focus = gtk_menu_focus;
widget_class->can_activate_accel = gtk_menu_real_can_activate_accel;
widget_class->grab_notify = gtk_menu_grab_notify;
@@ -1144,6 +1142,11 @@ gtk_menu_init (GtkMenu *menu)
g_signal_connect (priv->motion_controller, "enter", G_CALLBACK (gtk_menu_enter), menu);
g_signal_connect (priv->motion_controller, "motion", G_CALLBACK (gtk_menu_motion), menu);
g_signal_connect (priv->motion_controller, "leave", G_CALLBACK (gtk_menu_leave), menu);
+
+ priv->key_controller =
+ gtk_event_controller_key_new (GTK_WIDGET (menu));
+ g_signal_connect_swapped (priv->key_controller, "key-pressed",
+ G_CALLBACK (gtk_menu_stop_navigating_submenu), menu);
}
static void
@@ -1218,6 +1221,7 @@ gtk_menu_finalize (GObject *object)
g_clear_object (&priv->click_gesture);
g_clear_object (&priv->scroll_controller);
g_clear_object (&priv->motion_controller);
+ g_clear_object (&priv->key_controller);
G_OBJECT_CLASS (gtk_menu_parent_class)->finalize (object);
}
@@ -3038,22 +3042,6 @@ gtk_menu_released_cb (GtkGestureMultiPress *gesture,
}
static gboolean
-gtk_menu_key_press (GtkWidget *widget,
- GdkEventKey *event)
-{
- GtkMenu *menu;
-
- g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- menu = GTK_MENU (widget);
-
- gtk_menu_stop_navigating_submenu (menu);
-
- return GTK_WIDGET_CLASS (gtk_menu_parent_class)->key_press_event (widget, event);
-}
-
-static gboolean
check_threshold (GtkWidget *widget,
gint start_x,
gint start_y,