Listen on buddy for icon changes
This commit is contained in:
parent
4fb745e204
commit
d5ff67caa5
@ -583,6 +583,10 @@ class GroupChat(Chat):
|
|||||||
elif action == Group.SERVICE_REMOVED:
|
elif action == Group.SERVICE_REMOVED:
|
||||||
pass
|
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):
|
def _on_group_presence_event(self, action, buddy):
|
||||||
if buddy.get_nick_name() == self._group.get_owner().get_nick_name():
|
if buddy.get_nick_name() == self._group.get_owner().get_nick_name():
|
||||||
# Do not show ourself in the buddy list
|
# Do not show ourself in the buddy list
|
||||||
@ -591,8 +595,8 @@ class GroupChat(Chat):
|
|||||||
aniter = self._buddy_list_model.append(None)
|
aniter = self._buddy_list_model.append(None)
|
||||||
self._buddy_list_model.set(aniter,
|
self._buddy_list_model.set(aniter,
|
||||||
self._MODEL_COL_NICK, buddy.get_nick_name(),
|
self._MODEL_COL_NICK, buddy.get_nick_name(),
|
||||||
self._MODEL_COL_ICON, buddy.get_icon_pixbuf(),
|
|
||||||
self._MODEL_COL_BUDDY, buddy)
|
self._MODEL_COL_BUDDY, buddy)
|
||||||
|
buddy.connect('icon-changed', self.__buddy_icon_changed_cb)
|
||||||
elif action == Group.BUDDY_LEAVE:
|
elif action == Group.BUDDY_LEAVE:
|
||||||
aniter = self._get_iter_for_buddy(buddy)
|
aniter = self._get_iter_for_buddy(buddy)
|
||||||
if aniter:
|
if aniter:
|
||||||
|
@ -3,7 +3,7 @@ import os
|
|||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk, gobject
|
||||||
|
|
||||||
from Service import Service
|
from Service import Service
|
||||||
from sugar import env
|
from sugar import env
|
||||||
@ -20,9 +20,14 @@ def recognize_buddy_service_type(stype):
|
|||||||
def get_recognized_buddy_service_types():
|
def get_recognized_buddy_service_types():
|
||||||
return __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):
|
def __init__(self, service):
|
||||||
|
gobject.GObject.__init__(self)
|
||||||
self._services = {}
|
self._services = {}
|
||||||
self._services[service.get_type()] = service
|
self._services[service.get_type()] = service
|
||||||
self._nick_name = service.get_name()
|
self._nick_name = service.get_name()
|
||||||
@ -70,6 +75,7 @@ class Buddy(object):
|
|||||||
"""Can only set icon for other buddies. The Owner
|
"""Can only set icon for other buddies. The Owner
|
||||||
takes care of setting it's own icon."""
|
takes care of setting it's own icon."""
|
||||||
self._icon = icon
|
self._icon = icon
|
||||||
|
self.emit('icon-changed')
|
||||||
|
|
||||||
|
|
||||||
class Owner(Buddy):
|
class Owner(Buddy):
|
||||||
@ -105,13 +111,3 @@ class Owner(Buddy):
|
|||||||
|
|
||||||
def register(self):
|
def register(self):
|
||||||
self._presence_service.register(self._group)
|
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
|
|
||||||
|
@ -91,10 +91,6 @@ class LocalGroup(Group):
|
|||||||
return self._buddies[name]
|
return self._buddies[name]
|
||||||
return None
|
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):
|
def _add_buddy(self, buddy):
|
||||||
bid = buddy.get_nick_name()
|
bid = buddy.get_nick_name()
|
||||||
if not self._buddies.has_key(bid):
|
if not self._buddies.has_key(bid):
|
||||||
@ -134,7 +130,7 @@ class LocalGroup(Group):
|
|||||||
if key == 'group_address':
|
if key == 'group_address':
|
||||||
service.set_group_address(value)
|
service.set_group_address(value)
|
||||||
|
|
||||||
#print "ServiceResolved: name=%s, stype=%s, port=%s, address=%s" % (name, stype, port, address)
|
# print "ServiceResolved: name=%s, stype=%s, port=%s, address=%s" % (name, stype, port, address)
|
||||||
if stype in get_recognized_buddy_service_types():
|
if stype in get_recognized_buddy_service_types():
|
||||||
# Service recognized as Buddy services either create a new
|
# Service recognized as Buddy services either create a new
|
||||||
# buddy if one doesn't exist yet, or get added to the existing
|
# buddy if one doesn't exist yet, or get added to the existing
|
||||||
|
@ -42,5 +42,3 @@ class Service(object):
|
|||||||
group_address = self._group_address)
|
group_address = self._group_address)
|
||||||
else:
|
else:
|
||||||
pannounce.register_service(self._name, self._port, self._stype)
|
pannounce.register_service(self._name, self._port, self._stype)
|
||||||
# Notify the group that we're registering a new service
|
|
||||||
group.notify_service_registered(self)
|
|
||||||
|
@ -69,7 +69,8 @@ class UnicastStreamWriter(UnicastStreamWriterBase):
|
|||||||
method = getattr(self._writer, method_name)
|
method = getattr(self._writer, method_name)
|
||||||
return method(*args)
|
return method(*args)
|
||||||
except (socket.error, xmlrpclib.Fault, xmlrpclib.ProtocolError):
|
except (socket.error, xmlrpclib.Fault, xmlrpclib.ProtocolError):
|
||||||
traceback.print_exc()
|
pass
|
||||||
|
#traceback.print_exc()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,6 +110,10 @@ class Activity(dbus.service.Object):
|
|||||||
scaled_pixbuf = pixbuf.scale_simple(16, 16, gtk.gdk.INTERP_BILINEAR)
|
scaled_pixbuf = pixbuf.scale_simple(16, 16, gtk.gdk.INTERP_BILINEAR)
|
||||||
self.activity_set_icon(scaled_pixbuf)
|
self.activity_set_icon(scaled_pixbuf)
|
||||||
|
|
||||||
|
@dbus.service.method("com.redhat.Sugar.Activity", \
|
||||||
|
in_signature="", \
|
||||||
|
out_signature="")
|
||||||
|
|
||||||
def lost_focus(self):
|
def lost_focus(self):
|
||||||
self.activity_on_lost_focus()
|
self.activity_on_lost_focus()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user