Daniel Brötzmann pushed to branch mainwindow at gajim / gajim


Commits:
98ef46d0 by Daniel Brötzmann at 2021-02-22T19:39:38+01:00
Store pinned chats

- - - - -


3 changed files:

- gajim/gtk/chat_list.py
- gajim/gtk/chat_list_stack.py
- gajim/gtk/main.py


Changes:

=====================================
gajim/gtk/chat_list.py
=====================================
@@ -157,12 +157,12 @@ def get_chat_type(self, account, jid):
         row = self._chats.get((account, jid))
         return row.type
 
-    def add_chat(self, account, jid, type_):
+    def add_chat(self, account, jid, type_, pinned=False):
         if self._chats.get((account, jid)) is not None:
             # Chat is already in the List
             return
 
-        row = ChatRow(self._workspace_id, account, jid, type_)
+        row = ChatRow(self._workspace_id, account, jid, type_, pinned)
         self._chats[(account, jid)] = row
         self.add(row)
 
@@ -192,7 +192,7 @@ def contains_chat(self, account, jid):
     def get_open_chats(self):
         open_chats = []
         for key, value in self._chats.items():
-            open_chats.append(key + (value.type,))
+            open_chats.append(key + (value.type, value.is_pinned))
         return open_chats
 
     def update_time(self):
@@ -281,7 +281,7 @@ def _add_unread(row, properties):
 
 
 class ChatRow(Gtk.ListBoxRow):
-    def __init__(self, workspace_id, account, jid, type_):
+    def __init__(self, workspace_id, account, jid, type_, pinned):
         Gtk.ListBoxRow.__init__(self)
 
         self.account = account
@@ -295,7 +295,7 @@ def __init__(self, workspace_id, account, jid, type_):
 
         self._timestamp = None
         self._unread_count = 0
-        self._pinned = False  # TODO: Load from settings
+        self._pinned = pinned
 
         self.get_style_context().add_class('chatlist-row')
 


=====================================
gajim/gtk/chat_list_stack.py
=====================================
@@ -115,11 +115,11 @@ def show_chat_list(self, workspace_id):
             app.settings.get_workspace_setting(workspace_id, 'name'))
         self.set_visible_child_name(workspace_id)
 
-    def add_chat(self, workspace_id, account, jid, type_):
+    def add_chat(self, workspace_id, account, jid, type_, pinned=False):
         chat_list = self._chat_lists.get(workspace_id)
         if chat_list is None:
             chat_list = self.add_chat_list(workspace_id)
-        chat_list.add_chat(account, jid, type_)
+        chat_list.add_chat(account, jid, type_, pinned)
 
     def select_chat(self, account, jid):
         chat_list = self._find_chat(account, jid)
@@ -138,6 +138,7 @@ def store_open_chats(self, workspace_id):
     def toggle_chat_pinned(self, workspace_id, account, jid):
         chat_list = self._chat_lists[workspace_id]
         chat_list.toggle_chat_pinned(account, jid)
+        self.store_open_chats(workspace_id)
 
     def remove_chat(self, workspace_id, account, jid):
         chat_list = self._chat_lists[workspace_id]


=====================================
gajim/gtk/main.py
=====================================
@@ -404,6 +404,7 @@ def add_chat_for_workspace(self,
                                account,
                                jid,
                                type_,
+                               pinned=False,
                                select=False):
 
         if self.chat_exists(account, jid):
@@ -421,7 +422,8 @@ def add_chat_for_workspace(self,
             self._chat_stack.add_private_chat(account, jid)
         else:
             self._chat_stack.add_chat(account, jid)
-        self._chat_list_stack.add_chat(workspace_id, account, jid, type_)
+        self._chat_list_stack.add_chat(workspace_id, account, jid, type_,
+                                       pinned)
 
         if self._startup_finished:
             if select:
@@ -483,10 +485,11 @@ def _load_chats(self):
             self._chat_list_stack.add_chat_list(workspace_id)
             open_chats = app.settings.get_workspace_setting(workspace_id,
                                                             'open_chats')
-            for account, jid, type_ in open_chats:
+            for account, jid, type_, pinned in open_chats:
                 if account not in app.connections:
                     continue
-                self.add_chat_for_workspace(workspace_id, account, jid, type_)
+                self.add_chat_for_workspace(workspace_id, account, jid, type_,
+                                            pinned=pinned)
 
         for workspace_id in app.settings.get_workspaces():
             self._workspace_side_bar.activate_workspace(workspace_id)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/98ef46d02a08a924b10267f1de8f1cbc4fb17acd

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/98ef46d02a08a924b10267f1de8f1cbc4fb17acd
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to