From d213eada769f337bf0f538b1d670c0ab97caec54 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 22 May 2006 17:59:42 -0400 Subject: [PATCH] Change tab label color when there are --- sugar/chat/chat.py | 13 +++++++++++-- sugar/shell/activity.py | 24 +++++++++++++++++------- sugar/shell/shell.py | 12 ++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/sugar/chat/chat.py b/sugar/chat/chat.py index 6e246eac..514c47a4 100755 --- a/sugar/chat/chat.py +++ b/sugar/chat/chat.py @@ -271,10 +271,15 @@ class Chat(activity.Activity): self.activity_shutdown() def activity_on_lost_focus(self): - print "act %d: in activity_on_lost_focus" % self.activity_get_id() + activity.Activity.activity_on_lost_focus() def activity_on_got_focus(self): - print "act %d: in activity_on_got_focus" % self.activity_get_id() + activity.Activity.activity_on_got_focus() + self.activity_set_has_changes(False) + + def _message_inserted(self): + if not self.get_has_focus(): + self.activity_set_has_changes(True) def _insert_buddy(self, buf, nick): buddy = self._controller.get_group().get_buddy(nick) @@ -286,6 +291,8 @@ 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) @@ -299,6 +306,8 @@ class Chat(activity.Activity): aniter = buf.get_end_iter() buf.insert(aniter, "\n") + + self._message_inserted() def _insert_sketch(self, nick, svgdata): """Insert a sketch object into the chat buffer.""" diff --git a/sugar/shell/activity.py b/sugar/shell/activity.py index f7e59093..e0f26d19 100644 --- a/sugar/shell/activity.py +++ b/sugar/shell/activity.py @@ -12,7 +12,10 @@ class Activity(dbus.service.Object): """ Base Sugar activity object from which all other Activities should inherit """ def __init__(self): - pass + self._has_focus = False + + def get_has_focus(self): + return self._has_focus def name_owner_changed(self, service_name, old_service_name, new_service_name): #print "in name_owner_changed: svc=%s oldsvc=%s newsvc=%s"%(service_name, old_service_name, new_service_name) @@ -102,6 +105,13 @@ class Activity(dbus.service.Object): in_signature="", \ out_signature="") + def activity_set_has_changes(self, has_changes): + self.__activity_object.set_has_changes(has_changes) + + @dbus.service.method("com.redhat.Sugar.Activity", \ + in_signature="", \ + out_signature="") + def activity_set_tab_icon_name(self, icon_name): icon_theme = gtk.icon_theme_get_default() icon_info = icon_theme.lookup_icon(icon_name, gtk.ICON_SIZE_MENU, 0) @@ -161,6 +171,12 @@ class Activity(dbus.service.Object): def activity_shutdown(self): self.__activity_object.shutdown(reply_handler = self.__shutdown_reply_cb, error_handler = self.__shutdown_error_cb) + def activity_on_lost_focus(self): + self._has_focus = False; + + def activity_on_got_focus(self): + self._has_focus = True + # pure virtual methods def activity_on_connected_to_shell(self): @@ -171,9 +187,3 @@ class Activity(dbus.service.Object): def activity_on_close_from_user(self): print "act %d: you need to override activity_on_close_from_user" % self.activity_get_id() - - def activity_on_lost_focus(self): - print "act %d: you need to override activity_on_lost_focus" % self.activity_get_id() - - def activity_on_got_focus(self): - print "act %d: you need to override activity_on_got_focus" % self.activity_get_id() diff --git a/sugar/shell/shell.py b/sugar/shell/shell.py index 394efde4..0b9aea1a 100755 --- a/sugar/shell/shell.py +++ b/sugar/shell/shell.py @@ -130,6 +130,18 @@ class ActivityHost(dbus.service.Object): else: self.tab_activity_image.hide() + @dbus.service.method("com.redhat.Sugar.Shell.ActivityHost", \ + in_signature="b", \ + out_signature="") + def set_has_changes(self, has_changes): + if has_changes: + attrs = pango.AttrList() + attrs.insert(pango.AttrForeground(65535, 0, 0, 0, -1)) + attrs.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)) + self.tab_label.set_attributes(attrs) + else: + self.tab_label.set_attributes(pango.AttrList()) + @dbus.service.method("com.redhat.Sugar.Shell.ActivityHost", \ in_signature="s", \ out_signature="")