Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYann Leboulanger <asterix@lagaule.org>2008-08-08 21:03:56 +0400
committerYann Leboulanger <asterix@lagaule.org>2008-08-08 21:03:56 +0400
commitf5059b4e26fdff14df9474a2768f2c98bb342c4c (patch)
treee8bc6cf105263c8bdf7365a026c725bfdf9b663b /src
parent5fbea471304eb90717126a75b7ccf1ef84d8e150 (diff)
fix closing a tab
Diffstat (limited to 'src')
-rw-r--r--src/message_window.py74
1 files changed, 42 insertions, 32 deletions
diff --git a/src/message_window.py b/src/message_window.py
index 50fbdc321..e6f5d0480 100644
--- a/src/message_window.py
+++ b/src/message_window.py
@@ -439,46 +439,56 @@ 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
- 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()
+ 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'])
- # 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)
- 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]
- 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)
- # 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))
- self.notebook.remove_page(self.notebook.page_num(ctrl.widget))
+ del self._controls[ctrl.account][fjid]
- del self._controls[ctrl.account][fjid]
+ if len(self._controls[ctrl.account]) == 0:
+ del self._controls[ctrl.account]
- if len(self._controls[ctrl.account]) == 0:
- del self._controls[ctrl.account]
+ self.check_tabs()
+ self.show_title()
- 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: