Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/Session.py
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-07-12 12:02:29 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-07-12 12:02:29 (GMT)
commitbe806eb1918f7db90e661b5fcb4e260a0b1ba669 (patch)
tree09ca8d2341d5875c1623801516a5f32bf1626063 /shell/Session.py
parentca2b08f8b6fb1bc54a4e4f9cfc457f57cf958c7f (diff)
More cleanups and some fixes
Diffstat (limited to 'shell/Session.py')
-rw-r--r--shell/Session.py75
1 files changed, 10 insertions, 65 deletions
diff --git a/shell/Session.py b/shell/Session.py
index 5f85c10..93f4b1f 100644
--- a/shell/Session.py
+++ b/shell/Session.py
@@ -1,30 +1,9 @@
import os
-import signal
-
-import gobject
+import gtk
+import sugar.theme
from Shell import Shell
-
-class Process:
- def __init__(self, command):
- self._pid = None
- self._command = command
-
- def get_name(self):
- return self._command
-
- def start(self):
- splitted_cmd = self._command.split()
- try:
- self._pid = os.spawnvp(os.P_NOWAIT, splitted_cmd[0], splitted_cmd)
- except Exception, e:
- logging.error('Cannot run %s' % (self.get_name()))
-
- def stop(self):
- # FIXME Obviously we want to notify the processes to
- # shut down rather then killing them down forcefully.
- print 'Stopping %s (%d)' % (self.get_name(), self._pid)
- os.kill(self._pid, signal.SIGTERM)
+from Process import Process
class ActivityProcess(Process):
def __init__(self, module):
@@ -36,17 +15,15 @@ class ActivityProcess(Process):
class DbusProcess(Process):
def __init__(self):
- Process.__init__(self, "/bin/dbus-daemon --session --print-address")
+ Process.__init__(self, "dbus-daemon --session --print-address")
def get_name(self):
return 'Dbus'
def start(self):
- args = self._command.split()
- (self._pid, ign1, dbus_stdout, ign3) = gobject.spawn_async(
- args, flags=gobject.SPAWN_STDERR_TO_DEV_NULL, standard_output=True)
-
- dbus_file = os.fdopen(dbus_stdout)
+ Process.start(self)
+
+ dbus_file = os.fdopen(self._stdout)
addr = dbus_file.readline()
addr = addr.strip()
dbus_file.close()
@@ -59,61 +36,29 @@ class MatchboxProcess(Process):
def get_name(self):
return 'Matchbox'
-class XephyrProcess(Process):
- def __init__(self):
- # FIXME How to pick a free display number?
- self._display = 100
- cmd = 'Xephyr :%d -ac -screen 640x480' % (self._display)
- Process.__init__(self, cmd)
-
- def get_name(self):
- return 'Xephyr'
-
- def start(self):
- Process.start(self)
- os.environ['DISPLAY'] = ":%d" % (self._display)
-
class Session:
"""Takes care of running the shell and all the sugar processes"""
def __init__(self):
- self._processes = []
-
+ sugar.theme.setup()
+
self._shell = Shell()
- self._shell.connect('close', self._shell_close_cb)
self._shell.start()
def start(self):
"""Start the session"""
- # FIXME We should not start this on the olpc
- process = XephyrProcess()
- self._processes.insert(0, process)
- process.start()
-
process = DbusProcess()
- self._processes.insert(0, process)
process.start()
process = MatchboxProcess()
- self._processes.insert(0, process)
process.start()
registry = self._shell.get_registry()
for activity_module in registry.list_activities():
process = ActivityProcess(activity_module)
- self._processes.insert(0, process)
process.start()
-
+
try:
- import gtk
gtk.main()
except KeyboardInterrupt:
print 'Ctrl+C pressed, exiting...'
- self.shutdown()
-
- def _shell_close_cb(self, shell):
- self.shutdown()
-
- def shutdown(self):
- for process in self._processes:
- process.stop()