Philipp Hörist pushed to branch master at gajim / gajim
Commits: dfba6786 by Philipp Hörist at 2022-09-26T23:17:45+02:00 feat: Add shortcut to restore chats after closing Fixes #11088 - - - - - 5 changed files: - gajim/data/gui/shortcuts_window.ui - gajim/data/other/shortcuts.json - gajim/gtk/chat_page.py - gajim/gtk/const.py - gajim/gtk/main.py Changes: ===================================== gajim/data/gui/shortcuts_window.ui ===================================== @@ -203,6 +203,13 @@ <property name="title" translatable="yes">Close chat</property> </object> </child> + <child> + <object class="GtkShortcutsShortcut"> + <property name="visible">1</property> + <property name="accelerator"><primary><shift>w</property> + <property name="title" translatable="yes">Restore chat</property> + </object> + </child> <child> <object class="GtkShortcutsShortcut"> <property name="visible">1</property> ===================================== gajim/data/other/shortcuts.json ===================================== @@ -15,6 +15,7 @@ "win.show-emoji-chooser": ["<Primary><Shift>M"], "win.input-clear": ["<Primary>U"], "win.close-chat": ["<Primary>W"], + "win.restore-chat": ["<Primary><Shift>W"], "win.switch-next-chat": ["<Primary>Page_Down"], "win.switch-prev-chat": ["<Primary>Page_Up"], "win.switch-next-unread-chat": ["<Primary>Tab"], ===================================== gajim/gtk/chat_page.py ===================================== @@ -98,6 +98,7 @@ def __init__(self): self._ui.paned.connect('button-release-event', self._on_button_release) self._startup_finished: bool = False + self._closed_chat_memory: list[tuple[str, JID, str]] = [] self._add_actions() @@ -273,6 +274,21 @@ def load_workspace_chats(self, workspace_id: str) -> None: def is_chat_active(self, account: str, jid: JID) -> bool: return self._chat_list_stack.is_chat_active(account, jid) + def restore_chat(self) -> None: + if not self._closed_chat_memory: + return + + account, jid, workspace_id = self._closed_chat_memory.pop() + + client = app.get_client(account) + contact = client.get_module('Contacts').get_contact(jid) + + self.add_chat_for_workspace(workspace_id, + account, + jid, + contact.type_string, + select=True) + def _remove_chat(self, _action: Gio.SimpleAction, param: GLib.Variant) -> None: @@ -285,6 +301,7 @@ def _remove_chat(self, def remove_chat(self, account: str, jid: JID) -> None: for workspace_id in app.settings.get_workspaces(): if self.chat_exists_for_workspace(workspace_id, account, jid): + self._closed_chat_memory.append((account, jid, workspace_id)) self._chat_list_stack.remove_chat(workspace_id, account, jid) return ===================================== gajim/gtk/const.py ===================================== @@ -220,6 +220,7 @@ def __str__(self): ('change-subject', None, True), ('escape', None, True), ('close-chat', None, True), + ('restore-chat', None, True), ('switch-next-chat', None, True), ('switch-prev-chat', None, True), ('switch-next-unread-chat', None, True), ===================================== gajim/gtk/main.py ===================================== @@ -341,6 +341,7 @@ def _connect_actions(self) -> None: ('change-subject', self._on_action), ('escape', self._on_action), ('close-chat', self._on_action), + ('restore-chat', self._on_action), ('switch-next-chat', self._on_action), ('switch-prev-chat', self._on_action), ('switch-next-unread-chat', self._on_action), @@ -414,7 +415,10 @@ def _on_action(self, control.contact.jid) return None - if action_name == 'switch-next-chat': + if action_name == 'restore-chat': + self._chat_page.restore_chat() + + elif action_name == 'switch-next-chat': self.select_next_chat(Direction.NEXT) elif action_name == 'switch-prev-chat': View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/dfba6786224cd747211d2f70d75c75e7840116cf -- View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/dfba6786224cd747211d2f70d75c75e7840116cf You're receiving this email because of your account on dev.gajim.org.
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits