Make sugar-activity-factory just a wrapper.

This commit is contained in:
Marco Pesenti Gritti 2007-02-22 14:11:50 +01:00
parent 1b5ac988d7
commit 995c59cb3e
2 changed files with 17 additions and 22 deletions

View File

@ -18,21 +18,6 @@
import sys import sys
import pygtk
pygtk.require('2.0')
import gobject
import gtk
import dbus.glib
# Work around for dbus mutex locking issue
gobject.threads_init()
dbus.glib.threads_init()
from sugar.activity import activityfactoryservice from sugar.activity import activityfactoryservice
sys.path.insert(0, sys.argv[2]) activityfactoryservice.run(sys.argv)
activityfactoryservice.start(sys.argv[1], sys.argv[2])
gtk.main()

View File

@ -16,16 +16,24 @@
# Boston, MA 02111-1307, USA. # Boston, MA 02111-1307, USA.
import os import os
import sys
import gobject
import gtk
import dbus import dbus
import dbus.service import dbus.service
import dbus.glib
from sugar.activity.bundle import Bundle from sugar.activity.bundle import Bundle
from sugar.activity import activityhandle from sugar.activity import activityhandle
from sugar import logger from sugar import logger
# Work around for dbus mutex locking issue
gobject.threads_init()
dbus.glib.threads_init()
class ActivityFactoryService(dbus.service.Object): class ActivityFactoryService(dbus.service.Object):
"""Dbus service that takes care of creating new instances of an activity""" """D-Bus service that creates new instances of an activity"""
def __init__(self, service_name, activity_class): def __init__(self, service_name, activity_class):
self._activities = [] self._activities = []
@ -67,15 +75,17 @@ class ActivityFactoryService(dbus.service.Object):
if len(self._activities) == 0: if len(self._activities) == 0:
gtk.main_quit() gtk.main_quit()
def start(activity_class, bundle_path): def run(args):
"""Start the activity factory.""" """Start the activity factory."""
bundle = Bundle(bundle_path) sys.path.insert(0, args[2])
bundle = Bundle(args[2])
logger.start(bundle.get_name()) logger.start(bundle.get_name())
os.environ['SUGAR_BUNDLE_PATH'] = bundle_path os.environ['SUGAR_BUNDLE_PATH'] = args[2]
os.environ['SUGAR_BUNDLE_SERVICE_NAME'] = bundle.get_service_name() os.environ['SUGAR_BUNDLE_SERVICE_NAME'] = bundle.get_service_name()
os.environ['SUGAR_BUNDLE_DEFAULT_TYPE'] = bundle.get_default_type() os.environ['SUGAR_BUNDLE_DEFAULT_TYPE'] = bundle.get_default_type()
factory = ActivityFactoryService(bundle.get_service_name(), factory = ActivityFactoryService(bundle.get_service_name(), args[1])
activity_class) gtk.main()