Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-04 13:26:41 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-04 13:26:41 (GMT)
commit62ee1df83c66a6b518873a288a4926c36c52d986 (patch)
tree0b9521e2d735a6bdc8f393ba28adaa2af4de2a01 /shell
parent72a4aa6fe217d3a3d838dd8a7fcb67d17672ae7c (diff)
Complete the de-goocanvasification
Diffstat (limited to 'shell')
-rw-r--r--shell/view/BuddyMenu.py3
-rw-r--r--shell/view/frame/ZoomBox.py1
-rw-r--r--shell/view/home/DonutItem.py114
-rw-r--r--shell/view/home/FriendsBox.py11
-rw-r--r--shell/view/home/HomeBox.py15
-rw-r--r--shell/view/home/MyIcon.py10
6 files changed, 27 insertions, 127 deletions
diff --git a/shell/view/BuddyMenu.py b/shell/view/BuddyMenu.py
index 6d866e8..3b0d69c 100644
--- a/shell/view/BuddyMenu.py
+++ b/shell/view/BuddyMenu.py
@@ -1,6 +1,5 @@
import gtk
import gobject
-import goocanvas
from sugar.graphics.menu import Menu
from sugar.graphics.canvasicon import CanvasIcon
@@ -73,7 +72,7 @@ class BuddyMenu(Menu):
# FIXME check that the buddy is not in the activity already
- icon = IconItem(icon_name='stock-invite')
+ icon = CanvasIcon(icon_name='stock-invite')
self.add_action(icon, BuddyMenu.ACTION_INVITE)
def __buddy_icon_changed_cb(self, buddy):
diff --git a/shell/view/frame/ZoomBox.py b/shell/view/frame/ZoomBox.py
index 9dabf8b..7282da7 100644
--- a/shell/view/frame/ZoomBox.py
+++ b/shell/view/frame/ZoomBox.py
@@ -1,4 +1,3 @@
-import goocanvas
import hippo
from sugar.graphics.canvasicon import CanvasIcon
diff --git a/shell/view/home/DonutItem.py b/shell/view/home/DonutItem.py
deleted file mode 100644
index 402b4b1..0000000
--- a/shell/view/home/DonutItem.py
+++ /dev/null
@@ -1,114 +0,0 @@
-import math
-
-import goocanvas
-
-from sugar.canvas.IconItem import IconItem
-
-class PieceIcon(IconItem):
- def __init__(self, piece_item, **kwargs):
- IconItem.__init__(self, size=96, **kwargs)
- self._piece_item = piece_item
-
- def construct(self):
- angle_start = self._piece_item.get_angle_start()
- angle_end = self._piece_item.get_angle_end()
- radius = self.get_parent().get_radius()
- inner_radius = self.get_parent().get_inner_radius()
-
- icon_radius = (radius + inner_radius) / 2
- icon_angle = (angle_start + angle_end) / 2
- x = icon_radius * math.cos(icon_angle)
- y = - icon_radius * math.sin(icon_angle)
-
- icon_width = self.get_property('size')
- icon_height = self.get_property('size')
- self.set_property('x', x - icon_width / 2)
- self.set_property('y', y - icon_height / 2)
-
-class PieceItem(goocanvas.Path):
- def __init__(self, angle_start, angle_end, **kwargs):
- goocanvas.Path.__init__(self, **kwargs)
- self._angle_start = angle_start
- self._angle_end = angle_end
-
- self.set_property('fill-color', '#ffffff')
- self.set_property('stroke-color', '#e2e2e2')
- self.set_property('line-width', 4)
-
- def get_icon(self):
- return self._icon
-
- def set_icon(self, icon_name, color):
- self._icon = PieceIcon(self, icon_name=icon_name, color=color)
- self.get_parent().add_child(self._icon)
- self._icon.construct()
-
- def get_angle_start(self):
- return self._angle_start
-
- def get_angle_end(self):
- return self._angle_end
-
- def construct(self):
- r = self.get_parent().get_radius()
-
- data = 'M0,0 '
-
- dx = r * math.cos(self._angle_start)
- dy = - r * math.sin(self._angle_start)
-
- data += 'l%f,%f ' % (dx, dy)
-
- dx = r * math.cos(self._angle_end)
- dy = - r * math.sin(self._angle_end)
-
- data += 'A%f,%f 0 0,0 %f,%f ' % (r, r, dx, dy)
-
- data += 'z'
-
- self.set_property('data', data)
-
-class DonutItem(goocanvas.Group):
- def __init__(self, radius, **kwargs):
- goocanvas.Group.__init__(self, **kwargs)
- self._radius = radius
- self._angle_start = 0
-
- bg = goocanvas.Ellipse(radius_x=radius, radius_y=radius,
- fill_color='#f1f1f1', line_width=0)
- self.add_child(bg)
-
- self._inner_radius = radius / 2
- fg = goocanvas.Ellipse(radius_x=self._inner_radius,
- radius_y=self._inner_radius,
- fill_color='#e2e2e2', line_width=0)
- self.add_child(fg)
-
- def add_piece(self, perc, icon_name, color):
- # FIXME can't override set_parent on the
- # PieceItem and there is no signal. So we
- # call a construct method on the childs for now.
-
- angle_end = self._angle_start + perc * 2 * math.pi / 100
- piece_item = PieceItem(self._angle_start, angle_end)
- self._angle_start = angle_end
-
- self.add_child(piece_item, 1)
- piece_item.construct()
- piece_item.set_icon(icon_name, color)
-
- return piece_item
-
- def remove_piece(self, piece_item):
- index = self.find_child(piece_item)
- self.remove_child(index)
-
- icon = piece_item.get_icon()
- index = self.find_child(icon)
- self.remove_child(index)
-
- def get_radius(self):
- return self._radius
-
- def get_inner_radius(self):
- return self._inner_radius
diff --git a/shell/view/home/FriendsBox.py b/shell/view/home/FriendsBox.py
index b228770..53cf8b6 100644
--- a/shell/view/home/FriendsBox.py
+++ b/shell/view/home/FriendsBox.py
@@ -16,10 +16,8 @@ class FriendsBox(hippo.CanvasBox, hippo.CanvasItem):
self._layout = SpreadLayout()
self._friends = {}
- #me = MyIcon(112)
- #me.translate(600 - (me.get_property('size') / 2),
- # 450 - (me.get_property('size') / 2))
- #self.add_child(me)
+ self._my_icon = MyIcon(112)
+ self.append(self._my_icon, hippo.PACK_FIXED)
friends = self._shell.get_model().get_friends()
@@ -44,4 +42,9 @@ class FriendsBox(hippo.CanvasBox, hippo.CanvasItem):
def do_allocate(self, width, height):
hippo.CanvasBox.do_allocate(self, width, height)
+
self._layout.layout(self)
+
+ [icon_width, icon_height] = self._my_icon.get_allocation()
+ self.move(self._my_icon, (width - icon_width) / 2,
+ (height - icon_height) / 2)
diff --git a/shell/view/home/HomeBox.py b/shell/view/home/HomeBox.py
index e4409fd..ccaa985 100644
--- a/shell/view/home/HomeBox.py
+++ b/shell/view/home/HomeBox.py
@@ -1,11 +1,24 @@
import hippo
from view.home.activitiesdonut import ActivitiesDonut
+from view.home.MyIcon import MyIcon
+
+class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
+ __gtype_name__ = 'SugarHomeBox'
-class HomeBox(hippo.CanvasBox):
def __init__(self, shell):
hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff,
yalign=2)
donut = ActivitiesDonut(shell, box_width=300, box_height=300)
self.append(donut)
+
+ self._my_icon = MyIcon(120)
+ self.append(self._my_icon, hippo.PACK_FIXED)
+
+ def do_allocate(self, width, height):
+ hippo.CanvasBox.do_allocate(self, width, height)
+
+ [icon_width, icon_height] = self._my_icon.get_allocation()
+ self.move(self._my_icon, (width - icon_width) / 2,
+ (height - icon_height) / 2)
diff --git a/shell/view/home/MyIcon.py b/shell/view/home/MyIcon.py
index 0671bec..efc5715 100644
--- a/shell/view/home/MyIcon.py
+++ b/shell/view/home/MyIcon.py
@@ -1,10 +1,10 @@
-import conf
-from sugar.canvas.IconItem import IconItem
+from sugar.graphics.canvasicon import CanvasIcon
from sugar.graphics.iconcolor import IconColor
+import conf
-class MyIcon(IconItem):
+class MyIcon(CanvasIcon):
def __init__(self, size):
profile = conf.get_profile()
- IconItem.__init__(self, icon_name='stock-buddy',
- color=profile.get_color(), size=size)
+ CanvasIcon.__init__(self, icon_name='stock-buddy',
+ color=profile.get_color(), size=size)