Use the actual buddy color

This commit is contained in:
Marco Pesenti Gritti 2006-08-25 00:49:39 +02:00
parent 9e970b5b0f
commit 05061c5e3d
4 changed files with 12 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import base64
from sugar import env
from sugar.p2p import Stream
from sugar.presence import PresenceService
from sugar import conf
PRESENCE_SERVICE_TYPE = "_presence_olpc._tcp"
@ -29,7 +30,8 @@ class ShellOwner(object):
def announce(self):
# Create and announce our presence
props = { 'color': "#deadbe" }
color = conf.get_profile().get_color()
props = { 'color': color.get_fill_color() }
self._service = self._pservice.register_service(self._nick,
PRESENCE_SERVICE_TYPE, properties=props)
print "Owner '%s' using port %d" % (self._nick, self._service.get_port())

View File

@ -1,6 +1,7 @@
import gobject
from sugar.presence import PresenceService
from sugar.canvas.IconColor import IconColor
class Friend:
def __init__(self, buddy):
@ -9,6 +10,10 @@ class Friend:
def get_name(self):
return self._buddy.get_name()
def get_color(self):
color = self._buddy.get_color()
return IconColor(color)
class FriendsModel(gobject.GObject):
__gsignals__ = {
'friend-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,

View File

@ -3,7 +3,6 @@ import random
import goocanvas
from sugar.canvas.IconItem import IconItem
from sugar.canvas.IconColor import IconColor
import Theme
@ -48,7 +47,7 @@ class Model(goocanvas.CanvasModelSimple):
def add_friend(self, friend):
root = self.get_root_item()
icon = IconItem('stock-buddy', IconColor(), 48)
icon = IconItem('stock-buddy', friend.get_color(), 48)
icon.set_property('x', random.random() * 1100)
icon.set_property('y', random.random() * 800)

View File

@ -7,6 +7,7 @@ from sugar.canvas.IconColor import IconColor
from sugar.canvas.DonutItem import DonutItem
from sugar.canvas.DonutItem import PieceItem
from sugar.canvas.DonutItem import PieceIcon
import sugar.conf
import Theme
@ -81,7 +82,8 @@ class Model(goocanvas.CanvasModelSimple):
tasks.translate(600, 450)
root.add_child(tasks)
me = IconItem('stock-buddy', IconColor(), 150)
profile = sugar.conf.get_profile()
me = IconItem('stock-buddy', profile.get_color(), 150)
me.translate(600 - (me.get_property('width') / 2),
450 - (me.get_property('height') / 2))
root.add_child(me)