Basic implementation of the shutdown graphics

This commit is contained in:
Marco Pesenti Gritti 2007-01-11 11:20:08 +01:00
parent dda16d83c0
commit 297381cad7
7 changed files with 57 additions and 3 deletions

View File

@ -16,6 +16,8 @@
import os import os
import gobject
from sugar.presence import PresenceService from sugar.presence import PresenceService
from sugar.activity.bundleregistry import BundleRegistry from sugar.activity.bundleregistry import BundleRegistry
from model.Friends import Friends from model.Friends import Friends
@ -24,9 +26,22 @@ from model.homemodel import HomeModel
from model.Owner import ShellOwner from model.Owner import ShellOwner
from sugar import env from sugar import env
class ShellModel: class ShellModel(gobject.GObject):
STATE_STARTUP = 0
STATE_RUNNING = 1
STATE_SHUTDOWN = 2
__gproperties__ = {
'state' : (int, None, None,
0, 2, STATE_RUNNING,
gobject.PARAM_READWRITE)
}
def __init__(self): def __init__(self):
gobject.GObject.__init__(self)
self._current_activity = None self._current_activity = None
self._state = self.STATE_RUNNING
self._bundle_registry = BundleRegistry() self._bundle_registry = BundleRegistry()
@ -47,6 +62,14 @@ class ShellModel:
bundles_path = os.path.join(path, 'activities') bundles_path = os.path.join(path, 'activities')
self._bundle_registry.add_search_path(bundles_path) self._bundle_registry.add_search_path(bundles_path)
def do_set_property(self, pspec, value):
if pspec.name == 'state':
self._state = value
def do_get_property(self, pspec):
if pspec.name == 'state':
return self._state
def get_bundle_registry(self): def get_bundle_registry(self):
return self._bundle_registry return self._bundle_registry

View File

@ -29,9 +29,11 @@ from view.ActivityHost import ActivityHost
from sugar.activity import ActivityFactory from sugar.activity import ActivityFactory
from sugar.activity import Activity from sugar.activity import Activity
from view.frame.Frame import Frame from view.frame.Frame import Frame
from model.ShellModel import ShellModel
from hardwaremanager import HardwareManager from hardwaremanager import HardwareManager
from _sugar import KeyGrabber from _sugar import KeyGrabber
from _sugar import AudioManager from _sugar import AudioManager
from sugar import env
import sugar import sugar
class Shell(gobject.GObject): class Shell(gobject.GObject):
@ -107,6 +109,7 @@ class Shell(gobject.GObject):
# For non-OLPC machines # For non-OLPC machines
self._key_grabber.grab('<alt>f') self._key_grabber.grab('<alt>f')
self._key_grabber.grab('<alt>o') self._key_grabber.grab('<alt>o')
self._key_grabber.grab('<alt><shift>s')
def _key_pressed_cb(self, grabber, key): def _key_pressed_cb(self, grabber, key):
if key == 'F1': if key == 'F1':
@ -149,7 +152,7 @@ class Shell(gobject.GObject):
self.toggle_chat_visibility() self.toggle_chat_visibility()
elif key == '0x93': # Frame key elif key == '0x93': # Frame key
self._frame.notify_key_press() self._frame.notify_key_press()
elif key == '0x7C': # Power key elif key == '0x7C' or key == '<alt><shift>s': # Power key
self._shutdown() self._shutdown()
elif key == '0xEC': # Keyboard brightness elif key == '0xEC': # Keyboard brightness
self._hw_manager.toggle_keyboard_brightness() self._hw_manager.toggle_keyboard_brightness()
@ -166,6 +169,11 @@ class Shell(gobject.GObject):
console.toggle_visibility() console.toggle_visibility()
def _shutdown(self): 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() bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.Hal', proxy = bus.get_object('org.freedesktop.Hal',
'/org/freedesktop/Hal/devices/computer') '/org/freedesktop/Hal/devices/computer')

View File

@ -18,8 +18,10 @@ import hippo
from view.home.activitiesdonut import ActivitiesDonut from view.home.activitiesdonut import ActivitiesDonut
from view.home.MyIcon import MyIcon from view.home.MyIcon import MyIcon
from model.ShellModel import ShellModel
from sugar.graphics.grid import Grid from sugar.graphics.grid import Grid
from sugar.graphics import style from sugar.graphics import style
from sugar.graphics.iconcolor import IconColor
class HomeBox(hippo.CanvasBox, hippo.CanvasItem): class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'SugarHomeBox' __gtype_name__ = 'SugarHomeBox'
@ -36,6 +38,17 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
style.apply_stylesheet(self._my_icon, 'home.MyIcon') style.apply_stylesheet(self._my_icon, 'home.MyIcon')
self.append(self._my_icon, hippo.PACK_FIXED) 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): def do_allocate(self, width, height):
hippo.CanvasBox.do_allocate(self, width, height) hippo.CanvasBox.do_allocate(self, width, height)

View File

@ -19,6 +19,8 @@
import os import os
import sys import sys
os.environ['SUGAR_EMULATOR'] = 'yes'
sourcedir = os.path.abspath(os.path.dirname(__file__)) sourcedir = os.path.abspath(os.path.dirname(__file__))
if os.path.isfile(os.path.join(sourcedir, 'sugar/__uninstalled__.py')): if os.path.isfile(os.path.join(sourcedir, 'sugar/__uninstalled__.py')):
print 'Running sugar from ' + sourcedir + ' ...' print 'Running sugar from ' + sourcedir + ' ...'

View File

@ -30,6 +30,12 @@ def get_bundle_path():
else: else:
return None return None
def is_emulator():
if os.environ.has_key('SUGAR_EMULATOR'):
if os.environ['SUGAR_EMULATOR'] == 'yes':
return True
return False
def get_bundle_service_name(): def get_bundle_service_name():
if os.environ.has_key('SUGAR_BUNDLE_SERVICE_NAME'): if os.environ.has_key('SUGAR_BUNDLE_SERVICE_NAME'):
return os.environ['SUGAR_BUNDLE_SERVICE_NAME'] return os.environ['SUGAR_BUNDLE_SERVICE_NAME']

View File

@ -22,6 +22,8 @@ from sugar.graphics.colors import colors
def _parse_string(color_string): def _parse_string(color_string):
if color_string == 'white': if color_string == 'white':
return ['#ffffff', '#414141'] return ['#ffffff', '#414141']
elif color_string == 'insensitive':
return ['#ffffff', '#e2e2e2']
splitted = color_string.split(',') splitted = color_string.split(',')
if len(splitted) == 2: if len(splitted) == 2:

View File

@ -1,6 +1,6 @@
VERSION=0.63 VERSION=0.63
DATE=`date +%Y%m%d` DATE=`date +%Y%m%d`
RELEASE=2.7 RELEASE=2.8
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