diff --git a/src/common/commands.py b/src/common/commands.py index 1269f4963..4cb43bef5 100644 --- a/src/common/commands.py +++ b/src/common/commands.py @@ -158,7 +158,8 @@ def find_current_groupchats(account): import message_control rooms = [] for gc_control in gajim.interface.msg_win_mgr.get_controls( - message_control.TYPE_GC): + message_control.TYPE_GC) + gajim.interface.minimized_controls[account].\ + values(): acct = gc_control.account # check if account is the good one if acct != account: @@ -224,8 +225,7 @@ class LeaveGroupchatsCommand(AdHocCommand): try: gc = form['groupchats'].values - except: # KeyError if there's no presence-type field in form or - # AttributeError if that field is of wrong type + except: # KeyError if there's no groupchats in form self.badRequest(request) return False account = self.connection.name @@ -233,8 +233,14 @@ class LeaveGroupchatsCommand(AdHocCommand): for room_jid in gc: gc_control = gajim.interface.msg_win_mgr.get_gc_control(room_jid, account) + if not gc_control: + gc_control = gajim.interface.minimized_controls[account]\ + [room_jid] + gc_control.shutdown() + gajim.interface.roster.remove_groupchat(room_jid, account) + continue gc_control.parent_win.remove_tab(gc_control, None, force = True) - except: # KeyError if there's no presence-type field in form or + except: # KeyError if there's no such room opened self.badRequest(request) return False response, cmd = self.buildResponse(request, status = 'completed') diff --git a/src/message_window.py b/src/message_window.py index d9074125e..61d982e61 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -514,8 +514,6 @@ class MessageWindow(object): close(ctrl) def on_no(ctrl): - if not force: - return close(ctrl) def on_minimize(ctrl): @@ -526,7 +524,10 @@ class MessageWindow(object): close(ctrl) # Shutdown the MessageControl - ctrl.allow_shutdown(method, on_yes, on_no, on_minimize) + if force: + close(ctrl) + else: + ctrl.allow_shutdown(method, on_yes, on_no, on_minimize) def check_tabs(self): if self.get_num_controls() == 0: