Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/model/MeshModel.py5
-rw-r--r--shell/model/ShellModel.py15
-rw-r--r--shell/model/homemodel.py6
-rw-r--r--shell/view/frame/ActivitiesBox.py3
-rw-r--r--sugar/activity/ActivityFactory.py15
-rw-r--r--sugar/activity/bundle.py4
-rw-r--r--sugar/activity/bundleregistry.py11
7 files changed, 33 insertions, 26 deletions
diff --git a/shell/model/MeshModel.py b/shell/model/MeshModel.py
index a261156..6c9f883 100644
--- a/shell/model/MeshModel.py
+++ b/shell/model/MeshModel.py
@@ -18,6 +18,7 @@ import gobject
from sugar.graphics.iconcolor import IconColor
from sugar.presence import PresenceService
+from sugar.activity import bundleregistry
from model.BuddyModel import BuddyModel
class ActivityModel:
@@ -53,12 +54,12 @@ class MeshModel(gobject.GObject):
gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT]))
}
- def __init__(self, bundle_registry):
+ def __init__(self):
gobject.GObject.__init__(self)
self._activities = {}
self._buddies = {}
- self._bundle_registry = bundle_registry
+ self._bundle_registry = bundleregistry.get_registry()
self._pservice = PresenceService.get_instance()
self._pservice.connect("service-appeared",
diff --git a/shell/model/ShellModel.py b/shell/model/ShellModel.py
index abfff21..4c0df12 100644
--- a/shell/model/ShellModel.py
+++ b/shell/model/ShellModel.py
@@ -44,8 +44,6 @@ class ShellModel(gobject.GObject):
self._current_activity = None
self._state = self.STATE_RUNNING
- self._bundle_registry = BundleRegistry()
-
PresenceService.start()
self._pservice = PresenceService.get_instance()
@@ -53,16 +51,10 @@ class ShellModel(gobject.GObject):
self._owner.announce()
self._friends = Friends()
- self._mesh = MeshModel(self._bundle_registry)
- self._home = HomeModel(self._bundle_registry)
+ self._mesh = MeshModel()
+ self._home = HomeModel()
self._devices = DevicesModel()
- for path in env.get_data_dirs():
- bundles_path = os.path.join(path, 'activities')
- self._bundle_registry.add_search_path(bundles_path)
-
- self._bundle_registry.add_search_path(env.get_user_activities_dir())
-
def do_set_property(self, pspec, value):
if pspec.name == 'state':
self._state = value
@@ -71,9 +63,6 @@ class ShellModel(gobject.GObject):
if pspec.name == 'state':
return self._state
- def get_bundle_registry(self):
- return self._bundle_registry
-
def get_mesh(self):
return self._mesh
diff --git a/shell/model/homemodel.py b/shell/model/homemodel.py
index bc45a0a..ff04dfc 100644
--- a/shell/model/homemodel.py
+++ b/shell/model/homemodel.py
@@ -21,7 +21,7 @@ import wnck
import dbus
from model.homeactivity import HomeActivity
-from sugar.activity import Activity
+from sugar.activity import bundleregistry
_ACTIVITY_SERVICE_NAME = "org.laptop.Activity"
_ACTIVITY_SERVICE_PATH = "/org/laptop/Activity"
@@ -43,11 +43,11 @@ class HomeModel(gobject.GObject):
([gobject.TYPE_PYOBJECT]))
}
- def __init__(self, bundle_registry):
+ def __init__(self):
gobject.GObject.__init__(self)
self._activities = {}
- self._bundle_registry = bundle_registry
+ self._bundle_registry = bundleregistry.get_registry()
self._current_activity = None
screen = wnck.screen_get_default()
diff --git a/shell/view/frame/ActivitiesBox.py b/shell/view/frame/ActivitiesBox.py
index 196309d..ea64b7f 100644
--- a/shell/view/frame/ActivitiesBox.py
+++ b/shell/view/frame/ActivitiesBox.py
@@ -21,6 +21,7 @@ from sugar.graphics import units
from sugar.graphics.iconcolor import IconColor
from sugar.graphics.iconbutton import IconButton
from sugar.presence import PresenceService
+from sugar.activity import bundleregistry
from sugar import profile
class ActivityButton(IconButton):
@@ -63,7 +64,7 @@ class ActivitiesBox(hippo.CanvasBox):
self._invite_to_item = {}
self._invites = self._shell_model.get_invites()
- bundle_registry = self._shell_model.get_bundle_registry()
+ bundle_registry = bundleregistry.get_registry()
for bundle in bundle_registry:
if bundle.get_show_launcher():
self.add_activity(bundle)
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())