bugfix: clean self.plugin.windows on destroy, not delete-event (delete-event is not always called)

This commit is contained in:
Yann Leboulanger 2005-03-07 16:50:26 +00:00
parent 1de83250e5
commit 6ad614ccd6
2 changed files with 12 additions and 2 deletions

View File

@ -7013,6 +7013,7 @@ Custom</property>
<signal name="focus_in_event" handler="on_groupchat_window_focus_in_event" last_modification_time="Sat, 05 Mar 2005 00:34:51 GMT"/>
<signal name="key_press_event" handler="on_groupchat_window_key_press_event" last_modification_time="Sat, 05 Mar 2005 10:57:33 GMT"/>
<signal name="delete_event" handler="on_groupchat_window_delete_event" last_modification_time="Mon, 07 Mar 2005 11:19:05 GMT"/>
<signal name="destroy" handler="on_groupchat_window_destroy" last_modification_time="Mon, 07 Mar 2005 16:46:37 GMT"/>
<child>
<widget class="GtkVBox" id="vbox27">
@ -8108,6 +8109,7 @@ Custom</property>
<signal name="focus_in_event" handler="on_tabbed_chat_window_focus_in_event" last_modification_time="Wed, 02 Mar 2005 17:57:33 GMT"/>
<signal name="key_press_event" handler="on_tabbed_chat_window_key_press_event" last_modification_time="Wed, 02 Mar 2005 17:59:50 GMT"/>
<signal name="delete_event" handler="on_tabbed_chat_window_delete_event" last_modification_time="Mon, 07 Mar 2005 11:06:00 GMT"/>
<signal name="destroy" handler="on_tabbed_chat_window_destroy" last_modification_time="Mon, 07 Mar 2005 16:35:25 GMT"/>
<child>
<widget class="GtkNotebook" id="chat_notebook">

View File

@ -215,6 +215,8 @@ class tabbed_chat_window:
self.window = self.xml.get_widget('tabbed_chat_window')
self.new_user(user)
self.show_title()
self.xml.signal_connect('on_tabbed_chat_window_destroy', \
self.on_tabbed_chat_window_destroy)
self.xml.signal_connect('on_tabbed_chat_window_delete_event', \
self.on_tabbed_chat_window_delete_event)
self.xml.signal_connect('on_tabbed_chat_window_focus_in_event', \
@ -284,12 +286,14 @@ class tabbed_chat_window:
def on_tabbed_chat_window_delete_event(self, widget, event):
"""close window"""
#clean self.plugin.windows[self.account]['chats']
for jid in self.users:
if time.time() - self.last_message_time[jid] < 2:
dialog = Confirmation_dialog(_('You received a message from %s in the last two secondes.\nDo you still want to close this window ?') % jid)
if dialog.get_response() != gtk.RESPONSE_YES:
return True #stop the propagation of the event
def on_tabbed_chat_window_destroy(self, widget):
#clean self.plugin.windows[self.account]['chats']
for jid in self.users:
del self.plugin.windows[self.account]['chats'][jid]
if self.plugin.windows[self.account]['chats'].has_key('tabbed'):
@ -620,7 +624,7 @@ class tabbed_chat_window:
self.show_title()
class Groupchat_window:
def on_groupchat_window_delete_event(self, widget):
def on_groupchat_window_delete_event(self, widget, event):
"""close window"""
for room_jid in self.xmls:
if time.time() - self.last_message_time[room_jid] < 2:
@ -628,6 +632,8 @@ class Groupchat_window:
room_jid.split('@')[0])
if dialog.get_response() != gtk.RESPONSE_YES:
return True #stop the propagation of the event
def on_groupchat_window_destroy(self, widget):
for room_jid in self.xmls:
self.plugin.send('GC_STATUS', self.account, (self.nicks[room_jid], \
room_jid, 'offline', 'offline'))
@ -1255,6 +1261,8 @@ class Groupchat_window:
self.window = self.xml.get_widget('groupchat_window')
self.new_group(room_jid, nick)
self.show_title()
self.xml.signal_connect('on_groupchat_window_destroy', \
self.on_groupchat_window_destroy)
self.xml.signal_connect('on_groupchat_window_delete_event', \
self.on_groupchat_window_delete_event)
self.xml.signal_connect('on_groupchat_window_focus_in_event', \