From f094f65bd2649552c04c400992fbf8aac2c48f84 Mon Sep 17 00:00:00 2001
From: Nikos Kouremenos <kourem@gmail.com>
Date: Tue, 19 Jul 2005 17:08:01 +0000
Subject: [PATCH] send gone chatstate to every tab when closing a window with
 many tabs

---
 src/chat.py               | 10 +++++++---
 src/tabbed_chat_window.py |  6 +++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/chat.py b/src/chat.py
index 6f51ef715c..15b5b91cd8 100644
--- a/src/chat.py
+++ b/src/chat.py
@@ -141,13 +141,17 @@ class Chat:
 	def on_window_destroy(self, widget, kind): #kind is 'chats' or 'gc'
 		#clean self.plugin.windows[self.account][kind]
 		for jid in self.xmls:
+			windows = self.plugin.windows[self.account][kind]
+			if kind == 'chats':
+				# send 'gone' chatstate to every tabbed chat tab
+				windows[jid].send_chatstate('gone')
 			if self.plugin.systray_enabled and self.nb_unread[jid] > 0:
 				self.plugin.systray.remove_jid(jid, self.account)
-			del self.plugin.windows[self.account][kind][jid]
+			del windows[jid]
 			if self.print_time_timeout_id.has_key(jid):
 				gobject.source_remove(self.print_time_timeout_id[jid])
-		if self.plugin.windows[self.account][kind].has_key('tabbed'):
-			del self.plugin.windows[self.account][kind]['tabbed']
+		if windows.has_key('tabbed'):
+			del windows['tabbed']
 
 	def get_active_jid(self):
 		notebook = self.notebook
diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py
index 957c205d62..a34699e02b 100644
--- a/src/tabbed_chat_window.py
+++ b/src/tabbed_chat_window.py
@@ -209,8 +209,6 @@ class TabbedChatWindow(chat.Chat):
 			gajim.config.set('chat-height', height)
 
 	def on_tabbed_chat_window_destroy(self, widget):
-		# on window destroy, send 'gone' chatstate
-		self.send_chatstate('gone') # FIXME: loop to each tab and send that
 		#clean self.plugin.windows[self.account]['chats']
 		chat.Chat.on_window_destroy(self, widget, 'chats')
 
@@ -360,8 +358,10 @@ class TabbedChatWindow(chat.Chat):
 			self.send_chatstate('composing')
 
 	def send_chatstate(self, state):
+		''' sends our chatstate to the current tab '''
 		# please read jep-85 to get an idea of this
-		# we keep track of jep85 support by the peer by three extra states: None, -1 and 'ask'
+		# we keep track of jep85 support by the peer by three extra states:
+		# None, -1 and 'ask'
 		# None if no info about peer
 		# -1 if peer does not support jep85
 		# 'ask' if we sent 'active' chatstate and are waiting for reply
-- 
GitLab