fix closing a tab

This commit is contained in:
Yann Leboulanger 2008-08-08 17:03:56 +00:00
parent 5fbea47130
commit f5059b4e26
1 changed files with 45 additions and 35 deletions

View File

@ -439,19 +439,11 @@ class MessageWindow(object):
def remove_tab(self, ctrl, method, reason = None, force = False):
'''reason is only for gc (offline status message)
if force is True, do not ask any confirmation'''
# Shutdown the MessageControl
allow_shutdown = ctrl.allow_shutdown(method)
if not force and allow_shutdown == 'no':
return
if allow_shutdown == 'minimize' and method != self.CLOSE_COMMAND:
ctrl.minimize()
self.check_tabs()
return
def close(ctrl):
if reason is not None: # We are leaving gc with a status message
ctrl.shutdown(reason)
else: # We are leaving gc without status message or it's a chat
ctrl.shutdown()
# Update external state
gajim.events.remove_events(ctrl.account, ctrl.get_full_jid,
types = ['printed_msg', 'chat', 'gc_msg'])
@ -480,6 +472,24 @@ class MessageWindow(object):
self.check_tabs()
self.show_title()
def on_yes(ctrl):
close(ctrl)
def on_no(ctrl):
if not force:
return
close(ctrl)
def on_minimize(ctrl):
if method != self.CLOSE_COMMAND:
ctrl.minimize()
self.check_tabs()
return
close(ctrl)
# Shutdown the MessageControl
ctrl.allow_shutdown(method, on_yes, on_no, on_minimize)
def check_tabs(self):
if self.get_num_controls() == 0:
# These are not called when the window is destroyed like this, fake it