Bind keys to dcon manager actions, see README

This commit is contained in:
Marco Pesenti Gritti 2006-11-08 16:42:50 +01:00
parent 62ad1539c2
commit d1a9762cb8
3 changed files with 64 additions and 1 deletions

5
README
View File

@ -24,5 +24,10 @@ F3 Friends zoom level
F4 Mesh zoom level F4 Mesh zoom level
F5 Show the frame F5 Show the frame
F6 Open a terminal activity 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 F12 Open the log viewer
Ctrl+S Activate sketch mode in chat Ctrl+S Activate sketch mode in chat

View File

@ -26,6 +26,7 @@ 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 view.dconmanager import DCONManager
from _sugar import KeyGrabber from _sugar import KeyGrabber
import sugar import sugar
@ -49,6 +50,8 @@ class Shell(gobject.GObject):
style.load_stylesheet(view.stylesheet) style.load_stylesheet(view.stylesheet)
self._dcon_manager = DCONManager()
self._key_grabber = KeyGrabber() self._key_grabber = KeyGrabber()
self._key_grabber.connect('key-pressed', self._key_grabber.connect('key-pressed',
self.__global_key_pressed_cb) self.__global_key_pressed_cb)
@ -60,7 +63,11 @@ class Shell(gobject.GObject):
self._key_grabber.grab('F4') self._key_grabber.grab('F4')
self._key_grabber.grab('F5') self._key_grabber.grab('F5')
self._key_grabber.grab('F6') self._key_grabber.grab('F6')
self._key_grabber.grab('F7')
self._key_grabber.grab('F8')
self._key_grabber.grab('F9') self._key_grabber.grab('F9')
self._key_grabber.grab('F10')
self._key_grabber.grab('F11')
self._home_window = HomeWindow(self) self._home_window = HomeWindow(self)
self._home_window.show() self._home_window.show()
@ -87,8 +94,16 @@ class Shell(gobject.GObject):
self._frame.notify_key_press() self._frame.notify_key_press()
elif key == 'F6': elif key == 'F6':
self.start_activity('org.sugar.Terminal') self.start_activity('org.sugar.Terminal')
elif key == 'F9': elif key == 'F7':
self.toggle_chat_visibility() 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): def __global_key_released_cb(self, grabber, key):
if key == 'F5': if key == 'F5':

43
shell/view/dconmanager.py Normal file
View File

@ -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)