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


Commits:
1e8c130a by wurstsalat at 2022-05-31T20:10:34+02:00
fix: WorkspaceDialog: Disable Remove button for last workspace

- - - - -
0eabdb01 by wurstsalat at 2022-05-31T20:10:34+02:00
imprv: Workspaces: Add Move to new workspace functionality

This allows moving chats to a new workspace by either selecting the 'move 
to'
menu item or by dropping them on the 'new workspace' icon in the sidebar

- - - - -
780e6fe3 by wurstsalat at 2022-05-31T20:12:14+02:00
chore: Add HistorySyncAssistant to pyrightconfig

- - - - -


6 changed files:

- gajim/gtk/chat_list_stack.py
- gajim/gtk/main.py
- gajim/gtk/menus.py
- gajim/gtk/workspace_dialog.py
- gajim/gtk/workspace_side_bar.py
- pyrightconfig.json


Changes:

=====================================
gajim/gtk/chat_list_stack.py
=====================================
@@ -90,6 +90,7 @@ def _add_actions(self) -> None:
         actions = [
             ('toggle-chat-pinned', 'a{sv}', self._toggle_chat_pinned),
             ('move-chat-to-workspace', 'a{sv}', self._move_chat_to_workspace),
+            ('move-chat-to-new-workspace', 'a{sv}', 
self._move_chat_to_new_workspace),
             ('mark-as-read', 'a{sv}', self._mark_as_read),
         ]
 
@@ -230,6 +231,13 @@ def _move_chat_to_workspace(self,
         self.store_open_chats(current_chatlist.workspace_id)
         self.store_open_chats(params.workspace_id)
 
+    @structs.actionmethod
+    def _move_chat_to_new_workspace(self,
+                                    _action: Gio.SimpleAction,
+                                    params: structs.AccountJidParam
+                                    ) -> None:
+        app.window.move_chat_to_new_workspace(params.account, params.jid)
+
     @structs.actionmethod
     def _mark_as_read(self,
                       _action: Gio.SimpleAction,


=====================================
gajim/gtk/main.py
=====================================
@@ -15,8 +15,9 @@
 from __future__ import annotations
 
 from typing import Any
-from typing import Optional
+from typing import cast
 from typing import Generator
+from typing import Optional
 
 import logging
 import os
@@ -530,6 +531,24 @@ def get_chat_list(self, workspace_id: str) -> ChatList:
         chat_list_stack = self._chat_page.get_chat_list_stack()
         return chat_list_stack.get_chatlist(workspace_id)
 
+    def move_chat_to_new_workspace(self,
+                                   account: str,
+                                   jid: JID
+                                   ) -> None:
+        chat_list_stack = self._chat_page.get_chat_list_stack()
+        current_chatlist = cast(ChatList, chat_list_stack.get_visible_child())
+        type_ = current_chatlist.get_chat_type(account, jid)
+        if type_ is None:
+            return
+        current_chatlist.remove_chat(account, jid)
+
+        workspace_id = app.settings.add_workspace(_('My Workspace'))
+        app.window.add_workspace(workspace_id)
+        new_chatlist = self.get_chat_list(workspace_id)
+        new_chatlist.add_chat(account, jid, type_)
+        chat_list_stack.store_open_chats(current_chatlist.workspace_id)
+        chat_list_stack.store_open_chats(workspace_id)
+
     def _add_group_chat(self,
                         _action: Gio.SimpleAction,
                         param: GLib.Variant) -> None:


=====================================
gajim/gtk/menus.py
=====================================
@@ -428,12 +428,16 @@ def get_chat_list_row_menu(workspace_id: str,
     toggle_label = _('Unpin Chat') if pinned else _('Pin Chat')
     menu.add_item(toggle_label, 'win.toggle-chat-pinned', params)
 
+    submenu = menu.add_submenu(_('Move Chat'))
     workspaces = app.settings.get_workspaces()
     if len(workspaces) > 1:
-        submenu = menu.add_submenu(_('Move Chat'))
         for name, params in get_workspace_params(workspace_id, account, jid):
             submenu.add_item(name, 'win.move-chat-to-workspace', params)
 
+    params = AccountJidParam(account=account, jid=jid)
+    submenu.add_item(
+        _('New Workspace'), 'win.move-chat-to-new-workspace', params)
+
     if can_add_to_roster(contact):
         params = AccountJidParam(account=account, jid=jid)
         menu.add_item(_('Add to Contact List…'), 'win.add-to-roster', params)


=====================================
gajim/gtk/workspace_dialog.py
=====================================
@@ -56,7 +56,8 @@ def __init__(self, workspace_id: Optional[str] = None) -> 
None:
         color: Optional[str] = None
         self._avatar_sha: Optional[str] = None
 
-        if workspace_id is None:
+        workspaces = app.settings.get_workspaces()
+        if workspace_id is None or len(workspaces) == 1:
             self._ui.remove_workspace_button.set_sensitive(False)
         else:
             name = app.settings.get_workspace_setting(


=====================================
gajim/gtk/workspace_side_bar.py
=====================================
@@ -149,13 +149,16 @@ def _process_workspace_drop(self, workspace_id: str) -> 
None:
 
     def _process_chat_list_drop(self, identifier: str, y_coord: int) -> None:
         account, jid = identifier.split()
+        jid = JID.from_string(jid)
         workspace_row = cast(Workspace, self.get_row_at_y(y_coord))
         if workspace_row.workspace_id == 'add':
+            app.window.move_chat_to_new_workspace(
+                account, jid)
             return
 
         params = ChatListEntryParam(workspace_id=workspace_row.workspace_id,
                                     account=account,
-                                    jid=JID.from_string(jid))
+                                    jid=jid)
         app.window.activate_action('move-chat-to-workspace',
                                    params.to_variant())
 


=====================================
pyrightconfig.json
=====================================
@@ -82,6 +82,7 @@
         "gajim/gtk/groupchat_settings.py",
         "gajim/gtk/groupchat_state.py",
         "gajim/gtk/history_export.py",
+        "gajim/gtk/history_sync.py",
         "gajim/gtk/main_stack.py",
         "gajim/gtk/main.py",
         "gajim/gtk/mam_preferences.py",



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/e2ef26a4fe71d8f21207e4603c20e509492184f3...780e6fe31d790cf6b216887ed42299c3c5e3fc04

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/e2ef26a4fe71d8f21207e4603c20e509492184f3...780e6fe31d790cf6b216887ed42299c3c5e3fc04
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