Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/view/home/activitiesdonut.py
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-09-24 19:07:43 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-09-24 19:07:43 (GMT)
commit90bf68d0f3a7f96561dfe22c46721db585f4bdc9 (patch)
tree6228165159af75d8da50f440d2e93835c61fe6c9 /shell/view/home/activitiesdonut.py
parent0a53813064890877a52e2bf392eb4d1dbfbb0a3c (diff)
Rework home box layout to fix #2665.
Diffstat (limited to 'shell/view/home/activitiesdonut.py')
-rwxr-xr-xshell/view/home/activitiesdonut.py41
1 files changed, 38 insertions, 3 deletions
diff --git a/shell/view/home/activitiesdonut.py b/shell/view/home/activitiesdonut.py
index 9ac7621..d49c9fe 100755
--- a/shell/view/home/activitiesdonut.py
+++ b/shell/view/home/activitiesdonut.py
@@ -32,6 +32,10 @@ from sugar.graphics import xocolor
from sugar import profile
import proc_smaps
+_MAX_ACTIVITIES = 10
+_MIN_WEDGE_SIZE = 1.0 / _MAX_ACTIVITIES
+_DONUT_SIZE = style.zoom(450)
+
# TODO: rgb_to_html and html_to_rgb are useful elsewhere
# we should put this in a common module
def rgb_to_html(r, g, b):
@@ -50,9 +54,6 @@ def html_to_rgb(html_color):
r, g, b = (r / 255.0, g / 255.0, b / 255.0)
return (r, g, b)
-_MAX_ACTIVITIES = 10
-_MIN_WEDGE_SIZE = 1.0 / _MAX_ACTIVITIES
-
class ActivityIcon(CanvasIcon):
_INTERVAL = 250
@@ -188,6 +189,9 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
self._angles = []
self._shell_mappings = proc_smaps.get_shared_mapping_names(os.getpid())
+ self._layout = _Layout()
+ self.set_layout(self._layout)
+
self._model = shell.get_model().get_home()
self._model.connect('activity-added', self._activity_added_cb)
self._model.connect('activity-removed', self._activity_removed_cb)
@@ -495,4 +499,35 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
x = int(radius * math.cos(angle)) - icon_width / 2
y = int(radius * math.sin(angle)) - icon_height / 2
+
self.set_position(icon, x + width / 2, y + height / 2)
+
+class _Layout(gobject.GObject,hippo.CanvasLayout):
+ __gtype_name__ = 'SugarDonutLayout'
+ def __init__(self):
+ gobject.GObject.__init__(self)
+
+ def do_set_box(self, box):
+ self._box = box
+
+ def do_get_height_request(self, for_width):
+ return _DONUT_SIZE, _DONUT_SIZE
+
+ def do_get_width_request(self):
+ return _DONUT_SIZE, _DONUT_SIZE
+
+ def do_allocate(self, x, y, width, height,
+ req_width, req_height, origin_changed):
+ for child in self._box.get_layout_children():
+ min_width, child_width = child.get_width_request()
+ min_height, child_height = child.get_height_request(child_width)
+
+ [angle_start, angle_end] = self._box._get_angles(i)
+ angle = angle_start + (angle_end - angle_start) / 2
+
+ x = int(radius * math.cos(angle)) - icon_width / 2
+ y = int(radius * math.sin(angle)) - icon_height / 2
+
+ child.allocate(x + (width - child_width) / 2,
+ y + (height - child_height) / 2,
+ icon_width, icon_height, origin_changed)