Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits: 1634ed6e by lovetox at 2021-01-31T23:06:43+01:00 Stuff
- - - - -
8 changed files:
- gajim/data/style/gajim.css - gajim/gtk/account_side_bar.py - gajim/gtk/chat_list.py - gajim/gtk/main.py - gajim/gtk/start_chat.py - gajim/gtk/workspace_dialog.py - gajim/gtk/workspace_side_bar.py - gajim/gui_interface.py
Changes:
===================================== gajim/data/style/gajim.css ===================================== @@ -35,7 +35,7 @@
/* Main Window */ .mainwindow-grid { - background:rgb(255, 255, 255); + background: @theme_base_color; }
/* Generic elements */
===================================== gajim/gtk/account_side_bar.py ===================================== @@ -25,10 +25,9 @@ def add_account(self, account): def remove_account(self, account): pass
- def _on_row_activated(self, _listbox, row): - main_window = self.get_toplevel() - main_window.activate_action( - 'activate-account-page', GLib.Variant('s', row.account)) + @staticmethod + def _on_row_activated(_listbox, row): + app.window.show_account_page(row.account)
def activate_account_page(self, account): row = self.get_selected_row()
===================================== gajim/gtk/chat_list.py ===================================== @@ -206,9 +206,7 @@ def _on_state_flags_changed(self, _listboxrow, *args): self._revealer.set_reveal_child(False)
def _on_close_button_clicked(self, _button): - self.get_toplevel().activate_action( - 'remove-chat', - GLib.Variant('as', [self.workspace_id, self.account, self.jid])) + app.window.remove_chat(self.workspace_id, self.account, self.jid)
def set_unread(self, count): log.info('Set unread count: %s (%s)', self.jid, count)
===================================== gajim/gtk/main.py ===================================== @@ -69,13 +69,12 @@ def __init__(self):
def _add_actions(self): actions = [ - ('add-workspace', 's', self.add_workspace), - ('remove-workspace', 's', self.remove_workspace), - ('activate-workspace', 's', self.activate_workspace), - ('add-chat', 'as', self.add_chat), - ('add-group-chat', 'as', self.add_group_chat), - ('remove-chat', 'as', self.remove_chat), - ('activate-account-page', 's', self.activate_account_page), + ('add-workspace', 's', self._add_workspace), + ('remove-workspace', 's', self._remove_workspace), + ('activate-workspace', 's', self._activate_workspace), + ('add-chat', 'as', self._add_chat), + ('add-group-chat', 'as', self._add_group_chat), + ('remove-chat', 'as', self._remove_chat), ]
for action in actions: @@ -100,8 +99,7 @@ def show_title(self, *args): def get_active_jid(self, *args): pass
- def activate_account_page(self, _action, param): - account = param.get_string() + def show_account_page(self, account): self._account_side_bar.activate_account_page(account) self._ui.main_stack.set_visible_child_name(account)
@@ -119,16 +117,21 @@ def is_chat_focused(self, account, jid): return False return self._chat_list_stack.is_chat_active(account, jid)
- def add_workspace(self, _action, param): + def _add_workspace(self, _action, param): workspace_id = param.get_string() + self.add_workspace(workspace_id) + + def add_workspace(self, workspace_id): self._workspace_side_bar.add_workspace(workspace_id) self._chat_list_stack.add_chat_list(workspace_id) self._workspace_side_bar.activate_workspace(workspace_id) self._chat_list_stack.show_chat_list(workspace_id)
- def remove_workspace(self, _action, param): + def _remove_workspace(self, _action, param): workspace_id = param.get_string() + self.remove_workspace(workspace_id)
+ def remove_workspace(self, workspace_id): was_active = self.get_active_workspace() == workspace_id
success = self._workspace_side_bar.remove_workspace(workspace_id) @@ -143,19 +146,28 @@ def remove_workspace(self, _action, param): self._chat_list_stack.remove_chat_list(workspace_id) app.settings.remove_workspace(workspace_id)
- def activate_workspace(self, _action, param): - self._ui.main_stack.set_visible_child_name('chats') + def _activate_workspace(self, _action, param): workspace_id = param.get_string() + self.activate_workspace(workspace_id) + + def activate_workspace(self, workspace_id): + self._ui.main_stack.set_visible_child_name('chats') self._workspace_side_bar.activate_workspace(workspace_id) self._chat_list_stack.show_chat_list(workspace_id)
- def add_group_chat(self, _action, param): + def _add_group_chat(self, _action, param): account, jid = param.unpack() + self.add_group_chat(account, jid) + + def add_group_chat(self, account, jid): workspace_id = self._workspace_side_bar.get_active_workspace() self.add_chat_for_workspace(workspace_id, account, jid, 'groupchat')
- def add_chat(self, _action, param): + def _add_chat(self, _action, param): account, jid, type_ = param.unpack() + self.add_chat(account, jid, type_) + + def add_chat(self, account, jid, type_): workspace_id = self._workspace_side_bar.get_active_workspace() self.add_chat_for_workspace(workspace_id, account, jid, type_)
@@ -170,8 +182,11 @@ def add_chat_for_workspace(self, workspace_id, account, jid, type_): self._chat_list_stack.select_chat(workspace_id, account, jid) self._chat_list_stack.store_open_chats(workspace_id)
- def remove_chat(self, _action, param): + def _remove_chat(self, _action, param): workspace_id, account, jid = param.unpack() + self.remove_chat(workspace_id, account, jid) + + def remove_chat(self, workspace_id, account, jid): self._chat_list_stack.remove_chat(workspace_id, account, jid)
def chat_exists(self, account, jid):
===================================== gajim/gtk/start_chat.py ===================================== @@ -296,9 +296,7 @@ def _start_new_chat(self, row):
else: # app.interface.new_chat_from_jid(row.account, row.jid) - app.window.activate_action( - 'add-chat', GLib.Variant('as', - [row.account, row.jid, 'contact'])) + app.window.add_chat(row.account, row.jid, 'contact') self.ready_to_destroy = True self.destroy()
===================================== gajim/gtk/workspace_dialog.py ===================================== @@ -14,7 +14,6 @@
from gi.repository import Gtk from gi.repository import Gdk -from gi.repository import GLib
from gajim.common import app from gajim.common.const import AvatarSize @@ -126,6 +125,5 @@ def _on_save(self, _button): app.settings.set_workspace_setting( workspace_id, 'color', rgba.to_string())
- app.window.activate_action( - 'add-workspace', GLib.Variant('s', workspace_id)) + app.window.add_workspace(workspace_id) self.destroy()
===================================== gajim/gtk/workspace_side_bar.py ===================================== @@ -37,13 +37,12 @@ def _on_button_press(self, _listbox, button_event): row = self.get_row_at_y(button_event.y) WorspaceMenu(row)
- def _on_row_activated(self, _listbox, row): - main_window = self.get_toplevel() + @staticmethod + def _on_row_activated(_listbox, row): if row.workspace_id == 'add': open_window('WorkspaceDialog') else: - main_window.activate_action( - 'activate-workspace', GLib.Variant('s', row.workspace_id)) + app.window.activate_workspace(row.workspace_id)
def add_workspace(self, workspace_id): row = Workspace(workspace_id)
===================================== gajim/gui_interface.py ===================================== @@ -1479,16 +1479,14 @@ def show_add_join_groupchat(self, account, jid, nickname=None): client = app.get_client(account) client.get_module('MUC').join(jid, nick=nickname)
- app.window.activate_action( - 'add-group-chat', GLib.Variant('as', [account, str(jid)])) + app.window.add_group_chat(account, str(jid))
@staticmethod def _on_muc_added(_muc_manger, _signal_name, account, jid): if app.window.chat_exists(account, jid): return
- app.window.activate_action( - 'add-group-chat', GLib.Variant('as', [account, str(jid)])) + app.window.add_group_chat(account, str(jid))
def new_private_chat(self, gc_contact, account, session=None): conn = app.connections[account] @@ -1687,7 +1685,7 @@ def enable_account(self, account): self.instances[account] = { 'infos': {}, 'disco': {}, 'gc_config': {}, 'search': {}, 'sub_request': {}} - self.minimized_controls[account] = {} + app.groups[account] = {} app.contacts.add_account(account) app.gc_connected[account] = {} @@ -1702,14 +1700,9 @@ def enable_account(self, account): app.block_signed_in_notifications[account] = True app.last_message_time[account] = {} # refresh roster - if len(app.connections) >= 2: - # Do not merge accounts if only one exists - self.roster.regroup = app.settings.get('mergeaccounts') - else: - self.roster.regroup = False - self.roster.setup_and_draw_roster() + gui_menu_builder.build_accounts_menu() - self.roster.send_status(account, 'online', '') + app.connections[account].change_status('online', '') app.settings.set_account_setting(account, 'active', True) app.app.update_app_actions_state() window = get_app_window('AccountsWindow') @@ -1717,11 +1710,6 @@ def enable_account(self, account): GLib.idle_add(window.enable_account, account, True)
def disable_account(self, account): - self.roster.close_all(account, force=True) - for jid in self.minimized_controls[account]: - ctrl = self.minimized_controls[account][jid] - ctrl.shutdown() - for win in get_app_windows(account): # Close all account specific windows, except the RemoveAccount # dialog. It shows if the removal was successful. @@ -1734,7 +1722,6 @@ def disable_account(self, account): app.connections[account].cleanup() del app.connections[account] del self.instances[account] - del self.minimized_controls[account] del app.nicks[account] del app.block_signed_in_notifications[account] del app.groups[account] @@ -1744,14 +1731,8 @@ def disable_account(self, account): del app.to_be_removed[account] del app.newly_added[account] del app.last_message_time[account] - if len(app.connections) >= 2: - # Do not merge accounts if only one exists - self.roster.regroup = app.settings.get('mergeaccounts') - else: - self.roster.regroup = False + app.settings.set_account_setting(account, 'roster_version', '') - self.roster.setup_and_draw_roster() - self.roster.update_status_selector() gui_menu_builder.build_accounts_menu() app.settings.set_account_setting(account, 'active', False) app.app.update_app_actions_state() @@ -2176,10 +2157,10 @@ def __init__(self): for account in app.settings.get_accounts(): if (not app.settings.get_account_setting(account, 'is_zeroconf') and app.settings.get_account_setting(account, 'active')): - app.connections[account] = Client(account) - - muc_manager = app.connections[account].get_module('MUC').get_manager() - muc_manager.connect('muc-added', self._on_muc_added) + client = Client(account) + app.connections[account] = client + muc_manager = client.get_module('MUC').get_manager() + muc_manager.connect('muc-added', self._on_muc_added)
self.instances = {}
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/1634ed6e28abf7eb19a908fbe0305d131...