From d3eb18175813e2e6ce68812c8959accbebbf768f Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Wed, 8 Apr 2009 07:55:52 +0000
Subject: [PATCH] don't expand big brother when we get a message in a
 metacontact. Fixes #4867

---
 src/gajim.py         | 11 +++++++++--
 src/roster_window.py |  3 ++-
 src/session.py       | 12 ++++++++++--
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/gajim.py b/src/gajim.py
index 20912859bb..b1ed0a9be7 100644
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -2357,8 +2357,15 @@ class Interface:
 			else:
 				self.roster.draw_contact(jid, account)
 
-		# Select the contact in roster, it's visible because it has events.
-		self.roster.select_contact(jid, account)
+		# Select the big brother contact in roster, it's visible because it has
+		# events.
+		family = gajim.contacts.get_metacontacts_family(account, jid)
+		if family:
+			nearby_family, bb_jid, bb_account = \
+				self.roster._get_nearby_family_and_big_brother(family, account)
+		else:
+			bb_jid, bb_account = jid, account
+		self.roster.select_contact(bb_jid, bb_account)
 
 	def handle_event(self, account, fjid, type_):
 		w = None
diff --git a/src/roster_window.py b/src/roster_window.py
index 4b4376700d..f466af4640 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -1374,7 +1374,8 @@ class RosterWindow:
 		if self.dragging or not gajim.config.get('scroll_roster_to_last_message'):
 			# do not change selection while DND'ing
 			return
-		self.tree.expand_to_path(path)
+		# Expand his parent, so this path is visible, don't expand it.
+		self.tree.expand_to_path(path[:-1])
 		self.tree.scroll_to_cell(path)
 		self.tree.set_cursor(path)
 
diff --git a/src/session.py b/src/session.py
index 313f1068bb..93fbf23759 100644
--- a/src/session.py
+++ b/src/session.py
@@ -365,8 +365,16 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
 				gajim.interface.roster.draw_contact(jid, self.conn.name)
 
 			gajim.interface.roster.show_title() # we show the * or [n]
-		# Select contact row in roster.
-		gajim.interface.roster.select_contact(jid, self.conn.name)
+		# Select the big brother contact in roster, it's visible because it has
+		# events.
+		family = gajim.contacts.get_metacontacts_family(self.conn.name, jid)
+		if family:
+			nearby_family, bb_jid, bb_account = \
+				gajim.interface.roster._get_nearby_family_and_big_brother(family,
+				self.conn.name)
+		else:
+			bb_jid, bb_account = jid, self.conn.name
+		gajim.interface.roster.select_contact(bb_jid, bb_account)
 
 	# ---- ESessions stuff ---
 
-- 
GitLab