Smarter sugar-activity which can make itself the factory and open

one instance.
This commit is contained in:
Marco Pesenti Gritti
2007-03-09 16:35:53 +01:00
parent 1587218e9e
commit d3493aea9e
5 changed files with 62 additions and 33 deletions
+6 -5
View File
@@ -53,16 +53,16 @@ def _find_activity_id():
return act_id
class ActivityCreationHandler(gobject.GObject):
__gsignals__ = {
'error': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
([gobject.TYPE_PYOBJECT])),
'success': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ([])),
'error': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
([gobject.TYPE_PYOBJECT]))
}
def __init__(self, service_name, activity_handle):
gobject.GObject.__init__(self)
self._service_name = service_name
self._activity_handle = activity_handle
@@ -83,6 +83,7 @@ class ActivityCreationHandler(gobject.GObject):
def _reply_handler(self, xid):
logging.debug("Activity created %s (%s)." %
(self._activity_handle.activity_id, self._service_name))
self.emit('success')
def _error_handler(self, err):
logging.debug("Couldn't create activity %s (%s): %s" %
+9 -6
View File
@@ -77,22 +77,25 @@ class ActivityFactoryService(dbus.service.Object):
if len(self._activities) == 0:
gtk.main_quit()
def run(args):
def run_with_args(args):
"""Start the activity factory."""
parser = OptionParser()
parser.add_option("-p", "--bundle-path", dest="bundle_path",
help="path to the activity bundle")
(options, args) = parser.parse_args()
sys.path.insert(0, options.bundle_path)
run(options.bundle_path)
bundle = Bundle(options.bundle_path)
def run(bundle_path):
sys.path.insert(0, bundle_path)
bundle = Bundle(bundle_path)
logger.start(bundle.get_name())
os.environ['SUGAR_BUNDLE_PATH'] = options.bundle_path
os.environ['SUGAR_BUNDLE_PATH'] = 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[0])
gtk.main()
factory = ActivityFactoryService(bundle.get_service_name(),
bundle.get_class())
+3 -3
View File
@@ -43,8 +43,8 @@ class Bundle:
if cp.has_option(section, 'class'):
self._class = cp.get(section, 'class')
self._exec = '%s %s --bundle-path="%s"' % (
env.get_bin_path(_PYTHON_FACTORY), self._class, self.get_path())
self._exec = '%s --bundle-path="%s"' % (
env.get_bin_path(_PYTHON_FACTORY), self.get_path())
elif cp.has_option(section, 'exec'):
self._class = None
self._exec = cp.get(section, 'exec')
@@ -105,7 +105,7 @@ class Bundle:
def get_class(self):
"""Get the main Activity class"""
return self._exec
return self._class
def get_show_launcher(self):
"""Get whether there should be a visible launcher for the activity"""