From 5f861037bbb5ec4d4b71d54b20fa3613d9c30eb3 Mon Sep 17 00:00:00 2001 From: Ben Konrath Date: Tue, 1 Dec 2009 12:30:44 -0500 Subject: add configuration button with empty configuration window --- README | 7 +- src/caribou.py | 2 +- src/config.svg | 1080 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/keyboard.py | 61 +++- src/keysyms.py | 2 +- src/qwerty.py | 22 +- 6 files changed, 1150 insertions(+), 24 deletions(-) create mode 100644 src/config.svg diff --git a/README b/README index f47b682..f87336b 100644 --- a/README +++ b/README @@ -1,11 +1,8 @@ Running Caribou =============== -python src/caribou.py - -or - -python src/caribou.py --debug +cd src +python ./caribou.py --debug When an editable text widget has focus, a keyboard should pop up. There are still some problems with the text focus detection and keyboard placement. diff --git a/src/caribou.py b/src/caribou.py index 4bf3112..615f613 100644 --- a/src/caribou.py +++ b/src/caribou.py @@ -1,5 +1,5 @@ # -# Carbou - Text entry and UI navigation application +# Carbou - text entry and UI navigation application # # Copyright (C) 2009 Adaptive Technology Resource Centre # diff --git a/src/config.svg b/src/config.svg new file mode 100644 index 0000000..1df3bf3 --- /dev/null +++ b/src/config.svg @@ -0,0 +1,1080 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Lapo Calamandrei + + + + + + keyboard + settings + properties + set + + + + + Jakub Steiner + + + 2006-10-06 + www.gnome.org + + + + + + + + + + + + + + + + + + + diff --git a/src/keyboard.py b/src/keyboard.py index 140d77a..affc963 100644 --- a/src/keyboard.py +++ b/src/keyboard.py @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- # -# Carbou - Text entry and UI navigation application +# Carbou - text entry and UI navigation application # # Copyright (C) 2009 Adaptive Technology Resource Centre # @@ -24,6 +24,8 @@ import gtk.gdk as gdk import pango import virtkey import qwerty +import rsvg +import cairo class CaribouPredicitionArea(gtk.HBox): pass @@ -49,9 +51,38 @@ class CaribouKeyboard(gtk.Frame): for key in row: # check if the key is a simple str or a key defined by a tuple if isinstance(key, str): - button = gtk.Button(key) - char = ord(key.decode('utf-8')) - button.connect("clicked", self.__send_unicode, char) + if key == "cf": + # configuration key + # FIXME scale based on size of other buttons + scaleFactor = 0.5 + # FIXME catch "RuntimeError: unknown librsvg error" for file not found + # FIXME use broken image when file not found + svg = rsvg.Handle("config.svg") + surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, + int(round(svg.props.width * scaleFactor)), + int(round(svg.props.height * scaleFactor))) + cr = cairo.Context(surface) + cr.scale(scaleFactor, scaleFactor) + svg.render_cairo(cr) + cfg = gtk.Image() + data = surface.get_data() + pixbuf = gtk.gdk.pixbuf_new_from_data(data, + gtk.gdk.COLORSPACE_RGB, + True, + 8, + int(round(svg.props.width * scaleFactor)), + int(round(svg.props.height * scaleFactor)), + int(round(svg.props.width * scaleFactor * 4))) + cfg.set_from_pixbuf(pixbuf) + button = gtk.Button() + button.set_image(cfg) + button.set_name("configuration") + switch_buttons.append(button) + else: + # single utf-8 character key + button = gtk.Button(key) + char = ord(key.decode('utf-8')) + button.connect("clicked", self.__send_unicode, char) elif isinstance(key, tuple): button = gtk.Button(key[0]) # check if this key is a layout switch key or not @@ -68,10 +99,24 @@ class CaribouKeyboard(gtk.Frame): rowhbox.pack_start(button, expand=False, fill=True) - layoutvbox.pack_start(rowhbox, expand=False, fill=False) + layoutvbox.pack_start(rowhbox, expand=False, fill=True) self._layouts.append(layoutvbox) - + + # add configuration window to layouts + # TODO use gtkBuilder + confhbox = gtk.HBox(homogeneous=True) + # return to first keyboard layout from configuration window + button = gtk.Button("abc") # FIXME use keyboard image + button.set_name(self._layouts[0].get_name()) + switch_buttons.append(button) + confhbox.pack_start(button) + + confhbox.pack_start(gtk.Label("configuration coming soon")) + confhbox.set_name("configuration") + self._layouts.append(confhbox) + + # connect the change layout buttons for button in switch_buttons: for layout in self._layouts: if button.get_name() == layout.get_name(): @@ -80,8 +125,8 @@ class CaribouKeyboard(gtk.Frame): break else: print "ERROR" # TODO throw exception - - # add the first layer and make it visible + + # add the first layout and make it visible self.add(self._layouts[0]) self.show_all() diff --git a/src/keysyms.py b/src/keysyms.py index 2c21084..770a7ee 100644 --- a/src/keysyms.py +++ b/src/keysyms.py @@ -1,5 +1,5 @@ # -# Carbou - Text entry and UI navigation application +# Carbou - text entry and UI navigation application # # Copyright (C) 2009 Adaptive Technology Resource Centre # diff --git a/src/qwerty.py b/src/qwerty.py index dd1b2ef..83cb534 100644 --- a/src/qwerty.py +++ b/src/qwerty.py @@ -1,6 +1,6 @@ # -*- coding: UTF-8 -*- # -# Carbou - Text entry and UI navigation application +# Carbou - text entry and UI navigation application # # Copyright (C) 2009 Adaptive Technology Resource Centre # @@ -63,19 +63,23 @@ np = (".?12", "num_punct") lt = ("abc", "lowercase") ############################################################################### -# keyboard layouts - put a single utf-8 character or a tuple defined above +# keyboard layouts +# rules: +# * key can be a single utf-8 character or a tuple defined above +# * at least one layout must contain the reserved label "cf" for configuration +# * layouts must be the same dimensions ############################################################################### -lowercase = ( ("?", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p"), - ( np, "a", "s", "d", "f", "g", "h", "j", "k", "l", bs), - ( su, "z", "x", "c", "v", "b", "n", "m", sp, ".", en) ) +lowercase = ( ("cf", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p"), + ( np, "a", "s", "d", "f", "g", "h", "j", "k", "l", bs), + ( su, "z", "x", "c", "v", "b", "n", "m", sp, ".", en) ) -uppercase = ( ("?", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"), - ( np, "A", "S", "D", "F", "G", "H", "J", "K", "L", bs), - ( sd, "Z", "X", "C", "V", "B", "N", "M", sp, ".", en) ) +uppercase = ( ("cf", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"), + ( np, "A", "S", "D", "F", "G", "H", "J", "K", "L", bs), + ( sd, "Z", "X", "C", "V", "B", "N", "M", sp, ".", en) ) num_punct = ( ("!", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"), - ( lt, "@", "$", "/", "+", "-", up, "\"", ",", "#", bs), + ( lt, "@", "$", "/", "+", "-", up, "\"", ",", "?", bs), ("'", "(", ")", ";", ":", le, dn, ri, sp, ".", en) ) ############################################################################### -- cgit v1.2.1