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-22 14:46:13 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-02-22 14:46:13 (GMT)
commit02f375b7108037b6a1dc2f002f03091aa4853b8a (patch)
tree83cf7d6a4574ed4f286cb262c8d0ef1bdcc522be /sugar/activity
parent3742219d6c999a683fa716e59ad4803cad03c992 (diff)
Add a class attribute as per the updated spec.
Cleanups.
Diffstat (limited to 'sugar/activity')
-rw-r--r--sugar/activity/activityfactoryservice.py14
-rw-r--r--sugar/activity/bundle.py20
-rw-r--r--sugar/activity/bundleregistry.py9
3 files changed, 29 insertions, 14 deletions
diff --git a/sugar/activity/activityfactoryservice.py b/sugar/activity/activityfactoryservice.py
index 303d199..822bf99 100644
--- a/sugar/activity/activityfactoryservice.py
+++ b/sugar/activity/activityfactoryservice.py
@@ -17,6 +17,7 @@
import os
import sys
+from optparse import OptionParser
import gobject
import gtk
@@ -77,15 +78,20 @@ class ActivityFactoryService(dbus.service.Object):
def run(args):
"""Start the activity factory."""
- sys.path.insert(0, args[2])
+ parser = OptionParser()
+ parser.add_option("-p", "--bundle-path", dest="bundle_path",
+ help="path to the activity bundle")
+ (options, args) = parser.parse_args()
- bundle = Bundle(args[2])
+ sys.path.insert(0, options.bundle_path)
+
+ bundle = Bundle(options.bundle_path)
logger.start(bundle.get_name())
- os.environ['SUGAR_BUNDLE_PATH'] = args[2]
+ os.environ['SUGAR_BUNDLE_PATH'] = options.bundle_path
os.environ['SUGAR_BUNDLE_SERVICE_NAME'] = bundle.get_service_name()
os.environ['SUGAR_BUNDLE_DEFAULT_TYPE'] = bundle.get_default_type()
- factory = ActivityFactoryService(bundle.get_service_name(), args[1])
+ factory = ActivityFactoryService(bundle.get_service_name(), args[0])
gtk.main()
diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py
index 8c17958..6a6ebdd 100644
--- a/sugar/activity/bundle.py
+++ b/sugar/activity/bundle.py
@@ -1,8 +1,11 @@
import logging
import os
-
from ConfigParser import ConfigParser
+from sugar import env
+
+_PYTHON_FACTORY='sugar-activity-factory'
+
class Bundle:
"""Info about an activity bundle. Wraps the activity.info file."""
def __init__(self, path):
@@ -38,11 +41,18 @@ class Bundle:
self._valid = False
logging.error('%s must specify a name' % self._path)
- if cp.has_option(section, 'exec'):
+ if cp.has_option(section, 'class'):
+ self._class = cp.get(section, 'class')
+ self._exec = '%s %s --bundle-path=%s' % (
+ os.path.join(env.get_shell_bin_dir(), _PYTHON_FACTORY),
+ self._class, self.get_path())
+ elif cp.has_option(section, 'exec'):
+ self._class = None
self._exec = cp.get(section, 'exec')
else:
+ self._exec = None
self._valid = False
- logging.error('%s must specify an exec' % self._path)
+ logging.error('%s must specify exec or class' % self._path)
if cp.has_option(section, 'show_launcher'):
if cp.get(section, 'show_launcher') == 'no':
@@ -94,6 +104,10 @@ class Bundle:
"""Get the command to execute to launch the activity factory"""
return self._exec
+ def get_class(self):
+ """Get the main Activity class"""
+ return self._exec
+
def get_show_launcher(self):
"""Get whether there should be a visible launcher for the activity"""
return self._show_launcher
diff --git a/sugar/activity/bundleregistry.py b/sugar/activity/bundleregistry.py
index ccf3b79..08f543f 100644
--- a/sugar/activity/bundleregistry.py
+++ b/sugar/activity/bundleregistry.py
@@ -11,13 +11,8 @@ class _ServiceManager(object):
self._path = env.get_user_service_dir()
def add(self, bundle):
- name = bundle.get_service_name()
-
- # FIXME evil hack. Probably need to fix Exec spec
- full_exec = env.get_shell_bin_dir() + '/' + bundle.get_exec()
- full_exec += ' ' + bundle.get_path()
-
- util.write_service(name, full_exec, self._path)
+ util.write_service(bundle.get_service_name(),
+ bundle.get_exec(), self._path)
class BundleRegistry(gobject.GObject):
"""Service that tracks the available activity bundles"""