From bbeced56e523a934f1e2494de67bbf82e0f93d54 Mon Sep 17 00:00:00 2001
From: Marco Pesenti Gritti <mpg@redhat.com>
Date: Mon, 22 May 2006 23:08:41 -0400
Subject: [PATCH] Finish up chat notification, there are races but it seem

---
 sugar/chat/chat.py      | 8 ++++----
 sugar/shell/activity.py | 3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/sugar/chat/chat.py b/sugar/chat/chat.py
index 514c47a4..c9e642e8 100755
--- a/sugar/chat/chat.py
+++ b/sugar/chat/chat.py
@@ -271,10 +271,10 @@ class Chat(activity.Activity):
 		self.activity_shutdown()
 
 	def activity_on_lost_focus(self):
-		activity.Activity.activity_on_lost_focus()
+		activity.Activity.activity_on_lost_focus(self)
 
 	def activity_on_got_focus(self):
-		activity.Activity.activity_on_got_focus()
+		activity.Activity.activity_on_got_focus(self)
 		self.activity_set_has_changes(False)
 
 	def _message_inserted(self):
@@ -292,8 +292,6 @@ class Chat(activity.Activity):
 		aniter = buf.get_end_iter()
 		buf.insert(aniter, nick + ": ")
 		
-		self._message_inserted()
-
 	def _insert_rich_message(self, nick, msg):
 		msg = Emoticons.get_instance().replace(msg)
 	
@@ -325,6 +323,8 @@ class Chat(activity.Activity):
 		aniter = buf.get_end_iter()
 		buf.insert(aniter, "\n")
 
+		self._message_inserted()
+
 	def _get_first_richtext_chunk(self, msg):
 		"""Scan the message for the first richtext-tagged chunk and return it."""
 		rt_last = -1
diff --git a/sugar/shell/activity.py b/sugar/shell/activity.py
index e0f26d19..3b84bf52 100644
--- a/sugar/shell/activity.py
+++ b/sugar/shell/activity.py
@@ -12,7 +12,7 @@ class Activity(dbus.service.Object):
 	""" Base Sugar activity object from which all other Activities should inherit """
 
 	def __init__(self):
-		self._has_focus = False
+		self._has_focus = True
 		
 	def get_has_focus(self):
 		return self._has_focus
@@ -133,7 +133,6 @@ class Activity(dbus.service.Object):
 	def got_focus(self):
 		self.activity_on_got_focus()
 
-
 	@dbus.service.method("com.redhat.Sugar.Activity", \
 						 in_signature="", \
 						 out_signature="")