Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-08-17 09:47:41 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-08-17 09:47:41 (GMT)
commite5ed8275a1f375da460b3a757994f39ba80c4f08 (patch)
tree33faca9d9c1c89e464841f45eca8663f9471d282
parent7990bc0d3126408e2728e3f41745e1332182de5b (diff)
Some work on the donut...
-rw-r--r--shell/HomeWindow.py13
-rw-r--r--sugar/canvas/DonutItem.py49
2 files changed, 62 insertions, 0 deletions
diff --git a/shell/HomeWindow.py b/shell/HomeWindow.py
index 1449d0d..9534a81 100644
--- a/shell/HomeWindow.py
+++ b/shell/HomeWindow.py
@@ -2,6 +2,15 @@ import gtk
import goocanvas
from sugar.canvas.IconItem import IconItem
+from sugar.canvas.DonutItem import DonutItem
+
+class TasksItem(DonutItem):
+ def __init__(self):
+ DonutItem.__init__(self, 200)
+ self.add_piece(30)
+ self.add_piece(30)
+ self.add_piece(30)
+ self.add_piece(10)
class ActivityItem(IconItem):
def __init__(self, activity):
@@ -57,6 +66,10 @@ class Model(goocanvas.CanvasModelSimple):
activity_bar.translate(50, 860)
root.add_child(activity_bar)
+ tasks = TasksItem()
+ tasks.translate(600, 450)
+ root.add_child(tasks)
+
class HomeWindow(gtk.Window):
def __init__(self, shell):
gtk.Window.__init__(self)
diff --git a/sugar/canvas/DonutItem.py b/sugar/canvas/DonutItem.py
new file mode 100644
index 0000000..19c56f8
--- /dev/null
+++ b/sugar/canvas/DonutItem.py
@@ -0,0 +1,49 @@
+import math
+
+import goocanvas
+
+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
+
+ 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'
+
+ print data
+
+ 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
+
+ def add_piece(self, perc):
+ angle_end = self._angle_start + perc * 2 * math.pi / 100
+ piece_item = PieceItem(self._angle_start, angle_end)
+ self._angle_start = angle_end
+
+ # FIXME can't override set_parent on the
+ # PieceItem and there is no signal.
+ self.add_child(piece_item)
+ piece_item.construct()
+
+ def get_radius(self):
+ return self._radius