From 34ff33e4c191fddd79239dd0b3ed4d70ac549b7a Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 19 Sep 2006 09:15:26 +0000 Subject: [PATCH] Prevent user that removing an account closes all chat / gc windows. Fixes #2370 --- src/config.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/config.py b/src/config.py index a2627e557..958eb7355 100644 --- a/src/config.py +++ b/src/config.py @@ -1798,11 +1798,33 @@ class AccountsWindow: dialogs.ErrorDialog(_('Unread events'), _('Read all pending events before removing this account.')) return - if gajim.interface.instances[account].has_key('remove_account'): - gajim.interface.instances[account]['remove_account'].window.present() + win_opened = False + if gajim.interface.msg_win_mgr.get_controls(acct = account): + win_opened = True else: - gajim.interface.instances[account]['remove_account'] = \ - RemoveAccountWindow(account) + for key in gajim.interface.instances[account]: + if gajim.interface.instances[account][key]: + win_opened = True + break + # Detect if we have opened windows for this account + self.dialog = None + def remove(widget, account): + if self.dialog: + self.dialog.destroy() + if gajim.interface.instances[account].has_key('remove_account'): + gajim.interface.instances[account]['remove_account'].window.\ + present() + else: + gajim.interface.instances[account]['remove_account'] = \ + RemoveAccountWindow(account) + if win_opened: + self.dialog = dialogs.ConfirmationDialog( + _('You have opened chat in account %s') % account, + _('All chat and groupchat windows will be closed. Do you want to ' + 'continue?'), + on_response_ok = (remove, account)) + else: + remove(widget, account) def on_modify_button_clicked(self, widget): '''When modify button is clicked: