Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-01-31 16:32:03 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-01-31 16:32:03 (GMT)
commita228e5297bdcebc28469cf27319fa2201ce55b68 (patch)
treef3b1bed6a89d8f09d0b412bd9d164cb1c5068ceb /shell
parentde2cfecf924de3ee30ca893298a0912bbaa46920 (diff)
parent165bb9213fbe2c0dd1fe492bcdef920f0408b891 (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'shell')
-rw-r--r--shell/model/homemodel.py3
-rw-r--r--shell/view/home/activitiesdonut.py50
2 files changed, 40 insertions, 13 deletions
diff --git a/shell/model/homemodel.py b/shell/model/homemodel.py
index 30ffb8b..40d8bd7 100644
--- a/shell/model/homemodel.py
+++ b/shell/model/homemodel.py
@@ -135,6 +135,9 @@ class HomeModel(gobject.GObject):
self.emit('activity-added', activity)
def _internal_remove_activity(self, activity):
+ if activity == self._current_activity:
+ self._current_activity = None
+
self.emit('activity-removed', activity)
act_id = activity.get_id()
del self._activities[act_id]
diff --git a/shell/view/home/activitiesdonut.py b/shell/view/home/activitiesdonut.py
index 75d0b4d..9724fce 100644
--- a/shell/view/home/activitiesdonut.py
+++ b/shell/view/home/activitiesdonut.py
@@ -135,6 +135,7 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
self._model.connect('activity-launched', self._activity_launched_cb)
self._model.connect('activity-added', self._activity_added_cb)
self._model.connect('activity-removed', self._activity_removed_cb)
+ self._model.connect('active-activity-changed', self._activity_changed_cb)
def _activity_launched_cb(self, model, activity):
self._add_activity(activity)
@@ -150,6 +151,9 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
def _activity_removed_cb(self, model, activity):
self._remove_activity(activity)
+ def _activity_changed_cb(self, model, activity):
+ self.emit_paint_needed(0, 0, -1, -1)
+
def _remove_activity(self, activity):
act_id = activity.get_id()
if not self._activities.has_key(act_id):
@@ -179,7 +183,9 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
def _get_angles(self, index):
angle = 2 * math.pi / 8
- return [index * angle, (index + 1) * angle]
+ bottom_align = (math.pi - angle) / 2
+ return [index * angle + bottom_align,
+ (index + 1) * angle + bottom_align]
def _get_radius(self):
[width, height] = self.get_allocation()
@@ -195,30 +201,47 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
radius = self._get_radius()
+ # Outer Ring
cr.set_source_rgb(0xf1 / 255.0, 0xf1 / 255.0, 0xf1 / 255.0)
cr.arc(0, 0, radius, 0, 2 * math.pi)
cr.fill()
- angle_end = 0
- for i in range(0, len(self._activities)):
- [angle_start, angle_end] = self._get_angles(i)
-
- cr.new_path()
+ # Selected Wedge
+ current_activity = self._model.get_current_activity()
+ if current_activity is not None:
+ selected_index = self._model.index(current_activity)
+ [angle_start, angle_end] = self._get_angles(selected_index)
+
+ cr.new_path()
cr.move_to(0, 0)
cr.line_to(radius * math.cos(angle_start),
radius * math.sin(angle_start))
cr.arc(0, 0, radius, angle_start, angle_end)
cr.line_to(0, 0)
-
+ cr.set_source_rgb(1, 1, 1)
+ cr.fill()
+
+ # Edges
+ if len(self._model):
+ n_edges = len(self._model) + 1
+ else:
+ n_edges = 0
+
+ for i in range(0, n_edges):
+ cr.new_path()
+ cr.move_to(0, 0)
+ [angle, unused_angle] = self._get_angles(i)
+ cr.line_to(radius * math.cos(angle),
+ radius * math.sin(angle))
+
cr.set_source_rgb(0xe2 / 255.0, 0xe2 / 255.0, 0xe2 / 255.0)
cr.set_line_width(4)
cr.stroke_preserve()
-
- cr.set_source_rgb(1, 1, 1)
- cr.fill()
-
- cr.set_source_rgb(0xe2 / 255.0, 0xe2 / 255.0, 0xe2 / 255.0)
+
+ # Inner Ring
+ cr.new_path()
cr.arc(0, 0, self._get_inner_radius(), 0, 2 * math.pi)
+ cr.set_source_rgb(0xe2 / 255.0, 0xe2 / 255.0, 0xe2 / 255.0)
cr.fill()
def do_allocate(self, width, height, origin_changed):
@@ -227,7 +250,8 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
radius = (self._get_inner_radius() + self._get_radius()) / 2
i = 0
- for icon in self._activities.values():
+ for h_activity in self._model:
+ icon = self._activities[h_activity.get_id()]
[angle_start, angle_end] = self._get_angles(i)
angle = angle_start + (angle_end - angle_start) / 2