Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-03-09 20:36:20 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-03-09 20:36:20 (GMT)
commitf5c60b44c17fbaba6d6603fac70142a1f7cb38c3 (patch)
tree7f5543dad9f7a9294b7a67c3c90ffccaab905f8c /shell
parentf1aa2cf11a9a9429a70f7cc27cb7ae7122f28b01 (diff)
parentcc7ad2d42be9ca426f7d9a903bc2513634b5c873 (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
Diffstat (limited to 'shell')
-rwxr-xr-xshell/sugar-activity71
-rwxr-xr-xshell/sugar-activity-factory8
-rwxr-xr-xshell/sugar-shell17
3 files changed, 69 insertions, 27 deletions
diff --git a/shell/sugar-activity b/shell/sugar-activity
index 6f5c974..7757a76 100755
--- a/shell/sugar-activity
+++ b/shell/sugar-activity
@@ -18,30 +18,63 @@
import sys
import os
-import gobject
+from ConfigParser import ConfigParser
-from sugar.activity import activityfactory
from sugar import env
-from sugar import util
-def _success_cb(handler, activity, loop):
- activity.start(util.unique_id())
- loop.quit()
+# Setup the environment so that we run inside the Sugar shell
+cp = ConfigParser()
+cp.read([env.get_profile_path("session.info")])
+os.environ['DBUS_SESSION_BUS_ADDRESS'] = cp.get('Session', 'dbus_address')
+os.environ['DISPLAY'] = cp.get('Session', 'display')
+del cp
+
+import gtk
+import dbus
+import dbus.glib
+
+from sugar.activity import bundleregistry
+from sugar.activity import activityfactory
+from sugar.activity import activityfactoryservice
+
+def _success_cb(handler, exit):
+ if exit:
+ gtk.main_quit()
+
+def _error_cb(handler, err):
+ print err
+ gtk.main_quit()
+
+def print_help(self):
+ sys.exit(0)
+
+bundle = None
+
+if len(sys.argv) > 1:
+ registry = bundleregistry.get_registry()
+ bundle = registry.find_bundle(sys.argv[1])
-def _error_cb(handler, err, loop):
- loop.quit()
+if bundle == None:
+ print 'Usage:\n\n' \
+ 'sugar-activity [bundle]\n\n' \
+ 'Bundle can be a part of the service name or of bundle name.'
+ sys.exit(0)
-ppath = env.get_profile_path()
-bus_file = os.path.join(ppath, "session_bus_address")
-f = open(bus_file, "r")
-bus_name = f.read()
-f.close()
-os.environ['DBUS_SESSION_BUS_ADDRESS'] = bus_name
+bus = dbus.SessionBus()
+bus_object = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
+try:
+ name = bus_object.GetNameOwner(
+ bundle.get_service_name(), dbus_interface='org.freedesktop.DBus')
+except dbus.DBusException:
+ name = None
-loop = gobject.MainLoop()
+if name:
+ print '%s is already running, creating a new instance.' % service_name
+else:
+ activityfactoryservice.run(bundle.get_path())
-handler = activityfactory.create(sys.argv[1])
-handler.connect('success', _success_cb, loop)
-handler.connect('error', _error_cb, loop)
+handler = activityfactory.create(bundle.get_service_name())
+handler.connect('success', _success_cb, name != None)
+handler.connect('error', _error_cb)
-loop.run()
+gtk.main()
diff --git a/shell/sugar-activity-factory b/shell/sugar-activity-factory
index 009b460..a144f34 100755
--- a/shell/sugar-activity-factory
+++ b/shell/sugar-activity-factory
@@ -18,6 +18,12 @@
import sys
+import pygtk
+pygtk.require('2.0')
+import gtk
+
from sugar.activity import activityfactoryservice
-activityfactoryservice.run(sys.argv)
+activityfactoryservice.run_with_args(sys.argv)
+
+gtk.main()
diff --git a/shell/sugar-shell b/shell/sugar-shell
index 4b67e96..24eb751 100755
--- a/shell/sugar-shell
+++ b/shell/sugar-shell
@@ -18,9 +18,7 @@
import sys
import os
-
-if len(sys.argv) == 2:
- sys.path.insert(0, sys.argv[1])
+from ConfigParser import ConfigParser
import pygtk
pygtk.require('2.0')
@@ -35,8 +33,7 @@ from sugar import TracebackUtils
logger.cleanup()
logger.start('shell')
-if len(sys.argv) == 1:
- sys.path.insert(0, env.get_shell_path())
+sys.path.insert(0, env.get_shell_path())
from view.Shell import Shell
from model.ShellModel import ShellModel
@@ -55,9 +52,15 @@ if not key or not len(key):
#
# WARNING!!! this is going away at some near future point, do not rely on it
#
-dsba_file = os.path.join(env.get_profile_path(), "session_bus_address")
+dsba_file = os.path.join(env.get_profile_path(), "session.info")
f = open(dsba_file, "w")
-f.write(os.environ["DBUS_SESSION_BUS_ADDRESS"])
+
+cp = ConfigParser()
+cp.add_section('Session')
+cp.set('Session', 'dbus_address', os.environ['DBUS_SESSION_BUS_ADDRESS'])
+cp.set('Session', 'display', gtk.gdk.display_get_default().get_name())
+cp.write(f)
+
f.close()
model = ShellModel()