From b59d5434f2d922ea395eb81d486b87b3ddfb3f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Br=C3=B6tzmann?= Date: Tue, 30 Apr 2019 18:43:42 +0200 Subject: [PATCH] Shortcuts: Add shortcuts to move tab left or right --- gajim/data/gui/shortcuts_window.ui | 16 +++++++++++++++- gajim/message_window.py | 20 ++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/gajim/data/gui/shortcuts_window.ui b/gajim/data/gui/shortcuts_window.ui index 42a721079..4dd1976e7 100644 --- a/gajim/data/gui/shortcuts_window.ui +++ b/gajim/data/gui/shortcuts_window.ui @@ -109,7 +109,7 @@ 1 - <alt>Left <ctrl>Page_Up + <alt>Left <ctrl>Page_Up Switch to the previous tab @@ -141,6 +141,20 @@ Switch to the next unread tab + + + 1 + <ctrl><shift>Page_Up + Move tab to the left + + + + + 1 + <ctrl><shift>Page_Down + Move tab to the right + + 1 diff --git a/gajim/message_window.py b/gajim/message_window.py index 7982878a2..aca0cb86d 100644 --- a/gajim/message_window.py +++ b/gajim/message_window.py @@ -121,6 +121,7 @@ class MessageWindow: keys = ['f', 'g', 'h', 'i', 'l', 'L', 'n', 'u', 'b', 'F4', + 'Page_Up', 'Page_Down', 'w', 'Page_Up', 'Page_Down', 'Right', 'Left', 'd', 'c', 'm', 't', 'Escape'] + \ [''+str(i) for i in range(10)] @@ -411,7 +412,8 @@ class MessageWindow: 'gtk-key-theme-name') == 'Emacs': self.remove_tab(control, self.CLOSE_CTRL_KEY) return True - elif keyval in (Gdk.KEY_Page_Up, Gdk.KEY_Page_Down): + elif keyval in (Gdk.KEY_Page_Up, Gdk.KEY_Page_Down) and not \ + modifier & Gdk.ModifierType.SHIFT_MASK: # CTRL + PageUp | PageDown # Create event and send it to notebook event = Gdk.Event.new(Gdk.EventType.KEY_PRESS) @@ -425,10 +427,24 @@ class MessageWindow: if modifier & Gdk.ModifierType.SHIFT_MASK: # CTRL + SHIFT if control.type_id == message_control.TYPE_GC and \ - keyval == Gdk.KEY_n: # CTRL + SHIFT + n + keyval == Gdk.KEY_n: # CTRL + SHIFT + n self.window.lookup_action( 'change-nick-%s' % control.control_id).activate() return True + # CTRL + SHIFT + PageUp | PageDown + old_position = self.notebook.get_current_page() + total_pages = self.notebook.get_n_pages() + if keyval == Gdk.KEY_Page_Up: + self.notebook.reorder_child(control.widget, + old_position - 1) + return True + if keyval == Gdk.KEY_Page_Down: + if old_position == total_pages - 1: + self.notebook.reorder_child(control.widget, 0) + return True + self.notebook.reorder_child(control.widget, + old_position + 1) + return True # MOD1 (ALT) mask elif modifier & Gdk.ModifierType.MOD1_MASK: # Tab switch bindings