From d4bd7a5d05f251cdf90c0f656f0498df05b4e5b1 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 1 Jun 2007 14:19:14 +0200 Subject: [PATCH] Do not index icons by activity id. Raw X windows does not have one. --- shell/model/homeactivity.py | 9 +++++++++ shell/view/home/activitiesdonut.py | 23 +++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/shell/model/homeactivity.py b/shell/model/homeactivity.py index c22e8be1..f029e152 100644 --- a/shell/model/homeactivity.py +++ b/shell/model/homeactivity.py @@ -72,6 +72,8 @@ class HomeActivity(gobject.GObject): def set_service(self, service): self._service = service + if not self._activity_id: + self._activity_id = service.get_id() def get_service(self): """Retrieve the application's sugar introspection service @@ -154,6 +156,13 @@ class HomeActivity(gobject.GObject): """ return self._launch_time + def equals(self, activity): + if self._activity_id and activity.get_activity_id(): + return self._activity_id == activity.get_activity_id() + if self._xid and activity.get_xid(): + return self._xid == activity.get_xid() + return False + def do_set_property(self, pspec, value): if pspec.name == 'launching': self._launching = value diff --git a/shell/view/home/activitiesdonut.py b/shell/view/home/activitiesdonut.py index 57ceb45a..795ef728 100644 --- a/shell/view/home/activitiesdonut.py +++ b/shell/view/home/activitiesdonut.py @@ -139,7 +139,7 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem): def __init__(self, shell, **kwargs): hippo.CanvasBox.__init__(self, **kwargs) - self._activities = {} + self._activities = [] self._shell = shell self._model = shell.get_model().get_home() @@ -147,6 +147,11 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem): self._model.connect('activity-removed', self._activity_removed_cb) self._model.connect('active-activity-changed', self._activity_changed_cb) + def _get_icon_from_activity(self, activity): + for icon in self._activities: + if icon.get_activity().equals(activity): + return icon + def _activity_added_cb(self, model, activity): self._add_activity(activity) @@ -157,20 +162,18 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem): self.emit_paint_needed(0, 0, -1, -1) def _remove_activity(self, activity): - act_id = activity.get_activity_id() - if not self._activities.has_key(act_id): - return - icon = self._activities[act_id] - self.remove(icon) - icon._cleanup() - del self._activities[act_id] + icon = self._get_icon_from_activity(activity) + if icon: + self.remove(icon) + icon._cleanup() + self._activities.remove(icon) def _add_activity(self, activity): icon = ActivityIcon(activity) icon.connect('activated', self._activity_icon_clicked_cb) self.append(icon, hippo.PACK_FIXED) - self._activities[activity.get_activity_id()] = icon + self._activities.append(icon) self.emit_paint_needed(0, 0, -1, -1) @@ -250,7 +253,7 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem): i = 0 for h_activity in self._model: - icon = self._activities[h_activity.get_activity_id()] + icon = self._get_icon_from_activity(h_activity) [angle_start, angle_end] = self._get_angles(i) angle = angle_start + (angle_end - angle_start) / 2