diff options
author | Benjamin Otte <otte@redhat.com> | 2018-08-04 12:30:53 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-03-18 23:00:49 -0400 |
commit | 0f6c5da28df82ce0af8d2b5e454c011df595f783 (patch) | |
tree | b3d8697b86b333d8bb84a532bc20bb5c154ae9a8 /gtk/gtkwindow.c | |
parent | c7f10e570e92adaf307390ef6008ea486a8e9a12 (diff) | |
download | gtk+-0f6c5da28df82ce0af8d2b5e454c011df595f783.tar.gz |
window: Port bindings to use shortcuts
Diffstat (limited to 'gtk/gtkwindow.c')
-rw-r--r-- | gtk/gtkwindow.c | 104 |
1 files changed, 53 insertions, 51 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 3549009b2e..023c53ee82 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -28,7 +28,6 @@ #include "gtkaccelgroupprivate.h" #include "gtkapplicationprivate.h" -#include "gtkbindings.h" #include "gtkbox.h" #include "gtkbuildable.h" #include "gtkbuilderprivate.h" @@ -566,37 +565,45 @@ G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_BIN, gtk_window_root_interface_init)) 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 guint32 @@ -759,7 +766,6 @@ gtk_window_class_init (GtkWindowClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class; GtkContainerClass *container_class; - GtkBindingSet *binding_set; widget_class = (GtkWidgetClass*) klass; container_class = (GtkContainerClass*) klass; @@ -1105,36 +1111,32 @@ gtk_window_class_init (GtkWindowClass *klass) gtk_widget_class_install_action (widget_class, "default.activate", NULL, gtk_window_activate_default_activate); - binding_set = gtk_binding_set_by_class (klass); - - gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, 0, - "activate-focus", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, 0, - "activate-focus", 0); + gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, 0, + "activate-focus", NULL); + gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, 0, + "activate-focus", NULL); - 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); - - gtk_binding_entry_add_signal (binding_set, GDK_KEY_I, GDK_CONTROL_MASK|GDK_SHIFT_MASK, - "enable-debugging", 1, - G_TYPE_BOOLEAN, FALSE); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_D, GDK_CONTROL_MASK|GDK_SHIFT_MASK, - "enable-debugging", 1, - G_TYPE_BOOLEAN, TRUE); - - 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_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_add_binding_signal (widget_class, GDK_KEY_I, GDK_CONTROL_MASK|GDK_SHIFT_MASK, + "enable-debugging", "(b)", FALSE); + gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_D, GDK_CONTROL_MASK|GDK_SHIFT_MASK, + "enable-debugging", "(b)", TRUE); + + 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_set_accessible_type (widget_class, GTK_TYPE_WINDOW_ACCESSIBLE); gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FRAME); |