Do not index icons by activity id. Raw X windows does not have one.
This commit is contained in:
parent
cd3efeba49
commit
d4bd7a5d05
@ -72,6 +72,8 @@ class HomeActivity(gobject.GObject):
|
|||||||
|
|
||||||
def set_service(self, service):
|
def set_service(self, service):
|
||||||
self._service = service
|
self._service = service
|
||||||
|
if not self._activity_id:
|
||||||
|
self._activity_id = service.get_id()
|
||||||
|
|
||||||
def get_service(self):
|
def get_service(self):
|
||||||
"""Retrieve the application's sugar introspection service
|
"""Retrieve the application's sugar introspection service
|
||||||
@ -154,6 +156,13 @@ class HomeActivity(gobject.GObject):
|
|||||||
"""
|
"""
|
||||||
return self._launch_time
|
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):
|
def do_set_property(self, pspec, value):
|
||||||
if pspec.name == 'launching':
|
if pspec.name == 'launching':
|
||||||
self._launching = value
|
self._launching = value
|
||||||
|
@ -139,7 +139,7 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
def __init__(self, shell, **kwargs):
|
def __init__(self, shell, **kwargs):
|
||||||
hippo.CanvasBox.__init__(self, **kwargs)
|
hippo.CanvasBox.__init__(self, **kwargs)
|
||||||
|
|
||||||
self._activities = {}
|
self._activities = []
|
||||||
self._shell = shell
|
self._shell = shell
|
||||||
|
|
||||||
self._model = shell.get_model().get_home()
|
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('activity-removed', self._activity_removed_cb)
|
||||||
self._model.connect('active-activity-changed', self._activity_changed_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):
|
def _activity_added_cb(self, model, activity):
|
||||||
self._add_activity(activity)
|
self._add_activity(activity)
|
||||||
|
|
||||||
@ -157,20 +162,18 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
self.emit_paint_needed(0, 0, -1, -1)
|
self.emit_paint_needed(0, 0, -1, -1)
|
||||||
|
|
||||||
def _remove_activity(self, activity):
|
def _remove_activity(self, activity):
|
||||||
act_id = activity.get_activity_id()
|
icon = self._get_icon_from_activity(activity)
|
||||||
if not self._activities.has_key(act_id):
|
if icon:
|
||||||
return
|
self.remove(icon)
|
||||||
icon = self._activities[act_id]
|
icon._cleanup()
|
||||||
self.remove(icon)
|
self._activities.remove(icon)
|
||||||
icon._cleanup()
|
|
||||||
del self._activities[act_id]
|
|
||||||
|
|
||||||
def _add_activity(self, activity):
|
def _add_activity(self, activity):
|
||||||
icon = ActivityIcon(activity)
|
icon = ActivityIcon(activity)
|
||||||
icon.connect('activated', self._activity_icon_clicked_cb)
|
icon.connect('activated', self._activity_icon_clicked_cb)
|
||||||
self.append(icon, hippo.PACK_FIXED)
|
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)
|
self.emit_paint_needed(0, 0, -1, -1)
|
||||||
|
|
||||||
@ -250,7 +253,7 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
for h_activity in self._model:
|
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_start, angle_end] = self._get_angles(i)
|
||||||
angle = angle_start + (angle_end - angle_start) / 2
|
angle = angle_start + (angle_end - angle_start) / 2
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user