Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDan Winship <dwinship@redhat.com>2007-10-04 19:59:23 (GMT)
committer Dan Winship <dwinship@redhat.com>2007-10-04 19:59:23 (GMT)
commit2bcbde6e441ee5ab5743f6b45b5f85e85bbb644f (patch)
tree84a47bc8cb25119134c91db7787a7127acb08ce8 /services
parent5b0566803273cbc45f50a834b08aec73ede26ac5 (diff)
Add bundle removing methods/signals to the activity registry, and use them
Diffstat (limited to 'services')
-rw-r--r--services/shell/activityregistryservice.py18
-rw-r--r--services/shell/bundleregistry.py16
2 files changed, 33 insertions, 1 deletions
diff --git a/services/shell/activityregistryservice.py b/services/shell/activityregistryservice.py
index 21c6d86..c379071 100644
--- a/services/shell/activityregistryservice.py
+++ b/services/shell/activityregistryservice.py
@@ -32,6 +32,7 @@ class ActivityRegistry(dbus.service.Object):
bundle_registry = bundleregistry.get_registry()
bundle_registry.connect('bundle-added', self._bundle_added_cb)
+ bundle_registry.connect('bundle-removed', self._bundle_removed_cb)
@dbus.service.method(_ACTIVITY_REGISTRY_IFACE,
in_signature='s', out_signature='b')
@@ -49,6 +50,16 @@ class ActivityRegistry(dbus.service.Object):
return registry.add_bundle(bundle_path)
@dbus.service.method(_ACTIVITY_REGISTRY_IFACE,
+ in_signature='s', out_signature='b')
+ def RemoveBundle(self, bundle_path):
+ '''Unregister the activity bundle with the global registry
+
+ bundle_path -- path to the activity bundle root directory
+ '''
+ registry = bundleregistry.get_registry()
+ return registry.remove_bundle(bundle_path)
+
+ @dbus.service.method(_ACTIVITY_REGISTRY_IFACE,
in_signature='', out_signature='aa{sv}')
def GetActivities(self):
result = []
@@ -94,6 +105,10 @@ class ActivityRegistry(dbus.service.Object):
def ActivityAdded(self, activity_info):
pass
+ @dbus.service.signal(_ACTIVITY_REGISTRY_IFACE, signature='a{sv}')
+ def ActivityRemoved(self, activity_info):
+ pass
+
def _bundle_to_dict(self, bundle):
return {'name': bundle.get_name(),
'icon': bundle.get_icon(),
@@ -104,6 +119,9 @@ class ActivityRegistry(dbus.service.Object):
def _bundle_added_cb(self, bundle_registry, bundle):
self.ActivityAdded(self._bundle_to_dict(bundle))
+ def _bundle_removed_cb(self, bundle_registry, bundle):
+ self.ActivityRemoved(self._bundle_to_dict(bundle))
+
_instance = None
def get_instance():
diff --git a/services/shell/bundleregistry.py b/services/shell/bundleregistry.py
index 9a1cda6..54d5297 100644
--- a/services/shell/bundleregistry.py
+++ b/services/shell/bundleregistry.py
@@ -73,12 +73,17 @@ class _ServiceManager(object):
util.write_service(bundle.get_service_name(),
bundle.get_command(), self._path)
+ def remove(self, bundle):
+ util.delete_service(bundle.get_service_name(), self._path)
+
class BundleRegistry(gobject.GObject):
"""Service that tracks the available activity bundles"""
__gsignals__ = {
'bundle-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT]))
+ ([gobject.TYPE_PYOBJECT])),
+ 'bundle-removed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT]))
}
def __init__(self):
@@ -133,6 +138,15 @@ class BundleRegistry(gobject.GObject):
self.emit('bundle-added', bundle)
return True
+ def remove_bundle(self, bundle_path):
+ for bundle in self._bundles:
+ if bundle.get_path() == bundle_path:
+ self._bundles.remove(bundle)
+ self._service_manager.remove(bundle)
+ self.emit('bundle-removed', bundle)
+ return True
+ return False
+
def get_activities_for_type(self, mime_type):
result = []
for bundle in self._bundles: