Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/activity
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-02-21 16:53:44 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-02-21 16:53:44 (GMT)
commit7db372cc1cdc2d2c19af83c9566b14fa406a73a2 (patch)
tree8cce2afe9dd3f4a0447dddb3eed3b9ccacc92d92 /sugar/activity
parentf5b13b716e86f18d0d9c624b9381d9d721b4c892 (diff)
Make bundle registry a singleton. Get the object path from the registry.
Diffstat (limited to 'sugar/activity')
-rw-r--r--sugar/activity/ActivityFactory.py15
-rw-r--r--sugar/activity/bundle.py4
-rw-r--r--sugar/activity/bundleregistry.py11
3 files changed, 23 insertions, 7 deletions
diff --git a/sugar/activity/ActivityFactory.py b/sugar/activity/ActivityFactory.py
index 8ecb4c8..ec45fbe 100644
--- a/sugar/activity/ActivityFactory.py
+++ b/sugar/activity/ActivityFactory.py
@@ -25,6 +25,7 @@ import gobject
import gtk
from sugar.presence.PresenceService import PresenceService
+from sugar.activity import bundleregistry
from sugar.activity.bundle import Bundle
from sugar import logger
@@ -90,14 +91,14 @@ class ActivityCreationHandler(gobject.GObject):
([gobject.TYPE_PYOBJECT]))
}
- def __init__(self, activity_name):
+ def __init__(self, service_name):
gobject.GObject.__init__(self)
- bus = dbus.SessionBus()
- factory_name = activity_name
- factory_path = get_path(factory_name)
+ registry = bundleregistry.get_registry()
+ bundle = registry.get_bundle(service_name)
- proxy_obj = bus.get_object(factory_name, factory_path)
+ bus = dbus.SessionBus()
+ proxy_obj = bus.get_object(service_name, bundle.get_object_path())
factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
factory.create(reply_handler=self._reply_handler, error_handler=self._error_handler)
@@ -113,9 +114,9 @@ class ActivityCreationHandler(gobject.GObject):
logging.debug("Couldn't create activity: %s" % err)
self.emit('error', err)
-def create(activity_name):
+def create(service_name):
"""Create a new activity from its name."""
- return ActivityCreationHandler(activity_name)
+ return ActivityCreationHandler(service_name)
def start_factory(activity_class, bundle_path):
"""Start the activity factory."""
diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py
index c7675de..8c17958 100644
--- a/sugar/activity/bundle.py
+++ b/sugar/activity/bundle.py
@@ -71,6 +71,10 @@ class Bundle:
"""Get the activity service name"""
return self._service_name
+ def get_object_path(self):
+ """Get the path to the service object"""
+ return '/' + self._service_name.replace('.', '/')
+
def get_default_type(self):
"""Get the type of the main network service which tracks presence
and provides info about the activity, for example the title."""
diff --git a/sugar/activity/bundleregistry.py b/sugar/activity/bundleregistry.py
index 22a84e1..ccf3b79 100644
--- a/sugar/activity/bundleregistry.py
+++ b/sugar/activity/bundleregistry.py
@@ -73,3 +73,14 @@ class BundleRegistry(gobject.GObject):
return True
else:
return False
+
+def get_registry():
+ return _bundle_registry
+
+_bundle_registry = BundleRegistry()
+
+for path in env.get_data_dirs():
+ bundles_path = os.path.join(path, 'activities')
+ _bundle_registry.add_search_path(bundles_path)
+
+_bundle_registry.add_search_path(env.get_user_activities_dir())