CLeanup emulator shutdown

This commit is contained in:
Marco Pesenti Gritti 2007-03-09 13:53:26 +01:00
parent 6afd512d55
commit 73c1dbe4a7
5 changed files with 12 additions and 30 deletions

View File

@ -3,8 +3,7 @@ SUBDIRS = lib po shell sugar services tools
ACLOCAL_AMFLAGS = -I m4
bin_SCRIPTS = \
sugar-emulator \
sugar-emulator-shutdown
sugar-emulator
DISTCLEANFILES = \
intltool-extract \

View File

@ -5,5 +5,3 @@
<Alt>n=next
<Alt>p=prev
<Alt>c=close
<Alt>q=!sugar-emulator-shutdown

View File

@ -1,3 +1,6 @@
import os
import signal
import dbus
import gobject
@ -34,7 +37,8 @@ _actions_table = {
'0xEB' : 'rotate',
'<alt>r' : 'rotate',
'0xEC' : 'keyboard_brightness',
'<alt>Tab' : 'home'
'<alt>Tab' : 'home',
'<alt>q' : 'quit_emulator',
}
class KeyHandler(object):
@ -149,6 +153,11 @@ class KeyHandler(object):
gobject.spawn_async(['xrandr', '-o', states[self._screen_rotation]],
flags=gobject.SPAWN_SEARCH_PATH)
def handle_quit_emulator(self):
if os.environ.has_key('SUGAR_EMULATOR_PID'):
pid = int(os.environ['SUGAR_EMULATOR_PID'])
os.kill(pid, signal.SIGTERM)
def handle_home(self):
# FIXME: finish alt+tab support
pass

View File

@ -1,24 +0,0 @@
#!/usr/bin/env python
# Copyright (C) 2006, Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
import signal
if os.environ.has_key('SUGAR_XEPHYR_PID'):
pid = int(os.environ['SUGAR_XEPHYR_PID'])
os.kill(pid, signal.SIGTERM)

View File

@ -98,7 +98,7 @@ class XephyrProcess(Process):
def start(self, standard_output=False):
Process.start(self)
os.environ['DISPLAY'] = ":%d" % (self._display)
os.environ['SUGAR_XEPHYR_PID'] = '%d' % self.pid
os.environ['SUGAR_EMULATOR_PID'] = '%d' % self.pid
class Emulator(object):
"""The OLPC emulator"""