Cleanup kbd config passing

This commit is contained in:
Marco Pesenti Gritti 2007-03-09 13:47:17 +01:00
parent c255a7b544
commit 6afd512d55
2 changed files with 22 additions and 17 deletions

View File

@ -47,17 +47,21 @@ else:
program = sys.argv[1] program = sys.argv[1]
if gtk.gdk.screen_width() < 1200 or gtk.gdk.screen_height() < 900: if gtk.gdk.screen_width() < 1200 or gtk.gdk.screen_height() < 900:
fullscreen = True
width = -1 width = -1
height = -1 height = -1
else: else:
fullscreen = False
width = 1200 width = 1200
height = 900 height = 900
dpi = min(_sugar.get_screen_dpi(), 96) dpi = min(_sugar.get_screen_dpi(), 96)
emulator = Emulator(width, height, fullscreen, dpi) if sourcedir:
kbd_config = os.path.join(sourcedir, 'shell/data/kbdconfig')
else:
kbd_config = os.path.join(env.get_data_dir(), 'kbdconfig')
emulator = Emulator(width, height, dpi)
emulator.set_keyboard_config(kbd_config)
emulator.start() emulator.start()
if sourcedir: if sourcedir:

View File

@ -64,13 +64,13 @@ class Process:
self._stdout = result[2] self._stdout = result[2]
class MatchboxProcess(Process): class MatchboxProcess(Process):
def __init__(self): def __init__(self, kbd_config):
kbd_config = os.path.join(env.get_data_dir(), 'kbdconfig') options = '-use_titlebar no '
options = '-kbdconfig %s ' % kbd_config
options += '-use_titlebar no '
options += '-theme olpc ' options += '-theme olpc '
if kbd_config:
options = '-kbdconfig %s ' % kbd_config
command = 'matchbox-window-manager %s ' % options command = 'matchbox-window-manager %s ' % options
Process.__init__(self, command) Process.__init__(self, command)
@ -78,15 +78,14 @@ class MatchboxProcess(Process):
return 'Matchbox' return 'Matchbox'
class XephyrProcess(Process): class XephyrProcess(Process):
def __init__(self, width, height, fullscreen, dpi): def __init__(self, width, height, dpi):
self._display = get_display_number() self._display = get_display_number()
cmd = 'Xephyr :%d -ac ' % (self._display) cmd = 'Xephyr :%d -ac ' % (self._display)
if fullscreen:
cmd += ' -fullscreen '
if width > 0 and height > 0: if width > 0 and height > 0:
cmd += ' -screen %dx%d' % (width, height) cmd += ' -screen %dx%d' % (width, height)
else:
cmd += ' -fullscreen '
if dpi > 0: if dpi > 0:
cmd += ' -dpi %d' % (dpi) cmd += ' -dpi %d' % (dpi)
@ -103,20 +102,22 @@ class XephyrProcess(Process):
class Emulator(object): class Emulator(object):
"""The OLPC emulator""" """The OLPC emulator"""
def __init__(self, width, height, fullscreen, dpi): def __init__(self, width, height, dpi):
self._fullscreen = fullscreen self._keyboard_config = None
self._width = width self._width = width
self._height = height self._height = height
self._dpi = dpi self._dpi = dpi
def set_keyboard_config(self, config):
self._keyboard_config = config
def start(self): def start(self):
try: try:
process = XephyrProcess(self._width, self._height, process = XephyrProcess(self._width, self._height, self._dpi)
self._fullscreen, self._dpi)
process.start() process.start()
except: except:
print 'Cannot run the emulator. You need to install Xephyr' print 'Cannot run the emulator. You need to install Xephyr'
sys.exit(0) sys.exit(0)
process = MatchboxProcess() process = MatchboxProcess(self._keyboard_config)
process.start() process.start()