Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-31 11:06:28 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-31 11:06:28 (GMT)
commitcb285aba06dea2c2155522f5eeb74a793d96868c (patch)
treedd30bd19995504747eda9b715cbce0453a1c0319
parent92f37d31da17cb8e19295e62584ee58e88c83a77 (diff)
Get running activities to work. Still hacky.
-rw-r--r--dbus-uninstalled.conf1
-rwxr-xr-xshell/sugar-activity-factory3
-rw-r--r--shell/view/ActivityHost.py8
-rw-r--r--shell/view/Shell.py2
-rw-r--r--sugar/__installed__.py.in1
-rw-r--r--sugar/__uninstalled__.py1
-rw-r--r--sugar/activity/bundle.py26
-rw-r--r--sugar/activity/bundleregistry.py25
-rw-r--r--sugar/env.py3
-rw-r--r--tests/bundle/Test.activity/activity/activity.info2
-rw-r--r--tests/bundle/Test.activity/testactivity.py5
11 files changed, 61 insertions, 16 deletions
diff --git a/dbus-uninstalled.conf b/dbus-uninstalled.conf
index 384c8a3..fbed2d6 100644
--- a/dbus-uninstalled.conf
+++ b/dbus-uninstalled.conf
@@ -11,6 +11,7 @@
<listen>unix:tmpdir=/tmp</listen>
<servicedir>/tmp/sugar</servicedir>
+ <servicedir>/tmp/sugar-services</servicedir>
<policy context="default">
<!-- Allow everything to be sent -->
diff --git a/shell/sugar-activity-factory b/shell/sugar-activity-factory
index 66a9f07..4f4ba0d 100755
--- a/shell/sugar-activity-factory
+++ b/shell/sugar-activity-factory
@@ -41,6 +41,9 @@ logger.start(sys.argv[1])
logging.info('Starting activity factory %s' % sys.argv[1])
+if len(sys.argv) > 3:
+ sys.path.append(sys.argv[3])
+
ActivityFactory.register_factory(sys.argv[1], sys.argv[2])
gtk.main()
diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py
index 61b7078..ceeeeed 100644
--- a/shell/view/ActivityHost.py
+++ b/shell/view/ActivityHost.py
@@ -42,7 +42,7 @@ class ActivityChatWindow(gtk.Window):
self.add(chat_widget)
class ActivityHost:
- def __init__(self, window):
+ def __init__(self, shell_model, window):
self._window = window
self._xid = window.get_xid()
self._pservice = PresenceService.get_instance()
@@ -56,8 +56,14 @@ class ActivityHost:
self._type = self._activity.get_type()
self._gdk_window = gtk.gdk.window_foreign_new(self._xid)
+ # FIXME Old activity registry support, cleanup
registry = conf.get_activity_registry()
info = registry.get_activity(self._type)
+
+ if not info:
+ registry = shell_model.get_bundle_registry()
+ info = registry.get_bundle(self._type)
+
self._icon_name = info.get_icon()
try:
diff --git a/shell/view/Shell.py b/shell/view/Shell.py
index deaa889..401c935 100644
--- a/shell/view/Shell.py
+++ b/shell/view/Shell.py
@@ -96,7 +96,7 @@ class Shell(gobject.GObject):
def __window_opened_cb(self, screen, window):
if window.get_window_type() == wnck.WINDOW_NORMAL:
- activity_host = ActivityHost(window)
+ activity_host = ActivityHost(self.get_model(), window)
self._hosts[activity_host.get_xid()] = activity_host
self.emit('activity-opened', activity_host)
diff --git a/sugar/__installed__.py.in b/sugar/__installed__.py.in
index e844b84..832fca5 100644
--- a/sugar/__installed__.py.in
+++ b/sugar/__installed__.py.in
@@ -4,3 +4,4 @@ sugar_activities_dir = '@prefix@/share/sugar/activities'
sugar_activity_info_dir = '@prefix@/share/sugar/activities'
sugar_services_dir = '@prefix@/share/sugar/services'
sugar_dbus_config = '@prefix@/share/sugar/dbus-installed.conf'
+sugar_shell_bin_dir = '@prefix@/bin'
diff --git a/sugar/__uninstalled__.py b/sugar/__uninstalled__.py
index 6cd4d22..e0bfc29 100644
--- a/sugar/__uninstalled__.py
+++ b/sugar/__uninstalled__.py
@@ -9,3 +9,4 @@ sugar_services_dir = os.path.join(_sourcedir, 'services')
sugar_activity_info_dir = _tmpdir
sugar_activities_dir = os.path.join(_sourcedir, 'activities')
sugar_dbus_config = os.path.join(_sourcedir, 'dbus-uninstalled.conf')
+sugar_shell_bin_dir = os.path.join(_sourcedir, 'shell')
diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py
index 286c979..72d50fe 100644
--- a/sugar/activity/bundle.py
+++ b/sugar/activity/bundle.py
@@ -1,15 +1,25 @@
import logging
+import os
+
from ConfigParser import ConfigParser
class Bundle:
"""Info about an activity bundle. Wraps the activity.info file."""
- def __init__(self, info_path):
+ def __init__(self, path):
self._name = None
self._icon = None
self._service_name = None
self._show_launcher = False
self._valid = True
+ self._path = path
+
+ info_path = os.path.join(path, 'activity', 'activity.info')
+ if os.path.isfile(info_path):
+ self._parse_info(info_path)
+ else:
+ self._valid = False
+ def _parse_info(self, info_path):
cp = ConfigParser()
cp.read([info_path])
@@ -19,19 +29,19 @@ class Bundle:
self._service_name = cp.get(section, 'service_name')
else:
self._valid = False
- logging.error('%s must specify a service name' % info_path)
+ logging.error('%s must specify a service name' % self._path)
if cp.has_option(section, 'name'):
self._name = cp.get(section, 'name')
else:
self._valid = False
- logging.error('%s must specify a name' % info_path)
+ logging.error('%s must specify a name' % self._path)
if cp.has_option(section, 'exec'):
self._exec = cp.get(section, 'exec')
else:
self._valid = False
- logging.error('%s must specify an exec' % info_path)
+ logging.error('%s must specify an exec' % self._path)
if cp.has_option(section, 'show_launcher'):
if cp.get(section, 'show_launcher') == 'yes':
@@ -43,6 +53,10 @@ class Bundle:
def is_valid(self):
return self._valid
+ def get_path(self):
+ """Get the activity bundle path."""
+ return self._path
+
def get_name(self):
"""Get the activity user visible name."""
return self._name
@@ -62,3 +76,7 @@ class Bundle:
def get_show_launcher(self):
"""Get whether there should be a visible launcher for the activity"""
return self._show_launcher
+
+ # Compatibility with the old activity registry, remove after BTest-1
+ def get_id(self):
+ return self._service_name
diff --git a/sugar/activity/bundleregistry.py b/sugar/activity/bundleregistry.py
index 8ee1a98..1d563e8 100644
--- a/sugar/activity/bundleregistry.py
+++ b/sugar/activity/bundleregistry.py
@@ -2,6 +2,7 @@ import os
from ConfigParser import ConfigParser
from sugar.activity.bundle import Bundle
+from sugar import env
class _ServiceParser(ConfigParser):
def optionxform(self, option):
@@ -21,8 +22,15 @@ class _ServiceManager(object):
section = 'D-BUS Service'
service_cp.add_section(section)
- service_cp.set(section, 'Name', name)
- service_cp.set(section, 'Exec', bundle.get_exec())
+
+ # Compatibility with the old activity registry, remove after BTest-1
+ # service_cp.set(section, 'Name', name)
+ service_cp.set(section, 'Name', name + '.Factory')
+
+ # FIXME total hack
+ full_exec = env.get_shell_bin_dir() + '/' + bundle.get_exec()
+ full_exec += ' ' + bundle.get_path()
+ service_cp.set(section, 'Exec', full_exec)
dest = os.path.join(self._path, name + '.service')
fileobject = open(dest, 'w')
@@ -60,10 +68,9 @@ class BundleRegistry:
bundle_dir.endswith('.activity'):
self._add_bundle(bundle_dir)
- def _add_bundle(self, bundle_dir):
- info_path = os.path.join(bundle_dir, 'activity', 'activity.info')
- if os.path.isfile(info_path):
- bundle = Bundle(info_path)
- if bundle.is_valid():
- self._bundles[bundle.get_service_name()] = bundle
- self._service_manager.add(bundle)
+ def _add_bundle(self, bundle_path):
+ bundle = Bundle(bundle_path)
+ print bundle
+ if bundle.is_valid():
+ self._bundles[bundle.get_service_name()] = bundle
+ self._service_manager.add(bundle)
diff --git a/sugar/env.py b/sugar/env.py
index 2109c2d..bbe53be 100644
--- a/sugar/env.py
+++ b/sugar/env.py
@@ -56,3 +56,6 @@ def get_dbus_config():
def get_bundles_path():
return os.path.join(get_profile_path(), 'bundles')
+
+def get_shell_bin_dir():
+ return sugar_shell_bin_dir
diff --git a/tests/bundle/Test.activity/activity/activity.info b/tests/bundle/Test.activity/activity/activity.info
index 482cd9d..d8c2c45 100644
--- a/tests/bundle/Test.activity/activity/activity.info
+++ b/tests/bundle/Test.activity/activity/activity.info
@@ -2,4 +2,4 @@
name = Test
service_name = org.laptop.Test
icon = activity-sketch
-exec = bu
+exec = sugar-activity-factory org.laptop.Test testactivity.TestActivity
diff --git a/tests/bundle/Test.activity/testactivity.py b/tests/bundle/Test.activity/testactivity.py
new file mode 100644
index 0000000..34cf8b4
--- /dev/null
+++ b/tests/bundle/Test.activity/testactivity.py
@@ -0,0 +1,5 @@
+from sugar.activity.Activity import Activity
+
+class TestActivity(Activity):
+ def __init__(self):
+ Activity.__init__(self)