Rework the emulator. Move matchbox in the shell.
This commit is contained in:
parent
8b6af7efa5
commit
c9f28b7317
@ -1,4 +1,4 @@
|
|||||||
SUBDIRS = emulator lib po shell sugar services tools
|
SUBDIRS = lib po shell sugar services tools
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
|
@ -114,7 +114,6 @@ AM_GLIB_GNU_GETTEXT
|
|||||||
|
|
||||||
AC_OUTPUT([
|
AC_OUTPUT([
|
||||||
Makefile
|
Makefile
|
||||||
emulator/Makefile
|
|
||||||
lib/Makefile
|
lib/Makefile
|
||||||
lib/data/Makefile
|
lib/data/Makefile
|
||||||
lib/src/Makefile
|
lib/src/Makefile
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
confdir = $(pkgdatadir)/emulator
|
|
||||||
conf_DATA = kbdconfig
|
|
||||||
|
|
||||||
EXTRA_DIST = $(conf_DATA)
|
|
@ -7,7 +7,10 @@ bin_SCRIPTS = \
|
|||||||
|
|
||||||
sugardir = $(pkgdatadir)/shell
|
sugardir = $(pkgdatadir)/shell
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
shellservice.py
|
shellservice.py
|
||||||
|
|
||||||
EXTRA_DIST = $(bin_SCRIPTS)
|
confdir = $(pkgdatadir)/shell
|
||||||
|
conf_DATA = kbdconfig
|
||||||
|
|
||||||
|
EXTRA_DIST = $(bin_SCRIPTS) $(conf_DATA)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Copyright (C) 2006, Red Hat, Inc.
|
# Copyright (C) 2006, Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@ -40,6 +39,34 @@ from model.ShellModel import ShellModel
|
|||||||
from shellservice import ShellService
|
from shellservice import ShellService
|
||||||
from intro import intro
|
from intro import intro
|
||||||
|
|
||||||
|
def _start_matchbox():
|
||||||
|
cmd = ['matchbox-window-manager']
|
||||||
|
|
||||||
|
cmd.extend(['-use_titlebar', 'no'])
|
||||||
|
cmd.extend(['-theme', 'olpc'])
|
||||||
|
cmd.extend(['-kbdconfig', env.get_shell_path('kbdconfig')])
|
||||||
|
|
||||||
|
gobject.spawn_async(cmd, flags=gobject.SPAWN_SEARCH_PATH)
|
||||||
|
|
||||||
|
def _save_session_info():
|
||||||
|
# Save our DBus Session Bus address somewhere it can be found
|
||||||
|
#
|
||||||
|
# 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.info")
|
||||||
|
f = open(dsba_file, "w")
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
_save_session_info()
|
||||||
|
_start_matchbox()
|
||||||
|
|
||||||
# Do initial setup if needed
|
# Do initial setup if needed
|
||||||
key = profile.get_pubkey()
|
key = profile.get_pubkey()
|
||||||
if not key or not len(key):
|
if not key or not len(key):
|
||||||
@ -48,21 +75,6 @@ if not key or not len(key):
|
|||||||
gtk.main()
|
gtk.main()
|
||||||
profile.update()
|
profile.update()
|
||||||
|
|
||||||
# Save our DBus Session Bus address somewhere it can be found
|
|
||||||
#
|
|
||||||
# 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.info")
|
|
||||||
f = open(dsba_file, "w")
|
|
||||||
|
|
||||||
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()
|
model = ShellModel()
|
||||||
service = ShellService(model)
|
service = ShellService(model)
|
||||||
shell = Shell(model)
|
shell = Shell(model)
|
||||||
|
@ -18,17 +18,63 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import socket
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
|
import gobject
|
||||||
os.environ['SUGAR_EMULATOR'] = 'yes'
|
|
||||||
|
|
||||||
from sugar import env
|
from sugar import env
|
||||||
from sugar.emulator import Emulator
|
|
||||||
import _sugar
|
import _sugar
|
||||||
|
|
||||||
|
def _get_display_number():
|
||||||
|
"""Find a free display number trying to connect to 6000+ ports"""
|
||||||
|
retries = 20
|
||||||
|
display_number = 1
|
||||||
|
display_is_free = False
|
||||||
|
|
||||||
|
while not display_is_free and retries > 0:
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
try:
|
||||||
|
s.connect(('127.0.0.1', 6000 + display_number))
|
||||||
|
s.close()
|
||||||
|
|
||||||
|
display_number += 1
|
||||||
|
retries -= 1
|
||||||
|
except:
|
||||||
|
display_is_free = True
|
||||||
|
|
||||||
|
if display_is_free:
|
||||||
|
return display_number
|
||||||
|
else:
|
||||||
|
logging.error('Cannot find a free display.')
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
def _start_xephyr(width, height, dpi):
|
||||||
|
display = _get_display_number()
|
||||||
|
|
||||||
|
cmd = [ 'Xephyr' ]
|
||||||
|
cmd.append(':%d' % display)
|
||||||
|
cmd.append('-ac')
|
||||||
|
|
||||||
|
if width > 0 and height > 0:
|
||||||
|
cmd.append('-screen %dx%d' % (width, height))
|
||||||
|
else:
|
||||||
|
cmd.append('-fullscreen')
|
||||||
|
|
||||||
|
if dpi > 0:
|
||||||
|
cmd.append('-dpi')
|
||||||
|
cmd.append(str(dpi))
|
||||||
|
|
||||||
|
result = gobject.spawn_async(cmd, flags=gobject.SPAWN_SEARCH_PATH)
|
||||||
|
pid = result[0]
|
||||||
|
|
||||||
|
os.environ['DISPLAY'] = ":%d" % (display)
|
||||||
|
os.environ['SUGAR_EMULATOR_PID'] = str(pid)
|
||||||
|
|
||||||
|
os.environ['SUGAR_EMULATOR'] = 'yes'
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
program = 'sugar-shell'
|
program = 'sugar-shell'
|
||||||
else:
|
else:
|
||||||
@ -41,11 +87,6 @@ else:
|
|||||||
width = 1200
|
width = 1200
|
||||||
height = 900
|
height = 900
|
||||||
|
|
||||||
dpi = min(_sugar.get_screen_dpi(), 96)
|
_start_xephyr(width, height, min(_sugar.get_screen_dpi(), 96))
|
||||||
kbd_config = os.path.join(env.get_emulator_path('kbdconfig'))
|
|
||||||
|
|
||||||
emulator = Emulator(width, height, dpi)
|
|
||||||
emulator.set_keyboard_config(kbd_config)
|
|
||||||
emulator.start()
|
|
||||||
|
|
||||||
os.execlp('dbus-launch', 'dbus-launch', '--exit-with-session', program)
|
os.execlp('dbus-launch', 'dbus-launch', '--exit-with-session', program)
|
||||||
|
@ -4,7 +4,6 @@ sugardir = $(pythondir)/sugar
|
|||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
date.py \
|
date.py \
|
||||||
emulator.py \
|
|
||||||
env.py \
|
env.py \
|
||||||
logger.py \
|
logger.py \
|
||||||
profile.py \
|
profile.py \
|
||||||
|
@ -1,123 +0,0 @@
|
|||||||
# Copyright (C) 2006, Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# This library is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
|
||||||
# License as published by the Free Software Foundation; either
|
|
||||||
# version 2 of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This library is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
# Lesser General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Lesser General Public
|
|
||||||
# License along with this library; if not, write to the
|
|
||||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
# Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
import os
|
|
||||||
import socket
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import gobject
|
|
||||||
|
|
||||||
from sugar import env
|
|
||||||
|
|
||||||
def get_display_number():
|
|
||||||
"""Find a free display number trying to connect to 6000+ ports"""
|
|
||||||
retries = 20
|
|
||||||
display_number = 1
|
|
||||||
display_is_free = False
|
|
||||||
|
|
||||||
while not display_is_free and retries > 0:
|
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
||||||
try:
|
|
||||||
s.connect(('127.0.0.1', 6000 + display_number))
|
|
||||||
s.close()
|
|
||||||
|
|
||||||
display_number += 1
|
|
||||||
retries -= 1
|
|
||||||
except:
|
|
||||||
display_is_free = True
|
|
||||||
|
|
||||||
if display_is_free:
|
|
||||||
return display_number
|
|
||||||
else:
|
|
||||||
logging.error('Cannot find a free display.')
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
class Process:
|
|
||||||
"""Object representing one of the session processes"""
|
|
||||||
|
|
||||||
def __init__(self, command):
|
|
||||||
self._command = command
|
|
||||||
|
|
||||||
def get_name(self):
|
|
||||||
return self._command
|
|
||||||
|
|
||||||
def start(self, standard_output=False):
|
|
||||||
args = self._command.split()
|
|
||||||
flags = gobject.SPAWN_SEARCH_PATH
|
|
||||||
result = gobject.spawn_async(args, flags=flags,
|
|
||||||
standard_output=standard_output)
|
|
||||||
self.pid = result[0]
|
|
||||||
self._stdout = result[2]
|
|
||||||
|
|
||||||
class MatchboxProcess(Process):
|
|
||||||
def __init__(self, kbd_config):
|
|
||||||
options = '-use_titlebar no '
|
|
||||||
options += '-theme olpc '
|
|
||||||
|
|
||||||
if kbd_config:
|
|
||||||
options += '-kbdconfig %s ' % kbd_config
|
|
||||||
|
|
||||||
command = 'matchbox-window-manager %s ' % options
|
|
||||||
Process.__init__(self, command)
|
|
||||||
|
|
||||||
def get_name(self):
|
|
||||||
return 'Matchbox'
|
|
||||||
|
|
||||||
class XephyrProcess(Process):
|
|
||||||
def __init__(self, width, height, dpi):
|
|
||||||
self._display = get_display_number()
|
|
||||||
cmd = 'Xephyr :%d -ac ' % (self._display)
|
|
||||||
|
|
||||||
if width > 0 and height > 0:
|
|
||||||
cmd += ' -screen %dx%d' % (width, height)
|
|
||||||
else:
|
|
||||||
cmd += ' -fullscreen '
|
|
||||||
|
|
||||||
if dpi > 0:
|
|
||||||
cmd += ' -dpi %d' % (dpi)
|
|
||||||
|
|
||||||
Process.__init__(self, cmd)
|
|
||||||
|
|
||||||
def get_name(self):
|
|
||||||
return 'Xephyr'
|
|
||||||
|
|
||||||
def start(self, standard_output=False):
|
|
||||||
Process.start(self)
|
|
||||||
os.environ['DISPLAY'] = ":%d" % (self._display)
|
|
||||||
os.environ['SUGAR_EMULATOR_PID'] = '%d' % self.pid
|
|
||||||
|
|
||||||
class Emulator(object):
|
|
||||||
"""The OLPC emulator"""
|
|
||||||
def __init__(self, width, height, dpi):
|
|
||||||
self._keyboard_config = None
|
|
||||||
self._width = width
|
|
||||||
self._height = height
|
|
||||||
self._dpi = dpi
|
|
||||||
|
|
||||||
def set_keyboard_config(self, config):
|
|
||||||
self._keyboard_config = config
|
|
||||||
|
|
||||||
def start(self):
|
|
||||||
try:
|
|
||||||
process = XephyrProcess(self._width, self._height, self._dpi)
|
|
||||||
process.start()
|
|
||||||
except:
|
|
||||||
print 'Cannot run the emulator. You need to install Xephyr'
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
process = MatchboxProcess(self._keyboard_config)
|
|
||||||
process.start()
|
|
@ -66,6 +66,3 @@ def get_service_path(name):
|
|||||||
|
|
||||||
def get_shell_path(path=None):
|
def get_shell_path(path=None):
|
||||||
return _get_prefix_path('share/sugar/shell', path)
|
return _get_prefix_path('share/sugar/shell', path)
|
||||||
|
|
||||||
def get_emulator_path(path=None):
|
|
||||||
return _get_prefix_path('share/sugar/emulator', path)
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
VERSION=0.63
|
VERSION=0.63
|
||||||
DATE=`date +%Y%m%d`
|
DATE=`date +%Y%m%d`
|
||||||
RELEASE=2.52
|
RELEASE=2.53
|
||||||
TARBALL=sugar-$VERSION-$RELEASE.${DATE}git.tar.bz2
|
TARBALL=sugar-$VERSION-$RELEASE.${DATE}git.tar.bz2
|
||||||
|
|
||||||
rm sugar-$VERSION.tar.bz2
|
rm sugar-$VERSION.tar.bz2
|
||||||
|
Loading…
Reference in New Issue
Block a user