Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits: 8e2cb364 by lovetox at 2021-01-27T00:06:20+01:00 Fix some selection bugs
- - - - -
3 changed files:
- gajim/gtk/chat_list_stack.py - gajim/gtk/main.py - gajim/gtk/workspace_side_bar.py
Changes:
===================================== gajim/gtk/chat_list_stack.py ===================================== @@ -16,6 +16,8 @@ def __init__(self, ui, chat_stack): self._chat_stack = chat_stack self._chat_lists = {}
+ self.add_named(Gtk.Box(), 'default') + self.show_all() self._ui.search_entry.connect( 'search-changed', self._on_search_changed) @@ -35,7 +37,7 @@ def add_chat_list(self, workspace_id): def remove_chat_list(self, workspace_id): chat_list = self._chat_lists[workspace_id] self.remove(chat_list) - for account, jid in chat_list.get_open_chats(): + for account, jid, _ in chat_list.get_open_chats(): self.remove_chat(workspace_id, account, jid)
self._chat_lists.pop(workspace_id) @@ -48,9 +50,16 @@ def _on_row_selected(self, _chat_list, row): self._chat_stack.show_chat(row.account, row.jid)
def show_chat_list(self, workspace_id): - self.set_visible_child_name(workspace_id) + current_workspace_id = self.get_visible_child_name() + if current_workspace_id == workspace_id: + return + + if current_workspace_id != 'default': + self._chat_lists[current_workspace_id].unselect_all() + self._ui.workspace_label.set_text( app.settings.get_workspace_setting(workspace_id, 'name')) + self.set_visible_child_name(workspace_id)
def add_chat(self, workspace_id, account, jid, type_): chat_list = self._chat_lists.get(workspace_id) @@ -66,7 +75,6 @@ def select_chat(self, workspace_id, account, jid): def store_open_chats(self, workspace_id): chat_list = self._chat_lists[workspace_id] open_chats = chat_list.get_open_chats() - print('store', open_chats) app.settings.set_workspace_setting( workspace_id, 'open_chats', open_chats)
===================================== gajim/gtk/main.py ===================================== @@ -105,10 +105,22 @@ def add_workspace(self, _action, param):
def remove_workspace(self, _action, param): workspace_id = param.get_string() - self._workspace_side_bar.remove_workspace(workspace_id) + + was_active = self.get_active_workspace() == workspace_id + + success = self._workspace_side_bar.remove_workspace(workspace_id) + if not success: + return + + if was_active: + new_active_id = self._workspace_side_bar.get_first_workspace() + self._workspace_side_bar.activate_workspace(new_active_id) + self._chat_list_stack.show_chat_list(new_active_id) + self._chat_list_stack.remove_chat_list(workspace_id) app.settings.remove_workspace(workspace_id)
+ def activate_workspace(self, _action, param): workspace_id = param.get_string() self._workspace_side_bar.activate_workspace(workspace_id) @@ -145,6 +157,11 @@ def _load_chats(self): continue self.add_chat_for_workspace(workspace_id, account, jid, type_)
+ for workspace_id in app.settings.get_workspaces(): + self._workspace_side_bar.activate_workspace(workspace_id) + self._chat_list_stack.show_chat_list(workspace_id) + break + self._startup_finished = True
def _on_start_chat_clicked(self, _button):
===================================== gajim/gtk/workspace_side_bar.py ===================================== @@ -51,8 +51,11 @@ def add_workspace(self, workspace_id): self.add(row)
def remove_workspace(self, workspace_id): + if len(self._workspaces) == 1: + return False row = self._workspaces.pop(workspace_id) self.remove(row) + return True
def activate_workspace(self, workspace_id): row = self.get_selected_row() @@ -68,6 +71,10 @@ def get_active_workspace(self): return None return row.workspace_id
+ def get_first_workspace(self): + for row in self.get_children(): + return row.workspace_id + def update_avatar(self, workspace_id): row = self._workspaces[workspace_id] row.update_avatar()
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/8e2cb36451cf3229d3461ca02f7a81339...