diff --git a/src/common/gajim.py b/src/common/gajim.py index 0b60765c8..0f176b1bd 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -213,6 +213,8 @@ def get_number_of_connected_accounts(accounts_list = None): return connected_accounts def account_is_connected(account): + if account not in connections: + return False if connections[account].connected > 1: # 0 is offline, 1 is connecting return True else: diff --git a/src/config.py b/src/config.py index 2d6dc676b..48aba7ab2 100644 --- a/src/config.py +++ b/src/config.py @@ -2358,7 +2358,7 @@ class RemoveAccountWindow: if not res: return # Close all opened windows - gajim.interface.roster.close_all(self.account) + gajim.interface.roster.close_all(self.account, force = True) gajim.connections[self.account].disconnect(on_purpose = True) del gajim.connections[self.account] gajim.config.del_per('accounts', self.account) diff --git a/src/message_window.py b/src/message_window.py index 94598896e..73faa6112 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -279,10 +279,11 @@ class MessageWindow: ctrl_page = self.notebook.page_num(ctrl.widget) self.notebook.set_current_page(ctrl_page) - def remove_tab(self, ctrl, reason = None): - '''reason is only for gc (offline status message)''' + def remove_tab(self, ctrl, reason = None, force = False): + '''reason is only for gc (offline status message) + if force is True, do not ask any confirmation''' # Shutdown the MessageControl - if not ctrl.allow_shutdown(): + if not force and not ctrl.allow_shutdown(): return if reason is not None: # We are leaving gc with a status message ctrl.shutdown(reason) diff --git a/src/roster_window.py b/src/roster_window.py index 9d38746aa..b2268e921 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2717,11 +2717,13 @@ _('If "%s" accepts this request you will know his or her status.') % jid) else: w.window.destroy() - def close_all(self, account): - '''close all the windows from an account''' + def close_all(self, account, force = False): + '''close all the windows from an account + if force is True, do not ask confirmation before closing chat/gc windows + ''' self.close_all_from_dict(gajim.interface.instances[account]) for ctrl in gajim.interface.msg_win_mgr.get_controls(acct = account): - ctrl.parent_win.remove_tab(ctrl) + ctrl.parent_win.remove_tab(ctrl, force = force) def on_roster_window_delete_event(self, widget, event): '''When we want to close the window'''