Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-08-09 16:10:16 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-08-09 16:10:16 (GMT)
commitcff8ffc32895f3e304f843389c7d4a984502727e (patch)
tree1fdf4b73ec4fd5029db78bf8f83806b12f4626a3 /sugar
parentf00f3e2f8da0549a54f10ef20419ff6e11824685 (diff)
Complete move to external bundle registry.
Diffstat (limited to 'sugar')
-rw-r--r--sugar/activity/bundle.py7
-rw-r--r--sugar/activity/registry.py25
2 files changed, 23 insertions, 9 deletions
diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py
index bc24092..d361c62 100644
--- a/sugar/activity/bundle.py
+++ b/sugar/activity/bundle.py
@@ -296,11 +296,8 @@ class Bundle:
raise ZipExtractException
self._init_with_path(bundle_path)
-
- bus = dbus.SessionBus()
- proxy_obj = bus.get_object(_DBUS_SHELL_SERVICE, _DBUS_SHELL_PATH)
- dbus_service = dbus.Interface(proxy_obj, _DBUS_ACTIVITY_REGISTRY_IFACE)
- if not dbus_service.AddBundle(bundle_path):
+
+ if not activity.get_registry().add_bundle(bundle_path):
raise RegistrationException
def deinstall(self):
diff --git a/sugar/activity/registry.py b/sugar/activity/registry.py
index 430a2df..1483a78 100644
--- a/sugar/activity/registry.py
+++ b/sugar/activity/registry.py
@@ -19,6 +19,7 @@
import logging
import dbus
+import gobject
_ACTIVITY_REGISTRY_SERVICE_NAME = 'org.laptop.ActivityRegistry'
_ACTIVITY_REGISTRY_IFACE = 'org.laptop.ActivityRegistry'
@@ -28,17 +29,25 @@ def _activity_info_from_dict(info_dict):
if not info_dict:
return None
return ActivityInfo(info_dict['name'], info_dict['icon'],
- info_dict['service_name'], info_dict['path'])
+ info_dict['service_name'], info_dict['path'],
+ info_dict['show_launcher'])
class ActivityInfo(object):
- def __init__(self, name, icon, service_name, path):
+ def __init__(self, name, icon, service_name, path, show_launcher):
self.name = name
self.icon = icon
self.service_name = service_name
self.path = path
+ self.show_launcher = show_launcher
-class ActivityRegistry(object):
+class ActivityRegistry(gobject.GObject):
+ __gsignals__ = {
+ 'activity-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT]))
+ }
def __init__(self):
+ gobject.GObject.__init__(self)
+
bus = dbus.SessionBus()
bus_object = bus.get_object(_ACTIVITY_REGISTRY_SERVICE_NAME,
_ACTIVITY_REGISTRY_PATH)
@@ -57,6 +66,10 @@ class ActivityRegistry(object):
return result
+ def get_activities(self):
+ info_list = self._registry.GetActivities()
+ return self._convert_info_list(info_list)
+
def get_activity(self, service_name):
if self._service_name_to_activity_info.has_key(service_name):
return self._service_name_to_activity_info[service_name]
@@ -81,10 +94,14 @@ class ActivityRegistry(object):
self._mime_type_to_activities[mime_type] = activities
return activities
- def _activity_added_cb(self, bundle):
+ def add_bundle(self, bundle_path):
+ return self._registry.AddBundle(bundle_path)
+
+ def _activity_added_cb(self, info_dict):
logging.debug('ActivityRegistry._activity_added_cb: flushing caches')
self._service_name_to_activity_info.clear()
self._mime_type_to_activities.clear()
+ self.emit('activity-added', _activity_info_from_dict(info_dict))
_registry = None