diff options
author | wurstsalat <mailtrash@posteo.de> | 2022-08-17 20:03:53 +0300 |
---|---|---|
committer | wurstsalat <mailtrash@posteo.de> | 2022-08-17 20:03:57 +0300 |
commit | 49a5c9b13603e5b2c2e25f0a4eebf627bb9aa53c (patch) | |
tree | 69c6b421c0ab6345f6f3317ced36821cebd34da3 | |
parent | c0c27f43d08dc3a6601fbdefe3ec8767cf54a85a (diff) |
feat: Workspaces: Add shortcuts for switching
Workspaces can be activated by their position using Primary+{position}
-rw-r--r-- | gajim/data/gui/shortcuts_window.ui | 17 | ||||
-rw-r--r-- | gajim/data/other/shortcuts.json | 9 | ||||
-rw-r--r-- | gajim/gtk/main.py | 13 | ||||
-rw-r--r-- | gajim/gtk/workspace_side_bar.py | 16 |
4 files changed, 43 insertions, 12 deletions
diff --git a/gajim/data/gui/shortcuts_window.ui b/gajim/data/gui/shortcuts_window.ui index 603790cc2..e665c3a9c 100644 --- a/gajim/data/gui/shortcuts_window.ui +++ b/gajim/data/gui/shortcuts_window.ui @@ -151,35 +151,35 @@ <object class="GtkShortcutsShortcut"> <property name="visible">1</property> <property name="accelerator"><primary>Page_Up</property> - <property name="title" translatable="yes">Switch to the previous tab</property> + <property name="title" translatable="yes">Switch to the previous chat</property> </object> </child> <child> <object class="GtkShortcutsShortcut"> <property name="visible">1</property> <property name="accelerator"><primary>Page_Down</property> - <property name="title" translatable="yes">Switch to the next tab</property> + <property name="title" translatable="yes">Switch to the next chat</property> </object> </child> <child> <object class="GtkShortcutsShortcut"> <property name="visible">1</property> <property name="accelerator"><Alt>1...9</property> - <property name="title" translatable="yes">Switch to the first - ninth tab</property> + <property name="title" translatable="yes">Switch to the first - ninth chat</property> </object> </child> <child> <object class="GtkShortcutsShortcut"> <property name="visible">1</property> <property name="accelerator"><primary><shift>Tab</property> - <property name="title" translatable="yes">Switch to the previous unread tab</property> + <property name="title" translatable="yes">Switch to the previous unread chat</property> </object> </child> <child> <object class="GtkShortcutsShortcut"> <property name="visible">1</property> <property name="accelerator"><primary>Tab</property> - <property name="title" translatable="yes">Switch to the next unread tab</property> + <property name="title" translatable="yes">Switch to the next unread chat</property> </object> </child> <child> @@ -189,6 +189,13 @@ <property name="title" translatable="yes">Close chat</property> </object> </child> + <child> + <object class="GtkShortcutsShortcut"> + <property name="visible">1</property> + <property name="accelerator"><primary>1...9</property> + <property name="title" translatable="yes">Switch to the first - ninth workspace</property> + </object> + </child> </object> </child> <child> diff --git a/gajim/data/other/shortcuts.json b/gajim/data/other/shortcuts.json index 5396f6972..af8606af6 100644 --- a/gajim/data/other/shortcuts.json +++ b/gajim/data/other/shortcuts.json @@ -29,5 +29,14 @@ "win.switch-tab-7": ["<Alt>7", "<Alt>KP_7"], "win.switch-tab-8": ["<Alt>8", "<Alt>KP_8"], "win.switch-tab-9": ["<Alt>9", "<Alt>KP_9"], + "win.switch-workspace-1": ["<Primary>1", "<Primary>KP_1"], + "win.switch-workspace-2": ["<Primary>2", "<Primary>KP_2"], + "win.switch-workspace-3": ["<Primary>3", "<Primary>KP_3"], + "win.switch-workspace-4": ["<Primary>4", "<Primary>KP_4"], + "win.switch-workspace-5": ["<Primary>5", "<Primary>KP_5"], + "win.switch-workspace-6": ["<Primary>6", "<Primary>KP_6"], + "win.switch-workspace-7": ["<Primary>7", "<Primary>KP_7"], + "win.switch-workspace-8": ["<Primary>8", "<Primary>KP_8"], + "win.switch-workspace-9": ["<Primary>9", "<Primary>KP_9"], "win.toggle-chat-list": ["<Primary>R"] } diff --git a/gajim/gtk/main.py b/gajim/gtk/main.py index d158b6d0f..61e22af93 100644 --- a/gajim/gtk/main.py +++ b/gajim/gtk/main.py @@ -373,6 +373,15 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper): 'switch-tab-7', 'switch-tab-8', 'switch-tab-9', + 'switch-workspace-1', + 'switch-workspace-2', + 'switch-workspace-3', + 'switch-workspace-4', + 'switch-workspace-5', + 'switch-workspace-6', + 'switch-workspace-7', + 'switch-workspace-8', + 'switch-workspace-9', 'toggle-chat-list', ] @@ -442,6 +451,10 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper): number = int(action_name[-1]) - 1 self.select_chat_number(number) + elif action_name.startswith('switch-workspace-'): + number = int(action_name[-1]) - 1 + self._workspace_side_bar.activate_workspace_number(number) + elif action_name == 'toggle-chat-list': self._toggle_chat_list() diff --git a/gajim/gtk/workspace_side_bar.py b/gajim/gtk/workspace_side_bar.py index 4af7b134d..73601bf99 100644 --- a/gajim/gtk/workspace_side_bar.py +++ b/gajim/gtk/workspace_side_bar.py @@ -218,9 +218,8 @@ class WorkspaceSideBar(Gtk.ListBox): self.insert(row, len(self.get_children()) - 1) def store_workspace_order(self) -> None: - workspaces: list[CommonWorkspace] = cast( - list[CommonWorkspace], self.get_children()) - order: list[str] = [row.workspace_id for row in workspaces] + workspaces = cast(list[CommonWorkspace], self.get_children()) + order = [row.workspace_id for row in workspaces] order.remove('add') app.settings.set_app_setting('workspace_order', order) @@ -239,6 +238,11 @@ class WorkspaceSideBar(Gtk.ListBox): row = self._workspaces[workspace_id] self.select_row(row) + def activate_workspace_number(self, number: int) -> None: + row = cast(CommonWorkspace, self.get_row_at_index(number)) + if row is not None and row.workspace_id != 'add': + app.window.activate_workspace(row.workspace_id) + def get_active_workspace(self) -> Optional[str]: row = cast(CommonWorkspace, self.get_selected_row()) if row is None: @@ -246,8 +250,7 @@ class WorkspaceSideBar(Gtk.ListBox): return row.workspace_id def get_first_workspace(self) -> str: - workspaces: list[CommonWorkspace] = cast( - list[CommonWorkspace], self.get_children()) + workspaces = cast(list[CommonWorkspace], self.get_children()) for row in workspaces: return row.workspace_id return '' @@ -255,8 +258,7 @@ class WorkspaceSideBar(Gtk.ListBox): def get_workspace_by_id(self, workspace_id: str ) -> Optional[CommonWorkspace]: - workspaces: list[CommonWorkspace] = cast( - list[CommonWorkspace], self.get_children()) + workspaces = cast(list[CommonWorkspace], self.get_children()) for row in workspaces: if row.workspace_id == workspace_id: return row |