From 6c404d035577e185fa4911080325f6ef9554fb7e Mon Sep 17 00:00:00 2001 From: dkmvs <67212386+dkmvs@users.noreply.github.com> Date: Mon, 14 Sep 2020 04:26:13 +0300 Subject: [PATCH] Allow `Shift+Tab` Key Binding Accelerator This commit allows to assign the `Shift+Tab` key binding to an action in `Preferences>Keybindings`. In GTK the Tab key can be modified by the Shift key. Such a key combination has a special key value - `Gdk.KEY_ISO_Left_Tab`. To allow it, `key = key_with_shift.keyval` was added to the code. However, `Gdk.KEY_ISO_Left_Tab` key value is displayed as `Left Tab` in `Preferences>Keybindings`, which is confusing as it is not obvious that it corresponds to the `Shift+Tab` key combination. To make sure that `Shift+Tab` is displayed as `Shift+Tab`, the `Shift+Tab` case is treated as if no Shift was pressed at all. --- terminatorlib/prefseditor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index c77ab7c9..96290904 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -1673,7 +1673,9 @@ class PrefsEditor: def on_cellrenderer_accel_edited(self, liststore, path, key, mods, _code): """Handle an edited keybinding""" - if mods & Gdk.ModifierType.SHIFT_MASK: + # Ignore `Gdk.KEY_Tab` so that `Shift+Tab` is displayed as `Shift+Tab` + # in `Preferences>Keybindings` and NOT `Left Tab` (see `Gdk.KEY_ISO_Left_Tab`). + if mods & Gdk.ModifierType.SHIFT_MASK and key != Gdk.KEY_Tab: key_with_shift = Gdk.Keymap.translate_keyboard_state( self.keybindings.keymap, hardware_keycode=_code, @@ -1687,6 +1689,7 @@ class PrefsEditor: # Shift key. if key_with_shift.level != 0 and keyval_lower == keyval_upper: mods = Gdk.ModifierType(mods & ~Gdk.ModifierType.SHIFT_MASK) + key = key_with_shift.keyval accel = Gtk.accelerator_name(key, mods) current_binding = liststore.get_value(liststore.get_iter(path), 0)