From 4bedeec964c4d3c1639e42d5631911787eea9aac Mon Sep 17 00:00:00 2001
From: Travis Shirk <travis@pobox.com>
Date: Thu, 20 Dec 2007 03:40:27 +0000
Subject: [PATCH] MessageWindow reconfig bug fixes for deleted roster

---
 src/chat_control.py   |  2 +-
 src/message_window.py | 24 ++++++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/chat_control.py b/src/chat_control.py
index 3474895a4a..6459e4fa15 100644
--- a/src/chat_control.py
+++ b/src/chat_control.py
@@ -643,7 +643,7 @@ class ChatControlBase(MessageControl):
 		self.orig_msg = None
 
 	def print_conversation_line(self, text, kind, name, tim,
-		other_tags_for_name = [], other_tags_for_time = [], 
+		other_tags_for_name = [], other_tags_for_time = [],
 		other_tags_for_text = [], count_as_new = True,
 		subject = None, old_kind = None, xhtml = None):
 		'''prints 'chat' type messages'''
diff --git a/src/message_window.py b/src/message_window.py
index a1ed6b658f..c1eaf8fc6d 100644
--- a/src/message_window.py
+++ b/src/message_window.py
@@ -238,7 +238,10 @@ class MessageWindow(object):
 			self.setup_tab_dnd(control.widget)
 
 		self.redraw_tab(control)
-		self.notebook.show_all()
+		if self.parent_paned:
+			self.notebook.show_all()
+		else:
+			self.window.show_all()
 		# NOTE: we do not call set_control_active(True) since we don't know whether
 		# the tab is the active one.
 		self.show_title()
@@ -437,7 +440,6 @@ class MessageWindow(object):
 				# Don't close parent window, just remove the child
 				child = self.parent_paned.get_child2()
 				self.parent_paned.remove(child)
-				# FIXME: restore preferred roster size
 			else:
 				self.window.destroy()
 			return # don't show_title, we are dead
@@ -925,8 +927,10 @@ class MessageWindowMgr(gobject.GObject):
 	def shutdown(self, width_adjust=0):
 		for w in self.windows():
 			self.save_state(w, width_adjust)
-			w.window.hide()
-			w.window.destroy()
+			if not w.parent_paned:
+				w.window.hide()
+				w.window.destroy()
+
 		gajim.interface.save_config()
 
 	def save_state(self, msg_win, width_adjust=0):
@@ -993,7 +997,10 @@ class MessageWindowMgr(gobject.GObject):
 
 		controls = []
 		for w in self.windows():
-			w.window.hide()
+			# Note, we are taking care not to hide/delete the roster window when the
+			# MessageWindow is embedded.
+			if not w.parent_paned:
+				w.window.hide()
 			while w.notebook.get_n_pages():
 				page = w.notebook.get_nth_page(0)
 				ctrl = w._widget_to_control(page)
@@ -1002,7 +1009,12 @@ class MessageWindowMgr(gobject.GObject):
 				controls.append(ctrl)
 			# Must clear _controls from window to prevent MessageControl.shutdown calls
 			w._controls = {}
-			w.window.destroy()
+			if not w.parent_paned:
+				w.window.destroy()
+			else:
+				# Don't close parent window, just remove the child
+				child = w.parent_paned.get_child2()
+				w.parent_paned.remove(child)
 
 		self._windows = {}
 
-- 
GitLab