More cleanups, show my icon at the center of the screen

This commit is contained in:
Marco Pesenti Gritti 2006-09-09 02:34:47 +02:00
parent 665f83d7ef
commit dd9e09ab1c
6 changed files with 29 additions and 19 deletions

View File

@ -3,6 +3,8 @@ import random
import goocanvas import goocanvas
from sugar.canvas.IconItem import IconItem from sugar.canvas.IconItem import IconItem
from home.IconLayout import IconLayout
from home.MyIcon import MyIcon
class FriendIcon(IconItem): class FriendIcon(IconItem):
def __init__(self, friend): def __init__(self, friend):
@ -14,13 +16,18 @@ class FriendIcon(IconItem):
return self._friend return self._friend
class FriendsGroup(goocanvas.Group): class FriendsGroup(goocanvas.Group):
def __init__(self, shell, friends, icon_layout): def __init__(self, shell, friends):
goocanvas.Group.__init__(self) goocanvas.Group.__init__(self)
self._shell = shell self._shell = shell
self._icon_layout = icon_layout self._icon_layout = IconLayout(1200, 900)
self._friends = friends self._friends = friends
me = MyIcon(100)
me.translate(600 - (me.get_property('size') / 2),
450 - (me.get_property('size') / 2))
self.add_child(me)
for friend in self._friends: for friend in self._friends:
self.add_friend(friend) self.add_friend(friend)

View File

@ -1,11 +1,7 @@
import gtk
import goocanvas import goocanvas
import wnck
import conf
from sugar.canvas.IconItem import IconItem
from sugar.canvas.IconColor import IconColor
from home.DonutItem import DonutItem from home.DonutItem import DonutItem
from home.MyIcon import MyIcon
class TasksItem(DonutItem): class TasksItem(DonutItem):
def __init__(self, shell): def __init__(self, shell):
@ -50,9 +46,7 @@ class HomeGroup(goocanvas.Group):
tasks.translate(600, 450) tasks.translate(600, 450)
self.add_child(tasks) self.add_child(tasks)
profile = conf.get_profile() me = MyIcon(150)
me = IconItem(icon_name = 'stock-buddy',
color = profile.get_color(), size = 150)
me.translate(600 - (me.get_property('size') / 2), me.translate(600 - (me.get_property('size') / 2),
450 - (me.get_property('size') / 2)) 450 - (me.get_property('size') / 2))
self.add_child(me) self.add_child(me)

View File

@ -6,7 +6,6 @@ from sugar.canvas.CanvasView import CanvasView
from home.MeshGroup import MeshGroup from home.MeshGroup import MeshGroup
from home.HomeGroup import HomeGroup from home.HomeGroup import HomeGroup
from home.FriendsGroup import FriendsGroup from home.FriendsGroup import FriendsGroup
from home.IconLayout import IconLayout
import sugar import sugar
class HomeWindow(gtk.Window): class HomeWindow(gtk.Window):
@ -34,12 +33,10 @@ class HomeWindow(gtk.Window):
self._current_group = self._home_group self._current_group = self._home_group
def set_owner(self, owner): def set_owner(self, owner):
layout = IconLayout(1200, 900)
friends = owner.get_friends() friends = owner.get_friends()
self._friends_group = FriendsGroup(self._shell, friends, layout) self._friends_group = FriendsGroup(self._shell, friends)
layout = IconLayout(1200, 900) self._mesh_group = MeshGroup(self._shell)
self._mesh_group = MeshGroup(self._shell, layout)
def _set_group(self, group): def _set_group(self, group):
self._root.remove_child(self._current_group) self._root.remove_child(self._current_group)

View File

@ -4,6 +4,7 @@ sugar_PYTHON = \
DonutItem.py \ DonutItem.py \
FriendsGroup.py \ FriendsGroup.py \
IconLayout.py \ IconLayout.py \
MeshGroup.py \
HomeGroup.py \ HomeGroup.py \
HomeWindow.py HomeWindow.py \
MeshGroup.py \
MyIcon.py

View File

@ -6,6 +6,7 @@ import conf
from sugar.canvas.IconItem import IconItem from sugar.canvas.IconItem import IconItem
from sugar.canvas.IconItem import IconColor from sugar.canvas.IconItem import IconColor
from sugar.presence import PresenceService from sugar.presence import PresenceService
from home.IconLayout import IconLayout
class ActivityItem(IconItem): class ActivityItem(IconItem):
def __init__(self, service): def __init__(self, service):
@ -32,10 +33,10 @@ class ActivityItem(IconItem):
return self._service return self._service
class MeshGroup(goocanvas.Group): class MeshGroup(goocanvas.Group):
def __init__(self, shell, icon_layout): def __init__(self, shell):
goocanvas.Group.__init__(self) goocanvas.Group.__init__(self)
self._shell = shell self._shell = shell
self._icon_layout = icon_layout self._icon_layout = IconLayout(1200, 900)
self._activities = {} self._activities = {}
pservice = PresenceService.get_instance() pservice = PresenceService.get_instance()

10
shell/home/MyIcon.py Normal file
View File

@ -0,0 +1,10 @@
import conf
from sugar.canvas.IconItem import IconItem
from sugar.canvas.IconColor import IconColor
class MyIcon(IconItem):
def __init__(self, size):
profile = conf.get_profile()
IconItem.__init__(self, icon_name='stock-buddy',
color=profile.get_color(), size=size)