Change tab label color when there are

This commit is contained in:
Marco Pesenti Gritti 2006-05-22 17:59:42 -04:00
parent a6b1307eb4
commit d213eada76
3 changed files with 40 additions and 9 deletions

View File

@ -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."""

View File

@ -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()

View File

@ -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="")