Basic implementation of the shutdown graphics
This commit is contained in:
+9
-1
@@ -29,9 +29,11 @@ from view.ActivityHost import ActivityHost
|
||||
from sugar.activity import ActivityFactory
|
||||
from sugar.activity import Activity
|
||||
from view.frame.Frame import Frame
|
||||
from model.ShellModel import ShellModel
|
||||
from hardwaremanager import HardwareManager
|
||||
from _sugar import KeyGrabber
|
||||
from _sugar import AudioManager
|
||||
from sugar import env
|
||||
import sugar
|
||||
|
||||
class Shell(gobject.GObject):
|
||||
@@ -107,6 +109,7 @@ class Shell(gobject.GObject):
|
||||
# For non-OLPC machines
|
||||
self._key_grabber.grab('<alt>f')
|
||||
self._key_grabber.grab('<alt>o')
|
||||
self._key_grabber.grab('<alt><shift>s')
|
||||
|
||||
def _key_pressed_cb(self, grabber, key):
|
||||
if key == 'F1':
|
||||
@@ -149,7 +152,7 @@ class Shell(gobject.GObject):
|
||||
self.toggle_chat_visibility()
|
||||
elif key == '0x93': # Frame key
|
||||
self._frame.notify_key_press()
|
||||
elif key == '0x7C': # Power key
|
||||
elif key == '0x7C' or key == '<alt><shift>s': # Power key
|
||||
self._shutdown()
|
||||
elif key == '0xEC': # Keyboard brightness
|
||||
self._hw_manager.toggle_keyboard_brightness()
|
||||
@@ -166,6 +169,11 @@ class Shell(gobject.GObject):
|
||||
console.toggle_visibility()
|
||||
|
||||
def _shutdown(self):
|
||||
self._model.props.state = ShellModel.STATE_SHUTDOWN
|
||||
if not env.is_emulator():
|
||||
self._shutdown_system()
|
||||
|
||||
def _shutdown_system(self):
|
||||
bus = dbus.SystemBus()
|
||||
proxy = bus.get_object('org.freedesktop.Hal',
|
||||
'/org/freedesktop/Hal/devices/computer')
|
||||
|
||||
@@ -18,8 +18,10 @@ import hippo
|
||||
|
||||
from view.home.activitiesdonut import ActivitiesDonut
|
||||
from view.home.MyIcon import MyIcon
|
||||
from model.ShellModel import ShellModel
|
||||
from sugar.graphics.grid import Grid
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics.iconcolor import IconColor
|
||||
|
||||
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
__gtype_name__ = 'SugarHomeBox'
|
||||
@@ -36,6 +38,17 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
style.apply_stylesheet(self._my_icon, 'home.MyIcon')
|
||||
self.append(self._my_icon, hippo.PACK_FIXED)
|
||||
|
||||
shell.get_model().connect('notify::state',
|
||||
self._shell_state_changed_cb)
|
||||
|
||||
def _shell_state_changed_cb(self, model, pspec):
|
||||
# FIXME handle all possible mode switches
|
||||
if model.props.state == ShellModel.STATE_SHUTDOWN:
|
||||
if self._donut:
|
||||
self.remove(self._donut)
|
||||
self._donut = None
|
||||
self._my_icon.props.color = IconColor('insensitive')
|
||||
|
||||
def do_allocate(self, width, height):
|
||||
hippo.CanvasBox.do_allocate(self, width, height)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user