Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/model/ShellModel.py25
-rw-r--r--shell/view/Shell.py10
-rw-r--r--shell/view/home/HomeBox.py13
3 files changed, 46 insertions, 2 deletions
diff --git a/shell/model/ShellModel.py b/shell/model/ShellModel.py
index de6020b..b1c21bc 100644
--- a/shell/model/ShellModel.py
+++ b/shell/model/ShellModel.py
@@ -16,6 +16,8 @@
import os
+import gobject
+
from sugar.presence import PresenceService
from sugar.activity.bundleregistry import BundleRegistry
from model.Friends import Friends
@@ -24,9 +26,22 @@ from model.homemodel import HomeModel
from model.Owner import ShellOwner
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):
+ gobject.GObject.__init__(self)
+
self._current_activity = None
+ self._state = self.STATE_RUNNING
self._bundle_registry = BundleRegistry()
@@ -47,6 +62,14 @@ class ShellModel:
bundles_path = os.path.join(path, 'activities')
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):
return self._bundle_registry
diff --git a/shell/view/Shell.py b/shell/view/Shell.py
index f687a2b..0fbcfe4 100644
--- a/shell/view/Shell.py
+++ b/shell/view/Shell.py
@@ -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')
diff --git a/shell/view/home/HomeBox.py b/shell/view/home/HomeBox.py
index 48069ea..daef97d 100644
--- a/shell/view/home/HomeBox.py
+++ b/shell/view/home/HomeBox.py
@@ -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)