diff --git a/README b/README index df40e46e..6b4c2b17 100644 --- a/README +++ b/README @@ -24,5 +24,10 @@ F3 Friends zoom level F4 Mesh zoom level F5 Show the frame F6 Open a terminal activity +F7 Toggle chat visibility +F8 Color mode (DCON) +F9 Black and white mode (DCON) +F10 Decrease brightness (DCON) +F11 Increase brightness (DCON) F12 Open the log viewer Ctrl+S Activate sketch mode in chat diff --git a/shell/view/Shell.py b/shell/view/Shell.py index 401c935d..7daade72 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -26,6 +26,7 @@ from view.ActivityHost import ActivityHost from sugar.activity import ActivityFactory from sugar.activity import Activity from view.frame.Frame import Frame +from view.dconmanager import DCONManager from _sugar import KeyGrabber import sugar @@ -49,6 +50,8 @@ class Shell(gobject.GObject): style.load_stylesheet(view.stylesheet) + self._dcon_manager = DCONManager() + self._key_grabber = KeyGrabber() self._key_grabber.connect('key-pressed', self.__global_key_pressed_cb) @@ -60,7 +63,11 @@ class Shell(gobject.GObject): self._key_grabber.grab('F4') self._key_grabber.grab('F5') self._key_grabber.grab('F6') + self._key_grabber.grab('F7') + self._key_grabber.grab('F8') self._key_grabber.grab('F9') + self._key_grabber.grab('F10') + self._key_grabber.grab('F11') self._home_window = HomeWindow(self) self._home_window.show() @@ -87,8 +94,16 @@ class Shell(gobject.GObject): self._frame.notify_key_press() elif key == 'F6': self.start_activity('org.sugar.Terminal') - elif key == 'F9': + elif key == 'F7': self.toggle_chat_visibility() + elif key == 'F8': + self._dcon_manager.set_mode(DCONManager.COLOR_MODE) + elif key == 'F9': + self._dcon_manager.set_mode(DCONManager.BLACK_AND_WHITE_MODE) + elif key == 'F10': + self._dcon_manager.decrease_brightness() + elif key == 'F11': + self._dcon_manager.increase_brightness() def __global_key_released_cb(self, grabber, key): if key == 'F5': diff --git a/shell/view/dconmanager.py b/shell/view/dconmanager.py new file mode 100644 index 00000000..2cf40b51 --- /dev/null +++ b/shell/view/dconmanager.py @@ -0,0 +1,43 @@ +# 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 dbus + +DCON_MANAGER_INTERFACE = 'org.laptop.DCONManager' +DCON_MANAGER_SERVICE = 'org.laptop.DCONManager' +DCON_MANAGER_OBJECT_PATH = '/org/laptop/DCONManager' + +class DCONManager(object): + COLOR_MODE = 0 + BLACK_AND_WHITE_MODE = 1 + + def __init__(self): + bus = dbus.SystemBus() + proxy = bus.get_object(DCON_MANAGER_SERVICE, DCON_MANAGER_OBJECT_PATH) + self._service = dbus.Interface(proxy, DCON_MANAGER_INTERFACE) + + def set_mode(self, mode): + self._service.set_mode(mode) + + def increase_brightness(self): + level = self._service.get_backlight_level() + if level >= 0: + self._service.set_backlight_level(level + 1) + + def decrease_brightness(self): + level = self._service.get_backlight_level() + if level >= 0: + self._service.set_backlight_level(level - 1)