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,46 +439,56 @@ class MessageWindow(object):
def remove_tab(self, ctrl, method, reason = None, force = False): def remove_tab(self, ctrl, method, reason = None, force = False):
'''reason is only for gc (offline status message) '''reason is only for gc (offline status message)
if force is True, do not ask any confirmation''' if force is True, do not ask any confirmation'''
# Shutdown the MessageControl def close(ctrl):
allow_shutdown = ctrl.allow_shutdown(method) if reason is not None: # We are leaving gc with a status message
if not force and allow_shutdown == 'no': ctrl.shutdown(reason)
return else: # We are leaving gc without status message or it's a chat
if allow_shutdown == 'minimize' and method != self.CLOSE_COMMAND: ctrl.shutdown()
ctrl.minimize() # Update external state
gajim.events.remove_events(ctrl.account, ctrl.get_full_jid,
types = ['printed_msg', 'chat', 'gc_msg'])
fjid = ctrl.get_full_jid()
jid = gajim.get_jid_without_resource(fjid)
fctrl = self.get_control(fjid, ctrl.account)
bctrl = self.get_control(jid, ctrl.account)
# keep last_message_time around unless this was our last control with
# that jid
if not fctrl and not bctrl:
del gajim.last_message_time[ctrl.account][fjid]
# Disconnect tab DnD only if GTK version < 2.10
if gtk.pygtk_version < (2, 10, 0) or gtk.gtk_version < (2, 10, 0):
self.disconnect_tab_dnd(ctrl.widget)
self.notebook.remove_page(self.notebook.page_num(ctrl.widget))
del self._controls[ctrl.account][fjid]
if len(self._controls[ctrl.account]) == 0:
del self._controls[ctrl.account]
self.check_tabs() self.check_tabs()
return self.show_title()
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 def on_yes(ctrl):
gajim.events.remove_events(ctrl.account, ctrl.get_full_jid, close(ctrl)
types = ['printed_msg', 'chat', 'gc_msg'])
fjid = ctrl.get_full_jid() def on_no(ctrl):
jid = gajim.get_jid_without_resource(fjid) if not force:
return
close(ctrl)
fctrl = self.get_control(fjid, ctrl.account) def on_minimize(ctrl):
bctrl = self.get_control(jid, ctrl.account) if method != self.CLOSE_COMMAND:
# keep last_message_time around unless this was our last control with ctrl.minimize()
# that jid self.check_tabs()
if not fctrl and not bctrl: return
del gajim.last_message_time[ctrl.account][fjid] close(ctrl)
# Disconnect tab DnD only if GTK version < 2.10 # Shutdown the MessageControl
if gtk.pygtk_version < (2, 10, 0) or gtk.gtk_version < (2, 10, 0): ctrl.allow_shutdown(method, on_yes, on_no, on_minimize)
self.disconnect_tab_dnd(ctrl.widget)
self.notebook.remove_page(self.notebook.page_num(ctrl.widget))
del self._controls[ctrl.account][fjid]
if len(self._controls[ctrl.account]) == 0:
del self._controls[ctrl.account]
self.check_tabs()
self.show_title()
def check_tabs(self): def check_tabs(self):
if self.get_num_controls() == 0: if self.get_num_controls() == 0: