diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-03-17 17:24:09 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-03-25 22:36:03 -0400 |
commit | c1247a7993ddd1a530ac662e88632faa5bf16b63 (patch) | |
tree | 97a6cbbf3f4b5f2d6258e5343dffc2c1f28357e2 /gtk/gtkpopover.c | |
parent | b2a747b4d48e95e002d9b63ddb35a8f112312e64 (diff) | |
download | gtk+-c1247a7993ddd1a530ac662e88632faa5bf16b63.tar.gz |
popover: Add keynav keybindings
The shortcut controllers are limited to same-native,
so we need to duplicate the Tab and arrow key bindings
for focus handling, as well as the Enter bindings for
activation.
Diffstat (limited to 'gtk/gtkpopover.c')
-rw-r--r-- | gtk/gtkpopover.c | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 088759f45c..f12616d0e6 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -103,7 +103,6 @@ #include "gtkwidgetprivate.h" #include "gtkeventcontrollerkey.h" #include "gtkcssnodeprivate.h" -#include "gtkbindings.h" #include "gtkbinlayout.h" #include "gtkenums.h" #include "gtktypebuiltins.h" @@ -1445,37 +1444,41 @@ gtk_popover_remove (GtkContainer *container, } static void -add_tab_bindings (GtkBindingSet *binding_set, +add_tab_bindings (GtkWidgetClass *widget_class, GdkModifierType modifiers, GtkDirectionType direction) { - gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, modifiers, - "move-focus", 1, - GTK_TYPE_DIRECTION_TYPE, direction); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, modifiers, - "move-focus", 1, - GTK_TYPE_DIRECTION_TYPE, direction); + gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Tab, modifiers, + "move-focus", + "(i)", direction); + gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Tab, modifiers, + "move-focus", + "(i)", direction); } static void -add_arrow_bindings (GtkBindingSet *binding_set, +add_arrow_bindings (GtkWidgetClass *widget_class, guint keysym, GtkDirectionType direction) { guint keypad_keysym = keysym - GDK_KEY_Left + GDK_KEY_KP_Left; - gtk_binding_entry_add_signal (binding_set, keysym, 0, - "move-focus", 1, - GTK_TYPE_DIRECTION_TYPE, direction); - gtk_binding_entry_add_signal (binding_set, keysym, GDK_CONTROL_MASK, - "move-focus", 1, - GTK_TYPE_DIRECTION_TYPE, direction); - gtk_binding_entry_add_signal (binding_set, keypad_keysym, 0, - "move-focus", 1, - GTK_TYPE_DIRECTION_TYPE, direction); - gtk_binding_entry_add_signal (binding_set, keypad_keysym, GDK_CONTROL_MASK, - "move-focus", 1, - GTK_TYPE_DIRECTION_TYPE, direction); + gtk_widget_class_add_binding_signal (widget_class, keysym, 0, + "move-focus", + "(i)", + direction); + gtk_widget_class_add_binding_signal (widget_class, keysym, GDK_CONTROL_MASK, + "move-focus", + "(i)", + direction); + gtk_widget_class_add_binding_signal (widget_class, keypad_keysym, 0, + "move-focus", + "(i)", + direction); + gtk_widget_class_add_binding_signal (widget_class, keypad_keysym, GDK_CONTROL_MASK, + "move-focus", + "(i)", + direction); } static void @@ -1484,7 +1487,6 @@ gtk_popover_class_init (GtkPopoverClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - GtkBindingSet *binding_set; object_class->dispose = gtk_popover_dispose; object_class->finalize = gtk_popover_finalize; @@ -1563,24 +1565,22 @@ gtk_popover_class_init (GtkPopoverClass *klass) G_TYPE_NONE, 0); - binding_set = gtk_binding_set_by_class (klass); - - add_arrow_bindings (binding_set, GDK_KEY_Up, GTK_DIR_UP); - add_arrow_bindings (binding_set, GDK_KEY_Down, GTK_DIR_DOWN); - add_arrow_bindings (binding_set, GDK_KEY_Left, GTK_DIR_LEFT); - add_arrow_bindings (binding_set, GDK_KEY_Right, GTK_DIR_RIGHT); - - add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD); - add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD); - add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - - gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0, - "activate-default", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0, - "activate-default", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0, - "activate-default", 0); + add_arrow_bindings (widget_class, GDK_KEY_Up, GTK_DIR_UP); + add_arrow_bindings (widget_class, GDK_KEY_Down, GTK_DIR_DOWN); + add_arrow_bindings (widget_class, GDK_KEY_Left, GTK_DIR_LEFT); + add_arrow_bindings (widget_class, GDK_KEY_Right, GTK_DIR_RIGHT); + + add_tab_bindings (widget_class, 0, GTK_DIR_TAB_FORWARD); + add_tab_bindings (widget_class, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD); + add_tab_bindings (widget_class, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); + add_tab_bindings (widget_class, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); + + gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0, + "activate-default", NULL); + gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0, + "activate-default", NULL); + gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Enter, 0, + "activate-default", NULL); gtk_widget_class_set_css_name (widget_class, "popover"); } |