Get running activities to work. Still hacky.
This commit is contained in:
parent
92f37d31da
commit
cb285aba06
@ -11,6 +11,7 @@
|
|||||||
<listen>unix:tmpdir=/tmp</listen>
|
<listen>unix:tmpdir=/tmp</listen>
|
||||||
|
|
||||||
<servicedir>/tmp/sugar</servicedir>
|
<servicedir>/tmp/sugar</servicedir>
|
||||||
|
<servicedir>/tmp/sugar-services</servicedir>
|
||||||
|
|
||||||
<policy context="default">
|
<policy context="default">
|
||||||
<!-- Allow everything to be sent -->
|
<!-- Allow everything to be sent -->
|
||||||
|
@ -41,6 +41,9 @@ logger.start(sys.argv[1])
|
|||||||
|
|
||||||
logging.info('Starting activity factory %s' % 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])
|
ActivityFactory.register_factory(sys.argv[1], sys.argv[2])
|
||||||
|
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
@ -42,7 +42,7 @@ class ActivityChatWindow(gtk.Window):
|
|||||||
self.add(chat_widget)
|
self.add(chat_widget)
|
||||||
|
|
||||||
class ActivityHost:
|
class ActivityHost:
|
||||||
def __init__(self, window):
|
def __init__(self, shell_model, window):
|
||||||
self._window = window
|
self._window = window
|
||||||
self._xid = window.get_xid()
|
self._xid = window.get_xid()
|
||||||
self._pservice = PresenceService.get_instance()
|
self._pservice = PresenceService.get_instance()
|
||||||
@ -56,8 +56,14 @@ class ActivityHost:
|
|||||||
self._type = self._activity.get_type()
|
self._type = self._activity.get_type()
|
||||||
self._gdk_window = gtk.gdk.window_foreign_new(self._xid)
|
self._gdk_window = gtk.gdk.window_foreign_new(self._xid)
|
||||||
|
|
||||||
|
# FIXME Old activity registry support, cleanup
|
||||||
registry = conf.get_activity_registry()
|
registry = conf.get_activity_registry()
|
||||||
info = registry.get_activity(self._type)
|
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()
|
self._icon_name = info.get_icon()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -96,7 +96,7 @@ class Shell(gobject.GObject):
|
|||||||
|
|
||||||
def __window_opened_cb(self, screen, window):
|
def __window_opened_cb(self, screen, window):
|
||||||
if window.get_window_type() == wnck.WINDOW_NORMAL:
|
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._hosts[activity_host.get_xid()] = activity_host
|
||||||
self.emit('activity-opened', activity_host)
|
self.emit('activity-opened', activity_host)
|
||||||
|
|
||||||
|
@ -4,3 +4,4 @@ sugar_activities_dir = '@prefix@/share/sugar/activities'
|
|||||||
sugar_activity_info_dir = '@prefix@/share/sugar/activities'
|
sugar_activity_info_dir = '@prefix@/share/sugar/activities'
|
||||||
sugar_services_dir = '@prefix@/share/sugar/services'
|
sugar_services_dir = '@prefix@/share/sugar/services'
|
||||||
sugar_dbus_config = '@prefix@/share/sugar/dbus-installed.conf'
|
sugar_dbus_config = '@prefix@/share/sugar/dbus-installed.conf'
|
||||||
|
sugar_shell_bin_dir = '@prefix@/bin'
|
||||||
|
@ -9,3 +9,4 @@ sugar_services_dir = os.path.join(_sourcedir, 'services')
|
|||||||
sugar_activity_info_dir = _tmpdir
|
sugar_activity_info_dir = _tmpdir
|
||||||
sugar_activities_dir = os.path.join(_sourcedir, 'activities')
|
sugar_activities_dir = os.path.join(_sourcedir, 'activities')
|
||||||
sugar_dbus_config = os.path.join(_sourcedir, 'dbus-uninstalled.conf')
|
sugar_dbus_config = os.path.join(_sourcedir, 'dbus-uninstalled.conf')
|
||||||
|
sugar_shell_bin_dir = os.path.join(_sourcedir, 'shell')
|
||||||
|
@ -1,15 +1,25 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
|
|
||||||
class Bundle:
|
class Bundle:
|
||||||
"""Info about an activity bundle. Wraps the activity.info file."""
|
"""Info about an activity bundle. Wraps the activity.info file."""
|
||||||
def __init__(self, info_path):
|
def __init__(self, path):
|
||||||
self._name = None
|
self._name = None
|
||||||
self._icon = None
|
self._icon = None
|
||||||
self._service_name = None
|
self._service_name = None
|
||||||
self._show_launcher = False
|
self._show_launcher = False
|
||||||
self._valid = True
|
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 = ConfigParser()
|
||||||
cp.read([info_path])
|
cp.read([info_path])
|
||||||
|
|
||||||
@ -19,19 +29,19 @@ class Bundle:
|
|||||||
self._service_name = cp.get(section, 'service_name')
|
self._service_name = cp.get(section, 'service_name')
|
||||||
else:
|
else:
|
||||||
self._valid = False
|
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'):
|
if cp.has_option(section, 'name'):
|
||||||
self._name = cp.get(section, 'name')
|
self._name = cp.get(section, 'name')
|
||||||
else:
|
else:
|
||||||
self._valid = False
|
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'):
|
if cp.has_option(section, 'exec'):
|
||||||
self._exec = cp.get(section, 'exec')
|
self._exec = cp.get(section, 'exec')
|
||||||
else:
|
else:
|
||||||
self._valid = False
|
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.has_option(section, 'show_launcher'):
|
||||||
if cp.get(section, 'show_launcher') == 'yes':
|
if cp.get(section, 'show_launcher') == 'yes':
|
||||||
@ -43,6 +53,10 @@ class Bundle:
|
|||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
return self._valid
|
return self._valid
|
||||||
|
|
||||||
|
def get_path(self):
|
||||||
|
"""Get the activity bundle path."""
|
||||||
|
return self._path
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
"""Get the activity user visible name."""
|
"""Get the activity user visible name."""
|
||||||
return self._name
|
return self._name
|
||||||
@ -62,3 +76,7 @@ class Bundle:
|
|||||||
def get_show_launcher(self):
|
def get_show_launcher(self):
|
||||||
"""Get whether there should be a visible launcher for the activity"""
|
"""Get whether there should be a visible launcher for the activity"""
|
||||||
return self._show_launcher
|
return self._show_launcher
|
||||||
|
|
||||||
|
# Compatibility with the old activity registry, remove after BTest-1
|
||||||
|
def get_id(self):
|
||||||
|
return self._service_name
|
||||||
|
@ -2,6 +2,7 @@ import os
|
|||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
|
|
||||||
from sugar.activity.bundle import Bundle
|
from sugar.activity.bundle import Bundle
|
||||||
|
from sugar import env
|
||||||
|
|
||||||
class _ServiceParser(ConfigParser):
|
class _ServiceParser(ConfigParser):
|
||||||
def optionxform(self, option):
|
def optionxform(self, option):
|
||||||
@ -21,8 +22,15 @@ class _ServiceManager(object):
|
|||||||
|
|
||||||
section = 'D-BUS Service'
|
section = 'D-BUS Service'
|
||||||
service_cp.add_section(section)
|
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')
|
dest = os.path.join(self._path, name + '.service')
|
||||||
fileobject = open(dest, 'w')
|
fileobject = open(dest, 'w')
|
||||||
@ -60,10 +68,9 @@ class BundleRegistry:
|
|||||||
bundle_dir.endswith('.activity'):
|
bundle_dir.endswith('.activity'):
|
||||||
self._add_bundle(bundle_dir)
|
self._add_bundle(bundle_dir)
|
||||||
|
|
||||||
def _add_bundle(self, bundle_dir):
|
def _add_bundle(self, bundle_path):
|
||||||
info_path = os.path.join(bundle_dir, 'activity', 'activity.info')
|
bundle = Bundle(bundle_path)
|
||||||
if os.path.isfile(info_path):
|
print bundle
|
||||||
bundle = Bundle(info_path)
|
if bundle.is_valid():
|
||||||
if bundle.is_valid():
|
self._bundles[bundle.get_service_name()] = bundle
|
||||||
self._bundles[bundle.get_service_name()] = bundle
|
self._service_manager.add(bundle)
|
||||||
self._service_manager.add(bundle)
|
|
||||||
|
@ -56,3 +56,6 @@ def get_dbus_config():
|
|||||||
|
|
||||||
def get_bundles_path():
|
def get_bundles_path():
|
||||||
return os.path.join(get_profile_path(), 'bundles')
|
return os.path.join(get_profile_path(), 'bundles')
|
||||||
|
|
||||||
|
def get_shell_bin_dir():
|
||||||
|
return sugar_shell_bin_dir
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
name = Test
|
name = Test
|
||||||
service_name = org.laptop.Test
|
service_name = org.laptop.Test
|
||||||
icon = activity-sketch
|
icon = activity-sketch
|
||||||
exec = bu
|
exec = sugar-activity-factory org.laptop.Test testactivity.TestActivity
|
||||||
|
5
tests/bundle/Test.activity/testactivity.py
Normal file
5
tests/bundle/Test.activity/testactivity.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from sugar.activity.Activity import Activity
|
||||||
|
|
||||||
|
class TestActivity(Activity):
|
||||||
|
def __init__(self):
|
||||||
|
Activity.__init__(self)
|
Loading…
Reference in New Issue
Block a user