diff options
author | Bernie Innocenti <bernie@codewiz.org> | 2010-07-30 00:02:56 (GMT) |
---|---|---|
committer | Bernie Innocenti <bernie@codewiz.org> | 2010-07-30 00:02:56 (GMT) |
commit | 700117bc29c59bd7ef3820029df81ecf6c4a504c (patch) | |
tree | e72beb0718949215076b301f14d8790a16fb96dd /rpms | |
parent | a4a89c08fc9b83e84c23afdc384cd0af98dcbbaa (diff) |
sugar: add touchpad device icon in the frame
Diffstat (limited to 'rpms')
-rw-r--r-- | rpms/sugar/cpu-and-memory-resource-indicator.patch | 2 | ||||
-rw-r--r-- | rpms/sugar/sl2006-touchpad-device-on-frame.patch | 159 | ||||
-rw-r--r-- | rpms/sugar/sugar.spec | 4 |
3 files changed, 163 insertions, 2 deletions
diff --git a/rpms/sugar/cpu-and-memory-resource-indicator.patch b/rpms/sugar/cpu-and-memory-resource-indicator.patch index e66d7de..fd5c477 100644 --- a/rpms/sugar/cpu-and-memory-resource-indicator.patch +++ b/rpms/sugar/cpu-and-memory-resource-indicator.patch @@ -25,9 +25,9 @@ index 8a2e765..038c059 100644 --- a/extensions/deviceicon/Makefile.am +++ b/extensions/deviceicon/Makefile.am @@ -5,4 +5,5 @@ sugar_PYTHON = \ - battery.py \ network.py \ speaker.py \ + touchpad.py \ - volume.py + volume.py \ + resources.py diff --git a/rpms/sugar/sl2006-touchpad-device-on-frame.patch b/rpms/sugar/sl2006-touchpad-device-on-frame.patch new file mode 100644 index 0000000..fba088d --- /dev/null +++ b/rpms/sugar/sl2006-touchpad-device-on-frame.patch @@ -0,0 +1,159 @@ +From 47221ac4277a649c4808231f5616d75d73ab48e0 Mon Sep 17 00:00:00 2001 +From: Walter Bender <walter@sugarlabs.org> +Date: Tue, 20 Jul 2010 14:11:28 -0400 +Subject: [PATCH] touchpad device on frame + +--- + extensions/deviceicon/Makefile.am | 1 + + extensions/deviceicon/touchpad.py | 129 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 130 insertions(+), 0 deletions(-) + create mode 100644 extensions/deviceicon/touchpad.py + +diff --git a/extensions/deviceicon/Makefile.am b/extensions/deviceicon/Makefile.am +index 8a2e765..7f82a3f 100644 +--- a/extensions/deviceicon/Makefile.am ++++ b/extensions/deviceicon/Makefile.am +@@ -5,4 +5,5 @@ sugar_PYTHON = \ + battery.py \ + network.py \ + speaker.py \ ++ touchpad.py \ + volume.py +diff --git a/extensions/deviceicon/touchpad.py b/extensions/deviceicon/touchpad.py +new file mode 100644 +index 0000000..7f3ecb5 +--- /dev/null ++++ b/extensions/deviceicon/touchpad.py +@@ -0,0 +1,129 @@ ++# Copyright (C) 2010, Walter Bender, Sugar Labs ++# ++# 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 ++ ++ ++from gettext import gettext as _ ++import os ++ ++import gtk ++import gconf ++ ++from sugar.graphics.tray import TrayIcon ++from sugar.graphics.xocolor import XoColor ++from sugar.graphics.palette import Palette ++from sugar.graphics import style ++ ++from jarabe.frame.frameinvoker import FrameWidgetInvoker ++ ++TOUCHPAD_MODES = ['capacitive', 'resistive'] ++STATUS_TEXT = {TOUCHPAD_MODES[0]: _('finger'), TOUCHPAD_MODES[1]: _('stylus')} ++STATUS_ICON = {TOUCHPAD_MODES[0]: 'touchpad-' + TOUCHPAD_MODES[0], ++ TOUCHPAD_MODES[1]: 'touchpad-' + TOUCHPAD_MODES[1]} ++# FLAG_PATH is used to preserve status between boots. ++FLAG_PATH = '/home/olpc/.olpc-pentablet-mode' ++# NODE_PATH is used to communicate with the touchpad device. ++NODE_PATH = '/sys/devices/platform/i8042/serio1/ptmode' ++ ++class DeviceView(TrayIcon): ++ """ Manage the touchpad mode from the device palette on the Frame. """ ++ ++ FRAME_POSITION_RELATIVE = 500 ++ ++ def __init__(self): ++ """ Create the touchpad palette and display it on Frame. """ ++ icon_name = STATUS_ICON[read_touchpad_mode()] ++ ++ client = gconf.client_get_default() ++ color = XoColor(client.get_string('/desktop/sugar/user/color')) ++ TrayIcon.__init__(self, icon_name=icon_name, xo_color=color) ++ ++ self.set_palette_invoker(FrameWidgetInvoker(self)) ++ self.connect('button-release-event', self.__button_release_event_cb) ++ ++ def create_palette(self): ++ """ On create, set the current mode. """ ++ self.palette = ResourcePalette(_('My touchpad'), self.icon) ++ self.palette.set_group_id('frame') ++ return self.palette ++ ++ def __button_release_event_cb(self, widget, event): ++ """ On button release, switch modes. """ ++ self.palette.toggle_mode() ++ return True ++ ++ ++class ResourcePalette(Palette): ++ """ Query the current state of the touchpad and update the display. """ ++ ++ def __init__(self, primary_text, icon): ++ """ Create the palette and initilize with current touchpad status. """ ++ Palette.__init__(self, label=primary_text) ++ ++ self._icon = icon ++ ++ vbox = gtk.VBox() ++ self.set_content(vbox) ++ ++ self._status_text = gtk.Label() ++ vbox.pack_start(self._status_text, padding=style.DEFAULT_PADDING) ++ self._status_text.show() ++ ++ vbox.show() ++ ++ self._mode = read_touchpad_mode() ++ self._update() ++ ++ def _update(self): ++ """ Update the label and icon based on the current mode. """ ++ self._status_text.set_label(STATUS_TEXT[self._mode]) ++ self._icon.props.icon_name = STATUS_ICON[self._mode] ++ ++ def toggle_mode(self): ++ """ On mouse click, toggle the mode. """ ++ self._mode = TOUCHPAD_MODES[1 - TOUCHPAD_MODES.index(self._mode)] ++ write_touchpad_mode(self._mode) ++ self._update() ++ ++ ++def setup(tray): ++ """ Touchpad palette only appears when the device exisits. """ ++ if os.path.exists(NODE_PATH): ++ tray.add_device(DeviceView()) ++ ++ ++def read_touchpad_mode(): ++ """ Read the touchpad mode from the node path. """ ++ node_file_handle = open(NODE_PATH, 'r') ++ text = node_file_handle.read() ++ node_file_handle.close() ++ ++ return TOUCHPAD_MODES[int(text[0])] ++ ++ ++def write_touchpad_mode(touchpad): ++ """ Write the touchpad mode to the node path and set/unset the flag. """ ++ touchpad_mode_index = TOUCHPAD_MODES.index(touchpad) ++ ++ node_file_handle = open(NODE_PATH, 'w') ++ node_file_handle.write(str(touchpad_mode_index)) ++ node_file_handle.close() ++ ++ if touchpad_mode_index == 0: ++ if os.path.exists(FLAG_PATH): ++ os.remove(FLAG_PATH) ++ else: ++ flag_file_handle = open(FLAG_PATH, 'w') ++ flag_file_handle.close() +-- +1.7.0.4 + diff --git a/rpms/sugar/sugar.spec b/rpms/sugar/sugar.spec index 43edb32..0b234b1 100644 --- a/rpms/sugar/sugar.spec +++ b/rpms/sugar/sugar.spec @@ -3,7 +3,7 @@ Summary: Constructionist learning platform Name: sugar Version: 0.88.1 -Release: 5.22dxr%{?dist} +Release: 5.23dxr%{?dist} URL: http://sugarlabs.org/ Source0: http://download.sugarlabs.org/sources/sucrose/glucose/%{name}/%{name}-%{version}.tar.bz2 @@ -51,6 +51,7 @@ Patch202: backup-0002-Journal-XS-backup-and-restore.patch Patch205: backup-0005-save-lease.patch # experimental patches +Patch500: sl2006-touchpad-device-on-frame.patch Patch501: sl2006-touchpad-section-for-control-panel.patch Patch502: sl2006-file-exists-check.patch Patch503: cpu-and-memory-resource-indicator.patch @@ -162,6 +163,7 @@ multiple instances of sugar. #%patch204 -p1 %patch205 -p1 +%patch500 -p1 %patch501 -p1 %patch502 -p1 %patch503 -p1 |