Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2022-09-27 00:17:41 +0300
committerPhilipp Hörist <philipp@hoerist.com>2022-09-27 00:17:45 +0300
commitdfba6786224cd747211d2f70d75c75e7840116cf (patch)
tree1c06b50439b5c7cf9a1b6f8f70d85f7c071880e3
parent86690d0b3f46001dd1ddcbd28414bc9810e221a2 (diff)
feat: Add shortcut to restore chats after closing
Fixes #11088
-rw-r--r--gajim/data/gui/shortcuts_window.ui7
-rw-r--r--gajim/data/other/shortcuts.json1
-rw-r--r--gajim/gtk/chat_page.py17
-rw-r--r--gajim/gtk/const.py1
-rw-r--r--gajim/gtk/main.py6
5 files changed, 31 insertions, 1 deletions
diff --git a/gajim/data/gui/shortcuts_window.ui b/gajim/data/gui/shortcuts_window.ui
index 9e500f306..1c24e5be6 100644
--- a/gajim/data/gui/shortcuts_window.ui
+++ b/gajim/data/gui/shortcuts_window.ui
@@ -206,6 +206,13 @@
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
+ <property name="accelerator">&lt;primary&gt;&lt;shift&gt;w</property>
+ <property name="title" translatable="yes">Restore chat</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">1</property>
<property name="accelerator">&lt;primary&gt;1...9</property>
<property name="title" translatable="yes">Switch to the first - ninth workspace</property>
</object>
diff --git a/gajim/data/other/shortcuts.json b/gajim/data/other/shortcuts.json
index b472ece52..27e14db7b 100644
--- a/gajim/data/other/shortcuts.json
+++ b/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"],
diff --git a/gajim/gtk/chat_page.py b/gajim/gtk/chat_page.py
index 0aaa274a5..a1def675c 100644
--- a/gajim/gtk/chat_page.py
+++ b/gajim/gtk/chat_page.py
@@ -98,6 +98,7 @@ class ChatPage(Gtk.Box):
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 @@ class ChatPage(Gtk.Box):
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 @@ class ChatPage(Gtk.Box):
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
diff --git a/gajim/gtk/const.py b/gajim/gtk/const.py
index d206dc643..fc89baff9 100644
--- a/gajim/gtk/const.py
+++ b/gajim/gtk/const.py
@@ -220,6 +220,7 @@ MAIN_WIN_ACTIONS = [
('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),
diff --git a/gajim/gtk/main.py b/gajim/gtk/main.py
index 7a615c9ad..a326423a6 100644
--- a/gajim/gtk/main.py
+++ b/gajim/gtk/main.py
@@ -341,6 +341,7 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper):
('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 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper):
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':