diff options
author | Tomeu Vizoso <tomeu@tomeuvizoso.net> | 2007-01-27 11:54:56 (GMT) |
---|---|---|
committer | Tomeu Vizoso <tomeu@tomeuvizoso.net> | 2007-01-27 11:54:56 (GMT) |
commit | 9d13a9836d10e8ef5d2dda4dff6a7931ca2af728 (patch) | |
tree | b05c8b37576e56201ebb6fb7b030e3c018da35f5 /sugar/activity | |
parent | 37c6c1e9fa9b42d7a65f2234eac61307352887c2 (diff) |
Added new tool sugar-install-bundle.
Diffstat (limited to 'sugar/activity')
-rw-r--r-- | sugar/activity/bundlebuilder.py | 8 | ||||
-rw-r--r-- | sugar/activity/bundleregistry.py | 18 |
2 files changed, 16 insertions, 10 deletions
diff --git a/sugar/activity/bundlebuilder.py b/sugar/activity/bundlebuilder.py index a2e338f..9b3a81d 100644 --- a/sugar/activity/bundlebuilder.py +++ b/sugar/activity/bundlebuilder.py @@ -68,12 +68,6 @@ def _extract_bundle(source_file, dest_dir): def _get_source_path(): return os.getcwd() -def _get_activities_path(): - path = os.path.expanduser('~/Activities') - if not os.path.isdir(path): - os.mkdir(path) - return path - def _get_bundle_dir(): bundle_name = os.path.basename(_get_source_path()) return bundle_name + '.activity' @@ -82,7 +76,7 @@ def _get_install_dir(prefix): return os.path.join(prefix, 'share/activities') def _get_bundle_path(): - return os.path.join(_get_activities_path(), _get_bundle_dir()) + return os.path.join(env.get_user_activities_dir(), _get_bundle_dir()) def _get_package_name(): bundle = Bundle(_get_source_path()) diff --git a/sugar/activity/bundleregistry.py b/sugar/activity/bundleregistry.py index 8b7c44a..22a84e1 100644 --- a/sugar/activity/bundleregistry.py +++ b/sugar/activity/bundleregistry.py @@ -1,5 +1,6 @@ import os from ConfigParser import ConfigParser +import gobject from sugar.activity.bundle import Bundle from sugar import env @@ -18,10 +19,17 @@ class _ServiceManager(object): util.write_service(name, full_exec, self._path) -class BundleRegistry: +class BundleRegistry(gobject.GObject): """Service that tracks the available activity bundles""" + __gsignals__ = { + 'bundle-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])) + } + def __init__(self): + gobject.GObject.__init__(self) + self._bundles = {} self._search_path = [] self._service_manager = _ServiceManager() @@ -54,10 +62,14 @@ class BundleRegistry: bundle_dir = os.path.join(path, f) if os.path.isdir(bundle_dir) and \ bundle_dir.endswith('.activity'): - self._add_bundle(bundle_dir) + self.add_bundle(bundle_dir) - def _add_bundle(self, bundle_path): + def add_bundle(self, bundle_path): bundle = Bundle(bundle_path) if bundle.is_valid(): self._bundles[bundle.get_service_name()] = bundle self._service_manager.add(bundle) + self.emit('bundle-added', bundle) + return True + else: + return False |