Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2012-08-13 13:53:09 (GMT)
committer Simon Schampijer <simon@laptop.org>2012-10-04 23:06:56 (GMT)
commitb7997ef33011283690c9a3d24d54fb7050316e5c (patch)
tree0605b42a468735bb5d38a3b90737e0aa9b4a6074 /extensions
parentd6e3fe411ee22dc4308cd06f54e2b5e0bd1d27ab (diff)
Frame: add a device icon to reveal the OSK manually, SL #3982
This adds a device icon to reveal the OSK manually. We add a soft dependency on Maliit, if it is not available the icon is not added to the Frame. When the OSK is revealed using the button the Frame hides. Signed-off-by: Simon Schampijer <simon@laptop.org> Acked-by: Manuel QuiƱones <manuq@laptop.org>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/deviceicon/Makefile.am1
-rw-r--r--extensions/deviceicon/frame.py69
2 files changed, 70 insertions, 0 deletions
diff --git a/extensions/deviceicon/Makefile.am b/extensions/deviceicon/Makefile.am
index 7ed1f77..96a1753 100644
--- a/extensions/deviceicon/Makefile.am
+++ b/extensions/deviceicon/Makefile.am
@@ -3,6 +3,7 @@ sugardir = $(pkgdatadir)/extensions/deviceicon
sugar_PYTHON = \
__init__.py \
battery.py \
+ frame.py \
network.py \
speaker.py \
speech.py \
diff --git a/extensions/deviceicon/frame.py b/extensions/deviceicon/frame.py
new file mode 100644
index 0000000..b4e76f5
--- /dev/null
+++ b/extensions/deviceicon/frame.py
@@ -0,0 +1,69 @@
+# Copyright (C) 2012, OLPC
+#
+# 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 logging
+from gettext import gettext as _
+
+from gi.repository import GConf
+
+from sugar3.graphics.tray import TrayIcon
+from sugar3.graphics.toolbutton import ToolButton
+from sugar3.graphics.palette import Palette
+from sugar3.graphics.xocolor import XoColor
+
+from jarabe.frame.frameinvoker import FrameWidgetInvoker
+import jarabe.frame
+
+_ICON_NAME = 'module-keyboard'
+_HAS_MALIIT = False
+
+try:
+ from gi.repository import Maliit
+except ImportError:
+ logging.debug('Frame: can not create OSK icon: Maliit is not installed.')
+ _HAS_MALIIT = False
+else:
+ _HAS_MALIIT = True
+
+
+class DeviceView(TrayIcon):
+
+ FRAME_POSITION_RELATIVE = 103
+
+ def __init__(self):
+ client = GConf.Client.get_default()
+ self._color = XoColor(client.get_string('/desktop/sugar/user/color'))
+
+ TrayIcon.__init__(self, icon_name=_ICON_NAME, xo_color=self._color)
+
+ self._input_method = Maliit.InputMethod()
+ self.connect('button-release-event', self.__button_release_event_cb)
+ self.set_palette_invoker(FrameWidgetInvoker(self))
+
+ def create_palette(self):
+ palette = Palette(_('Show my keyboard'))
+ palette.set_group_id('frame')
+ return palette
+
+ def __button_release_event_cb(self, widget, event):
+ self._input_method.show()
+ frame = jarabe.frame.get_view()
+ frame.hide()
+
+
+def setup(tray):
+ if _HAS_MALIIT:
+ tray.add_device(DeviceView())