diff --git a/shell/model/MeshModel.py b/shell/model/MeshModel.py index c2eb1674..2006b5d4 100644 --- a/shell/model/MeshModel.py +++ b/shell/model/MeshModel.py @@ -22,7 +22,7 @@ from sugar.presence import PresenceService from model.BuddyModel import BuddyModel class ActivityModel: - def __init__(self, activity, service): + def __init__(self, activity, bundle, service): self._service = service self._activity = activity @@ -30,10 +30,7 @@ class ActivityModel: return self._activity.get_id() def get_icon_name(self): - registry = conf.get_activity_registry() - info = registry.get_activity_from_type(self._service.get_type()) - - return info.get_icon() + return bundle.get_icon() def get_color(self): return IconColor(self._activity.get_color()) @@ -56,11 +53,12 @@ class MeshModel(gobject.GObject): gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])) } - def __init__(self): + def __init__(self, bundle_registry): gobject.GObject.__init__(self) self._activities = {} self._buddies = {} + self._bundle_registry = bundle_registry self._pservice = PresenceService.get_instance() self._pservice.connect("service-appeared", @@ -124,8 +122,7 @@ class MeshModel(gobject.GObject): self._check_service(service) def _check_service(self, service): - registry = conf.get_activity_registry() - if registry.get_activity_from_type(service.get_type()) != None: + if self._bundle_registry.get_bundle(service.get_type()) != None: activity_id = service.get_activity_id() if not self.has_activity(activity_id): activity = self._pservice.get_activity(activity_id) @@ -135,8 +132,15 @@ class MeshModel(gobject.GObject): def has_activity(self, activity_id): return self._activities.has_key(activity_id) + def get_activity(self, activity_id): + if self.has_activity(activity_id): + return self._activities[activity_id] + else: + return None + def add_activity(self, activity, service): - model = ActivityModel(activity, service) + bundle = self._bundle_registry.get_bundle(service.get_type()) + model = ActivityModel(activity, bundle, service) self._activities[model.get_id()] = model self.emit('activity-added', model) diff --git a/shell/model/ShellModel.py b/shell/model/ShellModel.py index 54b7ebc5..d2d6e9d3 100644 --- a/shell/model/ShellModel.py +++ b/shell/model/ShellModel.py @@ -27,6 +27,8 @@ class ShellModel: def __init__(self): self._current_activity = None + self._bundle_registry = BundleRegistry() + PresenceService.start() self._pservice = PresenceService.get_instance() @@ -34,9 +36,7 @@ class ShellModel: self._owner.announce() self._friends = Friends() - self._mesh = MeshModel() - - self._bundle_registry = BundleRegistry() + self._mesh = MeshModel(self._bundle_registry) path = os.path.expanduser('~/Activities') self._bundle_registry.add_search_path(path) diff --git a/shell/view/frame/ActivitiesBox.py b/shell/view/frame/ActivitiesBox.py index 81b26eeb..2e3a75ac 100644 --- a/shell/view/frame/ActivitiesBox.py +++ b/shell/view/frame/ActivitiesBox.py @@ -32,11 +32,11 @@ class ActivityItem(CanvasIcon): return self._activity.get_service_name() class InviteItem(CanvasIcon): - def __init__(self, invite): - CanvasIcon.__init__(self, icon_name=invite.get_icon()) + def __init__(self, activity, invite): + CanvasIcon.__init__(self, icon_name=activity.get_icon()) style.apply_stylesheet(self, 'frame.ActivityIcon') - self.props.color = invite.get_color() + self.props.color = activity.get_color() self._invite = invite @@ -87,11 +87,14 @@ class ActivitiesBox(hippo.CanvasBox): self.append(item, 0) def add_invite(self, invite): - item = InviteItem(invite) - item.connect('activated', self._invite_clicked_cb) - self.append(item, 0) + mesh = self._shell_model.get_mesh() + activity = mesh.get_activity(invite.get_activity_id()) + if activity: + item = InviteItem(activity, invite) + item.connect('activated', self._invite_clicked_cb) + self.append(item, 0) - self._invite_to_item[invite] = item + self._invite_to_item[invite] = item def remove_invite(self, invite): self.remove(self._invite_to_item[invite])