Ticket #3982: 0001-Add-a-toolbutton-in-the-device-section-to-reveal-the.patch

File 0001-Add-a-toolbutton-in-the-device-section-to-reveal-the.patch, 13.0 KB (added by erikos, 12 years ago)

Add a frame device icon to reveal the OSK, adds soft dependency on Maliit

  • data/icons/module-keyboard.svg

    From b9a2bc5cfbb2643a76edaae17438a4d80953776d Mon Sep 17 00:00:00 2001
    From: Simon Schampijer <simon@schampijer.de>
    Date: Mon, 13 Aug 2012 15:53:09 +0200
    Subject: [PATCH shell] Add a toolbutton in the device section to reveal the
     OSK, SL #3982
    
    ---
     data/icons/module-keyboard.svg    | 154 ++++++--------------------------------
     extensions/deviceicon/Makefile.am |   1 +
     extensions/deviceicon/frame.py    |  66 ++++++++++++++++
     3 files changed, 88 insertions(+), 133 deletions(-)
     create mode 100644 extensions/deviceicon/frame.py
    
    diff --git a/data/icons/module-keyboard.svg b/data/icons/module-keyboard.svg
    index 43bbc57..4b82236 100644
    a b  
    1 <?xml version="1.0" ?><!DOCTYPE svg  PUBLIC '-//W3C//DTD SVG 1.1//EN'  'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
    2         <!ENTITY stroke_color "#666666">
     1<?xml version="1.0" encoding="UTF-8"?>
     2<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
     3        <!ENTITY stroke_color "#010101">
    34        <!ENTITY fill_color "#ffffff">
    4 ]><svg enable-background="new 0 0 55 55" height="55px" id="Layer_1" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="module-keyboard">
    5         <rect display="inline" fill="&fill_color;" height="23.326" width="54" x="0.5" y="15.837"/>
    6         <g display="inline">
    7                 <path d="M52.61,28.081c0,0.55-0.45,1-1,1h-5.443c-0.55,0-1-0.45-1-1v-5.444c0-0.55,0.45-1,1-1h5.443c0.55,0,1,0.45,1,1V28.081z"/>
    8         </g>
    9         <g display="inline">
    10                 <path d="M52.61,19.941c0,0.55-0.45,1-1,1h-5.412c-0.55,0-1-0.45-1-1v-1.368c0-0.55,0.45-1,1-1h5.412c0.55,0,1,0.45,1,1V19.941z"/>
    11         </g>
    12         <g display="inline">
    13                 <path d="M52.61,32.267c0,0.55-0.45,1-1,1h-5.412c-0.55,0-1-0.45-1-1v-1.367c0-0.55,0.45-1,1-1h5.412c0.55,0,1,0.45,1,1V32.267z"/>
    14         </g>
    15         <g display="inline">
    16                 <path d="M39.11,36.403c0,0.55-0.45,1-1,1H13.176c-0.55,0-1-0.45-1-1v-1.366c0-0.55,0.45-1,1-1H38.11c0.55,0,1,0.45,1,1V36.403z"/>
    17         </g>
    18         <g display="inline">
    19                 <g>
    20                         <path d="M5.889,19.977c0,0.55-0.45,1-1,1H3.549c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.339c0.55,0,1,0.45,1,1V19.977z"/>
    21                 </g>
    22                 <g>
    23                         <path d="M10.65,19.977c0,0.55-0.45,1-1,1H8.311c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1H9.65c0.55,0,1,0.45,1,1V19.977z"/>
    24                 </g>
    25                 <g>
    26                         <path d="M15.411,19.977c0,0.55-0.45,1-1,1h-1.339c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.339c0.55,0,1,0.45,1,1V19.977z"/>
    27                 </g>
    28                 <g>
    29                         <path d="M20.173,19.978c0,0.55-0.45,1-1,1h-1.34c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1V19.978z"/>
    30                 </g>
    31                 <g>
    32                         <path d="M24.934,19.977c0,0.55-0.45,1-1,1h-1.34c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1V19.977z"/>
    33                 </g>
    34                 <g>
    35                         <path d="M29.695,19.978c0,0.55-0.45,1-1,1h-1.34c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1V19.978z"/>
    36                 </g>
    37                 <g>
    38                         <path d="M34.457,19.977c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V19.977z"/>
    39                 </g>
    40                 <g>
    41                         <path d="M39.218,19.977c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V19.977z"/>
    42                 </g>
    43                 <g>
    44                         <path d="M43.979,19.977c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V19.977z"/>
    45                 </g>
    46         </g>
    47         <g display="inline">
    48                 <g>
    49                         <path d="M5.889,24.038c0,0.55-0.45,1-1,1H3.549c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.339c0.55,0,1,0.45,1,1V24.038z"/>
    50                 </g>
    51                 <g>
    52                         <path d="M10.65,24.038c0,0.55-0.45,1-1,1H8.311c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1H9.65c0.55,0,1,0.45,1,1V24.038z"/>
    53                 </g>
    54                 <g>
    55                         <path d="M15.411,24.038c0,0.55-0.45,1-1,1h-1.339c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.339c0.55,0,1,0.45,1,1V24.038z"/>
    56                 </g>
    57                 <g>
    58                         <path d="M20.173,24.038c0,0.55-0.45,1-1,1h-1.34c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1V24.038z"/>
    59                 </g>
    60                 <g>
    61                         <path d="M24.934,24.038c0,0.55-0.45,1-1,1h-1.34c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1V24.038z"/>
    62                 </g>
    63                 <g>
    64                         <path d="M29.695,24.038c0,0.55-0.45,1-1,1h-1.34c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1V24.038z"/>
    65                 </g>
    66                 <g>
    67                         <path d="M34.457,24.038c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V24.038z"/>
    68                 </g>
    69                 <g>
    70                         <path d="M39.218,24.038c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V24.038z"/>
    71                 </g>
    72                 <g>
    73                         <path d="M43.979,24.038c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1v-1.339c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V24.038z"/>
    74                 </g>
    75         </g>
    76         <g display="inline">
    77                 <g>
    78                         <path d="M5.889,28.099c0,0.55-0.45,1-1,1.001H3.549c-0.55,0.001-1-0.449-1-0.999V26.76c0-0.55,0.45-1,1-1h1.339     c0.55,0,1,0.45,1,1V28.099z"/>
    79                 </g>
    80                 <g>
    81                         <path d="M10.65,28.099c0,0.55-0.45,1-1,1.001H8.311c-0.55,0.001-1-0.449-1-0.999V26.76c0-0.55,0.45-1,1-1H9.65c0.55,0,1,0.45,1,1     V28.099z"/>
    82                 </g>
    83                 <g>
    84                         <path d="M15.411,28.099c0,0.55-0.45,1-1,1L13.072,29.1c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.339c0.55,0,1,0.45,1,1     V28.099z"/>
    85                 </g>
    86                 <g>
    87                         <path d="M20.173,28.099c0,0.55-0.45,1-1,1l-1.34,0.001c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1     V28.099z"/>
    88                 </g>
    89                 <g>
    90                         <path d="M24.934,28.099c0,0.55-0.45,1-1,1l-1.34,0.001c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1     V28.099z"/>
    91                 </g>
    92                 <g>
    93                         <path d="M29.695,28.099c0,0.55-0.45,1-1,1l-1.34,0.001c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1     V28.099z"/>
    94                 </g>
    95                 <g>
    96                         <path d="M34.457,28.099c0,0.55-0.45,1-1,1L32.116,29.1c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1     V28.099z"/>
    97                 </g>
    98                 <g>
    99                         <path d="M39.218,28.099c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1V26.76c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V28.099z"/>
    100                 </g>
    101                 <g>
    102                         <path d="M43.979,28.099c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1V26.76c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V28.099z"/>
    103                 </g>
    104         </g>
    105         <g display="inline">
    106                 <g>
    107                         <path d="M5.889,32.161c0,0.55-0.45,1-1,1H3.549c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.339c0.55,0,1,0.45,1,1V32.161z"/>
    108                 </g>
    109                 <g>
    110                         <path d="M10.65,32.161c0,0.55-0.45,1-1,1H8.311c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1H9.65c0.55,0,1,0.45,1,1V32.161z"/>
    111                 </g>
    112                 <g>
    113                         <path d="M15.411,32.161c0,0.55-0.45,1-1,1h-1.339c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.339c0.55,0,1,0.45,1,1V32.161z"/>
    114                 </g>
    115                 <g>
    116                         <path d="M20.173,32.161c0,0.55-0.45,1-1,1h-1.34c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1V32.161z"/>
    117                 </g>
    118                 <g>
    119                         <path d="M24.934,32.161c0,0.55-0.45,1-1,1h-1.34c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1V32.161z"/>
    120                 </g>
    121                 <g>
    122                         <path d="M29.695,32.161c0,0.55-0.45,1-1,1h-1.34c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.34c0.55,0,1,0.45,1,1V32.161z"/>
    123                 </g>
    124                 <g>
    125                         <path d="M34.457,32.161c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V32.161z"/>
    126                 </g>
    127                 <g>
    128                         <path d="M39.218,32.161c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V32.161z"/>
    129                 </g>
    130                 <g>
    131                         <path d="M43.979,32.161c0,0.55-0.45,1-1,1h-1.341c-0.55,0-1-0.45-1-1v-1.34c0-0.55,0.45-1,1-1h1.341c0.55,0,1,0.45,1,1V32.161z"/>
    132                 </g>
    133         </g>
    134 </g></svg>
    135  No newline at end of file
     5]>
     6<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="55" height="55" viewBox="0, 0, 55, 55">
     7  <g id="module-keyboard">
     8    <g>
     9      <path d="M6.331,40.69 C5.872,40.69 5.5,40.171 5.5,39.53 L5.5,15.47 C5.5,14.829 5.872,14.31 6.331,14.31 L48.669,14.31 C49.128,14.31 49.5,14.829 49.5,15.47 L49.5,39.53 C49.5,40.171 49.128,40.69 48.669,40.69 z" fill="&stroke_color;"/>
     10      <path d="M6.331,40.69 C5.872,40.69 5.5,40.171 5.5,39.53 L5.5,15.47 C5.5,14.829 5.872,14.31 6.331,14.31 L48.669,14.31 C49.128,14.31 49.5,14.829 49.5,15.47 L49.5,39.53 C49.5,40.171 49.128,40.69 48.669,40.69 z" fill-opacity="0" stroke="&fill_color;" stroke-width="3.5"/>
     11    </g>
     12    <path d="M12.834,23.257 C12.281,23.257 11.834,22.81 11.834,22.257 L11.834,20.34 C11.834,19.788 12.281,19.34 12.834,19.34 L16.538,19.34 C17.09,19.34 17.538,19.788 17.538,20.34 L17.538,22.257 C17.538,22.81 17.09,23.257 16.538,23.257 z M12.834,23.257" fill="&fill_color;"/>
     13    <path d="M21.376,23.257 C20.824,23.257 20.376,22.81 20.376,22.257 L20.376,20.34 C20.376,19.788 20.824,19.34 21.376,19.34 L25.081,19.34 C25.633,19.34 26.081,19.788 26.081,20.34 L26.081,22.257 C26.081,22.81 25.633,23.257 25.081,23.257 z M21.376,23.257" fill="&fill_color;"/>
     14    <path d="M29.919,23.257 C29.367,23.257 28.919,22.81 28.919,22.257 L28.919,20.34 C28.919,19.788 29.367,19.34 29.919,19.34 L33.624,19.34 C34.176,19.34 34.624,19.788 34.624,20.34 L34.624,22.257 C34.624,22.81 34.176,23.257 33.624,23.257 z M29.919,23.257" fill="&fill_color;"/>
     15    <path d="M38.462,23.257 C37.91,23.257 37.462,22.81 37.462,22.257 L37.462,20.34 C37.462,19.788 37.91,19.34 38.462,19.34 L42.166,19.34 C42.719,19.34 43.166,19.788 43.166,20.34 L43.166,22.257 C43.166,22.81 42.719,23.257 42.166,23.257 z M38.462,23.257" fill="&fill_color;"/>
     16    <path d="M25.658,29.444 C25.105,29.444 24.658,28.996 24.658,28.444 L24.658,26.527 C24.658,25.975 25.105,25.527 25.658,25.527 L29.362,25.527 C29.915,25.527 30.362,25.975 30.362,26.527 L30.362,28.444 C30.362,28.996 29.915,29.444 29.362,29.444 z M25.658,29.444" fill="&fill_color;"/>
     17    <path d="M34.672,25.527 L42.165,25.527 C42.718,25.527 43.166,25.991 43.166,26.563 L43.166,28.408 C43.166,28.98 42.718,29.444 42.165,29.444 L34.672,29.444 C34.119,29.444 33.67,28.98 33.67,28.408 L33.67,26.563 C33.67,25.991 34.119,25.527 34.672,25.527 z" fill="&fill_color;"/>
     18    <path d="M18.252,31.714 L36.748,31.714 C37.578,31.714 38.251,32.155 38.251,32.699 L38.251,34.645 C38.251,35.189 37.578,35.631 36.748,35.631 L18.252,35.631 C17.422,35.631 16.749,35.189 16.749,34.645 L16.749,32.699 C16.749,32.155 17.422,31.714 18.252,31.714 z" fill="&fill_color;"/>
     19    <path d="M12.838,25.527 L20.346,25.527 C20.9,25.527 21.35,25.991 21.35,26.563 L21.35,28.408 C21.35,28.98 20.9,29.444 20.346,29.444 L12.838,29.444 C12.283,29.444 11.834,28.98 11.834,28.408 L11.834,26.563 C11.834,25.991 12.283,25.527 12.838,25.527 z" fill="&fill_color;"/>
     20  </g>
     21  <defs/>
     22</svg>
  • extensions/deviceicon/Makefile.am

    diff --git a/extensions/deviceicon/Makefile.am b/extensions/deviceicon/Makefile.am
    index 7ed1f77..96a1753 100644
    a b sugardir = $(pkgdatadir)/extensions/deviceicon 
    33sugar_PYTHON =          \
    44        __init__.py     \
    55        battery.py      \
     6        frame.py        \
    67        network.py      \
    78        speaker.py      \
    89        speech.py       \
  • new file extensions/deviceicon/frame.py

    diff --git a/extensions/deviceicon/frame.py b/extensions/deviceicon/frame.py
    new file mode 100644
    index 0000000..055669f
    - +  
     1# Copyright (C) 2012, OLPC
     2#
     3# This program is free software; you can redistribute it and/or modify
     4# it under the terms of the GNU General Public License as published by
     5# the Free Software Foundation; either version 2 of the License, or
     6# (at your option) any later version.
     7#
     8# This program is distributed in the hope that it will be useful,
     9# but WITHOUT ANY WARRANTY; without even the implied warranty of
     10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11# GNU General Public License for more details.
     12#
     13# You should have received a copy of the GNU General Public License
     14# along with this program; if not, write to the Free Software
     15# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     16
     17import logging
     18from gettext import gettext as _
     19
     20from gi.repository import GConf
     21
     22from sugar3.graphics.tray import TrayIcon
     23from sugar3.graphics.toolbutton import ToolButton
     24from sugar3.graphics.palette import Palette
     25from sugar3.graphics.xocolor import XoColor
     26
     27from jarabe.frame.frameinvoker import FrameWidgetInvoker
     28
     29_ICON_NAME = 'module-keyboard'
     30_HAS_MALIIT = False
     31
     32try:
     33    from gi.repository import Maliit
     34except ImportError:
     35    logging.debug('Frame: can not create OSK icon: Maliit is not installed.')
     36    _HAS_MALIIT = False
     37else:
     38    _HAS_MALIIT = True
     39
     40
     41class DeviceView(TrayIcon):
     42
     43    FRAME_POSITION_RELATIVE = 103
     44
     45    def __init__(self):
     46        client = GConf.Client.get_default()
     47        self._color = XoColor(client.get_string('/desktop/sugar/user/color'))
     48
     49        TrayIcon.__init__(self, icon_name=_ICON_NAME, xo_color=self._color)
     50
     51        self._input_method = Maliit.InputMethod()
     52        self.connect('button-release-event', self.__button_release_event_cb)
     53        self.set_palette_invoker(FrameWidgetInvoker(self))
     54
     55    def create_palette(self):
     56        palette = Palette(_('Show my keyboard'))
     57        palette.set_group_id('frame')
     58        return palette
     59
     60    def __button_release_event_cb(self, widget, event):
     61        self._input_method.show()
     62
     63
     64def setup(tray):
     65    if _HAS_MALIIT:
     66        tray.add_device(DeviceView())