Listen on buddy for icon changes

This commit is contained in:
Marco Pesenti Gritti 2006-05-22 16:35:31 -04:00
parent 4fb745e204
commit d5ff67caa5
6 changed files with 21 additions and 22 deletions

View File

@ -583,6 +583,10 @@ class GroupChat(Chat):
elif action == Group.SERVICE_REMOVED:
pass
def __buddy_icon_changed_cb(self, buddy):
it = self._get_iter_for_buddy(buddy)
self._buddy_list_model.set(it, self._MODEL_COL_ICON, buddy.get_icon_pixbuf())
def _on_group_presence_event(self, action, buddy):
if buddy.get_nick_name() == self._group.get_owner().get_nick_name():
# Do not show ourself in the buddy list
@ -591,8 +595,8 @@ class GroupChat(Chat):
aniter = self._buddy_list_model.append(None)
self._buddy_list_model.set(aniter,
self._MODEL_COL_NICK, buddy.get_nick_name(),
self._MODEL_COL_ICON, buddy.get_icon_pixbuf(),
self._MODEL_COL_BUDDY, buddy)
buddy.connect('icon-changed', self.__buddy_icon_changed_cb)
elif action == Group.BUDDY_LEAVE:
aniter = self._get_iter_for_buddy(buddy)
if aniter:

View File

@ -3,7 +3,7 @@ import os
import pygtk
pygtk.require('2.0')
import gtk
import gtk, gobject
from Service import Service
from sugar import env
@ -20,9 +20,14 @@ def recognize_buddy_service_type(stype):
def get_recognized_buddy_service_types():
return __buddy_service_types[:]
class Buddy(gobject.GObject):
__gsignals__ = {
'icon-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([]))
}
class Buddy(object):
def __init__(self, service):
gobject.GObject.__init__(self)
self._services = {}
self._services[service.get_type()] = service
self._nick_name = service.get_name()
@ -70,6 +75,7 @@ class Buddy(object):
"""Can only set icon for other buddies. The Owner
takes care of setting it's own icon."""
self._icon = icon
self.emit('icon-changed')
class Owner(Buddy):
@ -105,13 +111,3 @@ class Owner(Buddy):
def register(self):
self._presence_service.register(self._group)
def notify_service_registered(self, service):
"""New services registered in our group are automatically owned
by us."""
self._services[service.get_type()] = service
def add_service(self, service):
"""Do nothing here, since all services we need to know about
are registered with us by our group."""
pass

View File

@ -91,10 +91,6 @@ class LocalGroup(Group):
return self._buddies[name]
return None
def notify_service_registered(self, service):
"""A new service is automatically owned by the owner of this group."""
self._owner.notify_service_registered(service)
def _add_buddy(self, buddy):
bid = buddy.get_nick_name()
if not self._buddies.has_key(bid):

View File

@ -42,5 +42,3 @@ class Service(object):
group_address = self._group_address)
else:
pannounce.register_service(self._name, self._port, self._stype)
# Notify the group that we're registering a new service
group.notify_service_registered(self)

View File

@ -69,7 +69,8 @@ class UnicastStreamWriter(UnicastStreamWriterBase):
method = getattr(self._writer, method_name)
return method(*args)
except (socket.error, xmlrpclib.Fault, xmlrpclib.ProtocolError):
traceback.print_exc()
pass
#traceback.print_exc()
return None

View File

@ -110,6 +110,10 @@ class Activity(dbus.service.Object):
scaled_pixbuf = pixbuf.scale_simple(16, 16, gtk.gdk.INTERP_BILINEAR)
self.activity_set_icon(scaled_pixbuf)
@dbus.service.method("com.redhat.Sugar.Activity", \
in_signature="", \
out_signature="")
def lost_focus(self):
self.activity_on_lost_focus()