Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
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
parentca2b08f8b6fb1bc54a4e4f9cfc457f57cf958c7f (diff)
More cleanups and some fixes
-rw-r--r--shell/Emulator.py27
-rw-r--r--shell/Makefile.am6
-rw-r--r--shell/Process.py16
-rw-r--r--shell/Session.py75
-rwxr-xr-xshell/Shell.py18
-rwxr-xr-xshell/sugar6
-rw-r--r--sugar/Makefile.am1
-rw-r--r--sugar/__init__.py11
-rw-r--r--sugar/activity/Activity.py13
-rw-r--r--sugar/theme.py10
10 files changed, 78 insertions, 105 deletions
diff --git a/shell/Emulator.py b/shell/Emulator.py
new file mode 100644
index 0000000..982fc21
--- /dev/null
+++ b/shell/Emulator.py
@@ -0,0 +1,27 @@
+import os
+
+from Process import Process
+
+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 Emulator:
+ """The OLPC emulator"""
+
+ def __init__(self):
+ pass
+
+ def start(self):
+ process = XephyrProcess()
+ process.start()
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 486c497..ff0a450 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -2,12 +2,14 @@ bin_SCRIPTS = sugar
sugardir = $(pkgdatadir)/shell
sugar_PYTHON = \
- __init__.py \
+ __init__.py \
ActivityRegistry.py \
ConsoleLogger.py \
- Owner.py \
+ Emulator.py \
+ Owner.py \
HomeWindow.py \
PresenceWindow.py \
+ Process.py \
Session.py \
Shell.py
diff --git a/shell/Process.py b/shell/Process.py
new file mode 100644
index 0000000..fcbf779
--- /dev/null
+++ b/shell/Process.py
@@ -0,0 +1,16 @@
+import gobject
+
+class Process:
+ def __init__(self, command):
+ self._pid = None
+ self._command = command
+
+ def get_name(self):
+ return self._command
+
+ def start(self):
+ args = self._command.split()
+ flags = gobject.SPAWN_SEARCH_PATH or gobject.SPAWN_STDERR_TO_DEV_NULL
+ result = gobject.spawn_async(args, flags=flags, standard_output=True)
+ self._pid = result[0]
+ self._stdout = result[2]
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()
diff --git a/shell/Shell.py b/shell/Shell.py
index d8befd5..d0fc59f 100755
--- a/shell/Shell.py
+++ b/shell/Shell.py
@@ -1,6 +1,5 @@
import dbus
import gtk
-import gobject
import wnck
from sugar.LogWriter import LogWriter
@@ -33,15 +32,8 @@ class ShellDbusService(dbus.service.Object):
def toggle_console(self):
self._shell.toggle_console()
-class Shell(gobject.GObject):
- __gsignals__ = {
- 'close': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([])),
- }
-
+class Shell:
def __init__(self):
- gobject.GObject.__init__(self)
-
self._screen = wnck.screen_get_default()
def start(self):
@@ -132,11 +124,3 @@ class Shell(gobject.GObject):
def get_registry(self):
return self._registry
-
-if __name__ == "__main__":
- shell = Shell()
- shell.start()
- try:
- gtk.main()
- except KeyboardInterrupt:
- print 'Ctrl+c pressed, exiting...'
diff --git a/shell/sugar b/shell/sugar
index 1a5d1ad..528aa19 100755
--- a/shell/sugar
+++ b/shell/sugar
@@ -5,6 +5,8 @@ import os
import pwd
import random
+from Emulator import Emulator
+
def add_to_python_path(path):
sys.path.insert(0, path)
if os.environ.has_key('PYTHONPATH'):
@@ -13,6 +15,10 @@ def add_to_python_path(path):
else:
os.environ['PYTHONPATH'] = path
+# FIXE Don't run the emulator on the OLPC
+emulator = Emulator()
+emulator.start()
+
i = 0
for arg in sys.argv:
if arg == '--test-user':
diff --git a/sugar/Makefile.am b/sugar/Makefile.am
index c69d4b2..228c624 100644
--- a/sugar/Makefile.am
+++ b/sugar/Makefile.am
@@ -7,6 +7,7 @@ sugar_PYTHON = \
bots.py \
env.py \
keybindings.py \
+ theme.py \
util.py \
LogWriter.py
diff --git a/sugar/__init__.py b/sugar/__init__.py
index 5ecc9df..e69de29 100644
--- a/sugar/__init__.py
+++ b/sugar/__init__.py
@@ -1,11 +0,0 @@
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-settings = gtk.settings_get_default()
-
-if settings.get_property('gtk-theme-name') != 'olpc':
- settings.set_string_property('gtk-theme-name', 'olpc', '')
-
-if settings.get_property('gtk-icon-theme-name') != 'olpc':
- settings.set_string_property('gtk-icon-theme-name', 'olpc', '')
diff --git a/sugar/activity/Activity.py b/sugar/activity/Activity.py
index bbccb9c..220d5e9 100644
--- a/sugar/activity/Activity.py
+++ b/sugar/activity/Activity.py
@@ -11,6 +11,7 @@ import gtk, gobject
from sugar.LogWriter import LogWriter
from sugar import keybindings
import sugar.util
+import sugar.theme
SHELL_SERVICE_NAME = "caom.redhat.Sugar.Shell"
SHELL_SERVICE_PATH = "/com/redhat/Sugar/Shell"
@@ -82,18 +83,10 @@ def create(activity_name, service = None, args = None):
else:
factory.create()
-def _get_registry():
- bus = dbus.SessionBus()
- proxy_obj = bus.get_object("com.redhat.Sugar.ActivityRegistry",
- "/com/redhat/Sugar/ActivityRegistry")
- return dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityRegistry")
-
-def list_activities():
- registry = _get_registry()
- return registry.list_activities()
-
def main(activity_name, activity_class):
"""Starts the activity main loop."""
+ sugar.theme.setup()
+
log_writer = LogWriter(activity_name)
log_writer.start()
diff --git a/sugar/theme.py b/sugar/theme.py
new file mode 100644
index 0000000..628d188
--- /dev/null
+++ b/sugar/theme.py
@@ -0,0 +1,10 @@
+import gtk
+
+def setup():
+ settings = gtk.settings_get_default()
+
+ if settings.get_property('gtk-theme-name') != 'olpc':
+ settings.set_string_property('gtk-theme-name', 'olpc', '')
+
+ if settings.get_property('gtk-icon-theme-name') != 'olpc':
+ settings.set_string_property('gtk-icon-theme-name', 'olpc', '')