Get back mesh view to work. It got broken when refactoring bundles.
This commit is contained in:
parent
99cce220cd
commit
e023d1c345
@ -24,12 +24,13 @@ class ActivityModel:
|
|||||||
def __init__(self, activity, bundle, service):
|
def __init__(self, activity, bundle, service):
|
||||||
self._service = service
|
self._service = service
|
||||||
self._activity = activity
|
self._activity = activity
|
||||||
|
self._bundle = bundle
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
return self._activity.get_id()
|
return self._activity.get_id()
|
||||||
|
|
||||||
def get_icon_name(self):
|
def get_icon_name(self):
|
||||||
return bundle.get_icon()
|
return self._bundle.get_icon()
|
||||||
|
|
||||||
def get_color(self):
|
def get_color(self):
|
||||||
return IconColor(self._activity.get_color())
|
return IconColor(self._activity.get_color())
|
||||||
@ -121,12 +122,14 @@ class MeshModel(gobject.GObject):
|
|||||||
self._check_service(service)
|
self._check_service(service)
|
||||||
|
|
||||||
def _check_service(self, service):
|
def _check_service(self, service):
|
||||||
if self._bundle_registry.get_bundle(service.get_type()) != None:
|
service_type = service.get_type()
|
||||||
|
bundle = self._bundle_registry.find_by_default_type(service_type)
|
||||||
|
if bundle != None:
|
||||||
activity_id = service.get_activity_id()
|
activity_id = service.get_activity_id()
|
||||||
if not self.has_activity(activity_id):
|
if not self.has_activity(activity_id):
|
||||||
activity = self._pservice.get_activity(activity_id)
|
activity = self._pservice.get_activity(activity_id)
|
||||||
if activity != None:
|
if activity != None:
|
||||||
self.add_activity(activity, service)
|
self.add_activity(bundle, activity, service)
|
||||||
|
|
||||||
def has_activity(self, activity_id):
|
def has_activity(self, activity_id):
|
||||||
return self._activities.has_key(activity_id)
|
return self._activities.has_key(activity_id)
|
||||||
@ -137,8 +140,7 @@ class MeshModel(gobject.GObject):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def add_activity(self, activity, service):
|
def add_activity(self, bundle, activity, service):
|
||||||
bundle = self._bundle_registry.get_bundle(service.get_type())
|
|
||||||
model = ActivityModel(activity, bundle, service)
|
model = ActivityModel(activity, bundle, service)
|
||||||
self._activities[model.get_id()] = model
|
self._activities[model.get_id()] = model
|
||||||
self.emit('activity-added', model)
|
self.emit('activity-added', model)
|
||||||
|
@ -33,6 +33,13 @@ class BundleRegistry:
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def find_by_default_type(self, default_type):
|
||||||
|
"""Find a bundle by the network service default type"""
|
||||||
|
for bundle in self._bundles.values():
|
||||||
|
if bundle.get_default_type() == default_type:
|
||||||
|
return bundle
|
||||||
|
return None
|
||||||
|
|
||||||
def add_search_path(self, path):
|
def add_search_path(self, path):
|
||||||
"""Add a directory to the bundles search path"""
|
"""Add a directory to the bundles search path"""
|
||||||
self._search_path.append(path)
|
self._search_path.append(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user