Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed copyright : Sun -> Oracle

Added virtual keyboard functionality (with ibus patch)
  • Loading branch information...
commit b0d2a698874223786950ca78d189bddf160abe0e 1 parent 0c332a0
Naoyuki Ishimura authored
Showing with 2,672 additions and 117 deletions.
  1. +1 −1  COPYING
  2. +2 −1  Makefile.am
  3. 0  autogen.sh
  4. +3 −1 configure.ac
  5. +10 −10 engine/Makefile.am
  6. +1 −1  engine/compose_tbl.py
  7. +2 −2 engine/engine.py
  8. +1 −1  engine/factory.py
  9. +2 −3 engine/ibus-engine-xkbc.in
  10. +1 −1  engine/main.py
  11. +3 −3 engine/xkbc.xml.in.in
  12. +3 −3 help/C/ibus-xkbc-C.omf
  13. +2 −2 help/C/ibus-xkbc.xml
  14. +13 −5 ibus-xkbc.spec.in
  15. +2 −2 icons/Makefile.am
  16. +108 −0 patches/ibus-1.3.3-on-nv-ss12.patch
  17. +2 −2 setup/Makefile.am
  18. +1 −1  setup/hotkey.py
  19. +2 −3 setup/ibus-setup-xkbc.in
  20. +1 −1  setup/keyeventutil.py
  21. +1 −1  setup/layout.py
  22. +12 −7 setup/main.py
  23. +14 −10 setup/prefs.py
  24. +2 −1  setup/vars.py
  25. +1 −2  setup/xkbc/Makefile.am
  26. +1 −1  setup/xkbc/__init__.py
  27. +52 −1 setup/xkbc/constants.py
  28. +5 −3 setup/xkbc/parser.py
  29. +0 −28 setup/xkbc/props.py
  30. +46 −3 setup/xkbc/unicodeutil.py
  31. +1 −1  setup/xkbc/xkb_component.py
  32. +51 −8 setup/xkbc/xkb_config.py
  33. +525 −4 setup/xkbc/xkb_geometry.py
  34. +1 −1  setup/xkbc/xkb_keycodes.py
  35. +1 −1  setup/xkbc/xkb_keymap.py
  36. +1 −1  setup/xkbc/xkb_rules.py
  37. +1 −1  setup/xkbc/xkb_symbols.py
  38. BIN  setup/xkbc/xkbc.dat
  39. +49 −0 vkb/Makefile.am
  40. +69 −0 vkb/geometry/vkb
  41. +26 −0 vkb/ibus-kbd-xkbc.in
  42. +92 −0 vkb/vkb.py
  43. +504 −0 vkb/vkb_canvas.py
  44. +47 −0 vkb/vkb_color.py
  45. +184 −0 vkb/vkb_config.py
  46. +58 −0 vkb/vkb_constants.py
  47. +304 −0 vkb/vkb_key.py
  48. +314 −0 vkb/vkb_keymodel.py
  49. +78 −0 vkb/vkb_signal.py
  50. +72 −0 vkb/vkb_window.py
View
2  COPYING
@@ -8,7 +8,7 @@ is applied is otherwise unspecified.
--------------------------------------------------------------------
-Copyright (C) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+Copyright (C) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify
View
3  Makefile.am
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The XKeyboard Config based engine for IBus
#
-# Copyright (c) 2009 Naoyuki Ishimura <naoyuki.ishimura@sun.com>
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -22,6 +22,7 @@ SUBDIRS = \
engine \
setup \
setup/xkbc \
+ vkb \
icons \
m4 \
po \
View
0  autogen.sh 100644 → 100755
File mode changed
View
4 configure.ac
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus XKBC project
#
-# Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -78,6 +78,8 @@ engine/xkbc.engine
setup/Makefile
setup/ibus-setup-xkbc
setup/xkbc/Makefile
+vkb/Makefile
+vkb/ibus-kbd-xkbc
icons/Makefile
m4/Makefile
help/Makefile
View
20 engine/Makefile.am
@@ -1,8 +1,8 @@
# vim:set noet ts=4:
#
-# ibus-tmpl - The Input Bus template project
+# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -20,10 +20,10 @@
#
engine_xkbc_PYTHON = \
engine.py \
- factory.py \
+ factory.py \
compose_tbl.py \
- main.py \
- $(NULL)
+ main.py \
+ $(NULL)
engine_xkbcdir = $(datadir)/ibus-xkbc/engine
@@ -42,14 +42,14 @@ xkbc.xml: xkbc.xml.in
CLEANFILES = \
xkbc.xml \
*.py \
- *.pyc \
+ *.pyc \
*.pyo \
- $(NULL)
+ $(NULL)
EXTRA_DIST = \
- ibus-engine-xkbc.in \
- xkbc.xml.in \
- $(NULL)
+ ibus-engine-xkbc.in \
+ xkbc.xml.in \
+ $(NULL)
# test:
# $(ENV) LANG=en_US PYTHONPATH=$(top_srcdir) $(PYTHON) $(srcdir)/main.py
View
2  engine/compose_tbl.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
4 engine/engine.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -53,7 +53,7 @@ def __init__(self, bus, object_path):
self.__compose_state = COMPOSE_END
self.__compose_dict = None
- self.__xkbc = prefs_get_symbols_data()
+ self.__xkbc = prefs_get_xkbc_db()
self.__prop_list = self._init_props()
self.__target_layout_name = prefs_get_last_layout()
View
2  engine/factory.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
5 engine/ibus-engine-xkbc.in
@@ -1,10 +1,9 @@
#!/bin/bash
# vim:set noet ts=4:
#
-# ibus-tmpl - The Input Bus template project
+# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
2  engine/main.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
6 engine/xkbc.xml.in.in
@@ -5,16 +5,16 @@
<description>XKBC Component</description>
<exec>${libexecdir}/ibus-engine-xkbc --ibus</exec>
<version>@VERSION@</version>
- <author>Naoyuki Ishimura &lt;naoyuki.ishimura@sun.com&gt;</author>
+ <author>Naoyuki Ishimura &lt;naoyuki.ishimura@oracle.com&gt;</author>
<license>GPL</license>
- <homepage>http://code.google.com/p/ibus</homepage>
+ <homepage>http://github.com/sun-im/ibus-xkbc</homepage>
<textdomain>ibus-xkbc</textdomain>
<engines>
<engine>
<name>xkbc</name>
<license>GPL</license>
- <author>Naoyuki Ishimura &lt;naoyuki.ishimura@sun.com&gt;</author>
+ <author>Naoyuki Ishimura &lt;naoyuki.ishimura@oracle.com&gt;</author>
<icon>${pkgdatadir}/icons/ibus-xkbc.png</icon>
<layout>us</layout>
<longname>XKBC (Keyboard Emulation)</longname>
View
6 help/C/ibus-xkbc-C.omf
@@ -2,10 +2,10 @@
<omf>
<resource>
<creator>
- Sun Documentation Team
+ Oracle Documentation Team
</creator>
<maintainer>
- Sun Documentation Team
+ Oracle Documentation Team
</maintainer>
<title>
Keyboard Layout Emulation Input Method (XKBC)
@@ -25,6 +25,6 @@
<identifier url="ibus-xkbc.xml"/>
<language code="C"/>
<relation seriesid="00dc1156-d4c6-11d8-9917-c62edd84afcc"/>
- <rights type="GNU FDL" license.version="1.1" holder="Sun Microsystems"/>
+ <rights type="GNU FDL" license.version="1.1" holder="Oracle and/or its affiliates"/>
</resource>
</omf>
View
4 help/C/ibus-xkbc.xml
@@ -3,9 +3,9 @@
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY legal SYSTEM "legal.xml">
<!ENTITY appname "iBus XKBC">
- <!ENTITY author1 "Sun">
+ <!ENTITY author1 "Oracle">
<!ENTITY author2 "Input Method dev">
- <!ENTITY publisher "Sun Microsystems, Inc.">
+ <!ENTITY publisher "Oracle">
<!ENTITY appversion "1.0">
<!ENTITY manrevision "1.0">
<!ENTITY date "January 2010">
View
18 ibus-xkbc.spec.in
@@ -3,10 +3,10 @@ Name: @PACKAGE_NAME@
Version: @PACKAGE_VERSION@
Release: 1%{?dist}
Summary: The XKBC engine for IBus input platform
-License: GPL
+License: GPLv2
Group: System Environment/Libraries
-URL: http://code.google.com/p/ibus/
-Source0: http://ibus.googlecode.com/files/%{name}-%{version}.tar.gz
+URL: http://github.com/sun-im/ibus-xkbc/
+Source0: http://cloud.github.com/download/sun-im/ibus-xkbc/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -15,15 +15,17 @@ BuildRequires: libtool
BuildRequires: python-devel
BuildRequires: pkgconfig
-Requires: ibus >= 1.2.0.20090904
+Requires: ibus >= %{require_ibus_version}
%description
-The XKBC engine for IBus platform. It provides keyboard layout emulation input method.
+The XKBC engine for IBus platform.
+It provides keyboard layout emulation input method.
%prep
%setup -q
%build
+sh autogen.sh
%configure --disable-static
# make -C po update-gmo
make %{?_smp_mflags}
@@ -46,5 +48,11 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/ibus/component/*
%changelog
+* Wed Feb 04 2010 Peng Wu <pwu@redhat.com> - 1.2.0.20100115-3
+- Correct home page url.
+
+* Wed Feb 04 2010 Peng Wu <pwu@redhat.com> - 1.2.0.20100115-2
+- Fixes koji build for F-13.
+
* Fri Oct 30 2009 Naoyuki Ishimura <naoyuki.ishimura@sun.com> - 0.1.0-1
- The first version.
View
4 icons/Makefile.am
@@ -1,8 +1,8 @@
# vim:set noet ts=4:
#
-# ibus-tmpl - The Input Bus template project
+# ibus-xkbc - The XKeyboard Config based engine for IBus
#
-# Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
108 patches/ibus-1.3.3-on-nv-ss12.patch
@@ -0,0 +1,108 @@
+diff -ruNa ibus-1.3.3.orig/bus/connection.c ibus-1.3.3/bus/connection.c
+--- ibus-1.3.3.orig/bus/connection.c 2010-03-25 16:29:20.000000000 +0900
++++ ibus-1.3.3/bus/connection.c 2010-05-26 13:28:29.917200467 +0900
+@@ -28,6 +28,7 @@
+
+ /* BusConnectionPriv */
+ struct _BusConnectionPrivate {
++ char dummy;
+ };
+ typedef struct _BusConnectionPrivate BusConnectionPrivate;
+
+diff -ruNa ibus-1.3.3.orig/bus/dbusimpl.c ibus-1.3.3/bus/dbusimpl.c
+--- ibus-1.3.3.orig/bus/dbusimpl.c 2010-03-25 16:29:20.000000000 +0900
++++ ibus-1.3.3/bus/dbusimpl.c 2010-05-25 15:15:17.717446408 +0900
+@@ -804,6 +804,42 @@
+ /* ignore signal from local interface */
+ return FALSE;
+ }
++ /* for Virtual Keyboard support */
++ if (ibus_message_is_signal (message,
++ "org.freedesktop.IBus.VKB",
++ "SendText")) {
++ gboolean retval;
++ IBusText *text;
++ IBusError *error = NULL;
++
++ retval = ibus_message_get_args (message,
++ &error,
++ IBUS_TYPE_TEXT, &text,
++ G_TYPE_INVALID);
++
++ if (text) {
++ bus_input_context_send_text_to_last_focused (text);
++ }
++ return FALSE;
++ }
++ if (ibus_message_is_signal (message,
++ "org.freedesktop.IBus.VKB",
++ "SendKey")) {
++ gboolean retval;
++ guint keyval, state;
++ IBusError *error = NULL;
++
++ retval = ibus_message_get_args (message,
++ &error,
++ G_TYPE_UINT, &keyval,
++ G_TYPE_UINT, &state,
++ G_TYPE_INVALID);
++
++ bus_input_context_send_key_to_last_focused (keyval, 0, state);
++
++ return FALSE;
++ }
++
+
+ ibus_message_set_sender (message, bus_connection_get_unique_name (connection));
+
+diff -ruNa ibus-1.3.3.orig/bus/dbusimpl.c ibus-1.3.3/bus/dbusimpl.c
+--- ibus-1.3.3.orig/bus/inputcontext.c 2010-04-30 21:22:39.000000000 +0900
++++ ibus-1.3.3/bus/inputcontext.c 2010-05-25 15:13:47.390586237 +0900
+@@ -1175,11 +1175,15 @@
+ return context->has_focus;
+ }
+
++static BusInputContext *target_context = NULL;
++
+ void
+ bus_input_context_focus_in (BusInputContext *context)
+ {
+ g_assert (BUS_IS_INPUT_CONTEXT (context));
+
++ target_context = context;
++
+ if (context->has_focus)
+ return;
+
+@@ -1241,6 +1245,30 @@
+ }
+
+ void
++bus_input_context_send_text_to_last_focused (IBusText *text)
++{
++ if (target_context) {
++ bus_input_context_send_signal (target_context,
++ "CommitText",
++ IBUS_TYPE_TEXT, &text,
++ G_TYPE_INVALID);
++ }
++}
++
++void
++bus_input_context_send_key_to_last_focused (guint keyval, guint keycode, guint state)
++{
++ if (target_context) {
++ bus_input_context_send_signal (target_context,
++ "ForwardKeyEvent",
++ G_TYPE_UINT, &keyval,
++ G_TYPE_UINT, &keycode,
++ G_TYPE_UINT, &state,
++ G_TYPE_INVALID);
++ }
++}
++
++void
+ bus_input_context_focus_out (BusInputContext *context)
+ {
+ g_assert (BUS_IS_INPUT_CONTEXT (context));
+
View
4 setup/Makefile.am
@@ -1,8 +1,8 @@
# vim:set noet ts=4:
#
-# ibus-pinyin - The PinYin engine for IBus
+# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
2  setup/hotkey.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
5 setup/ibus-setup-xkbc.in
@@ -1,10 +1,9 @@
#!/bin/bash
# vim:set noet ts=4:
#
-# ibus-tmpl - The Input Bus template project
+# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
2  setup/keyeventutil.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
2  setup/layout.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
19 setup/main.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -39,7 +39,8 @@ def help_cb(widget, data):
return False
def print_help(out, v=0):
- print >> out, "-c need <file> artument"
+ print >> out, "-k # virtual keyboard symbol list config"
+ print >> out, "-c <file> # re-create xkbc.dat data file"
sys.exit(v)
def _show_help():
@@ -58,23 +59,27 @@ def main():
# -------------------------------------------------------------
# Re-create ibus-xkbc/data/xkbc.dat
# this option is for just maintenance purpose
- shortopt = "c:"
+ shortopt = "c:k"
try:
opts, args = getopt.getopt(sys.argv[1:], shortopt)
except:
print_help(sys.stderr, 1)
+ vkb_mode = False
for o, a in opts:
if o == "-c":
import prefs
prefs.recreate_db(a)
sys.exit(0)
+ elif o == "-k":
+ vkb_mode = True
else:
print_help(sys.stderr, 1)
# -------------------------------------------------------------
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- window.set_title(UI_TITLE)
+ title = UI_TITLE if vkb_mode == False else UI_TITLE_VKB
+ window.set_title(title)
window.set_size_request(400, 500)
window.connect("delete_event", lambda w, e: gtk.main_quit())
@@ -99,8 +104,6 @@ def main():
scrolled_window.add_with_viewport(view)
scrolled_window.set_size_request(400, 400)
- notebook.append_page(scrolled_window, gtk.Label(UI_SOURCE_LAYOUT_TAB))
-
# Hot key
hotkey_box = gtk.VBox(False, 0)
cycle_hotkey_list = hotkey.CycleHotkeyList(window)
@@ -109,7 +112,9 @@ def main():
rcycle_hotkey_list = hotkey.RCycleHotkeyList(window)
hotkey_box.pack_start(rcycle_hotkey_list.get_window(), True, False, 0)
- notebook.append_page(hotkey_box, gtk.Label(UI_HOTKEY_TAB))
+ if vkb_mode == False:
+ notebook.append_page(scrolled_window, gtk.Label(UI_SOURCE_LAYOUT_TAB))
+ notebook.append_page(hotkey_box, gtk.Label(UI_HOTKEY_TAB))
button_box = gtk.HBox(False, 10)
ok_button = gtk.Button(UI_OK)
View
24 setup/prefs.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -31,21 +31,21 @@
import cPickle as pickle
PICKLE_FILE = os.getenv('XKBC_DATAFILE')
all_layouts = None
-all_symbols = None
+xkbc_db = None
-def prefs_get_symbols_data():
- global all_layouts, all_symbols
- if all_symbols == None:
+def prefs_get_xkbc_db():
+ global all_layouts, xkbc_db
+ if xkbc_db == None:
f = open(PICKLE_FILE)
- all_layouts, all_symbols = pickle.load(f)
+ all_layouts, xkbc_db = pickle.load(f)
f.close()
- return all_symbols
+ return xkbc_db
def prefs_get_layouts():
- global all_layouts, all_symbols
+ global all_layouts, xkbc_db
if all_layouts == None:
f = open(PICKLE_FILE)
- all_layouts, all_symbols = pickle.load(f)
+ all_layouts, xkbc_db = pickle.load(f)
f.close()
return all_layouts
@@ -159,7 +159,7 @@ def get_last_layout(self):
return DEFAULT_LAYOUTS[0]
-class _ConfigDummy:
+class _ConfigDummy(object):
def __init__(self):
self.__dict = {}
@@ -222,6 +222,10 @@ def prefs_get_user_layouts():
user_list = _prefs.get_user_layouts()
return _get_layout_objects(user_list)
+def prefs_get_user_layouts_from_config():
+ user_list = _prefs.get_user_layouts_from_config()
+ return _get_layout_objects(user_list)
+
def prefs_get_physical_layout():
return _prefs.get_physical_layout()
View
3  setup/vars.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -19,6 +19,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
UI_TITLE = "XKBC Configuration"
+UI_TITLE_VKB = "Virtual Keyboard layout Configuration"
UI_LAYOUT_TAB = "Target Layout"
UI_SOURCE_LAYOUT_TAB = "Physical Layout"
UI_HOTKEY_TAB = "Hot Keys"
View
3  setup/xkbc/Makefile.am
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -22,7 +22,6 @@ setup_xkbc_PYTHON = \
__init__.py \
constants.py \
parser.py \
- props.py \
unicodeutil.py \
xkb_component.py \
xkb_config.py \
View
2  setup/xkbc/__init__.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
53 setup/xkbc/constants.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -49,6 +49,7 @@
KWD_KEYMAP = "xkb_keymap"
KWD_GEOMETRY = "xkb_geometry"
+# symbols specific
KWD_MODIFIER_MAP = "modifier_map"
KWD_TYPE = "type"
KWD_KEY = ["key", "Key"]
@@ -71,6 +72,55 @@
KWD_INDICATOR = "indicator"
KWD_VIRTUAL = "virtual"
+# geometry specific
+KWD_DESCRIPTION = "description"
+KWD_WIDTH = "width"
+KWD_HEIGHT = "height"
+KWD_SHAPE = "shape"
+KWD_SHAPE_CORNERRADIUS = "shape.cornerRadius"
+KWD_OUTLINE = "outline"
+KWD_SOLID = "solid"
+KWD_SECTION = "section"
+KWD_SECTION_LEFT = "section.left"
+KWD_SECTION_TOP = "section.top"
+KWD_ROW_LEFT = "row.left"
+KWD_ROW_TOP = "row.top"
+KWD_KEY_SHAPE = "key.shape"
+KWD_KEY_GAP = "key.gap"
+KWD_TOP = "top"
+KWD_LEFT = "left"
+KWD_PRIORITY = "priority"
+KWD_ROW = "row"
+KWD_ROW_VERTICAL = "row.vertical"
+KWD_KEYS = "keys"
+KWD_INDICATOR_ONCOLOR = "indicator.onColor"
+KWD_INDICATOR_OFFCOLOR = "indicator.offColor"
+KWD_INDICATOR_TOP = "indicator.top"
+KWD_INDICATOR_SHAPE = "indicator.shape"
+KWD_INDICATOR = "indicator"
+KWD_INDICATOR_PRIORITY = "indicator.priority"
+KWD_INDICATOR_LEFT = "indicator.left"
+KWD_TEXT_TOP = "text.top"
+KWD_TEXT_COLOR = "text.color"
+KWD_TEXT = "text"
+KWD_TEXT_FONT = "text.font"
+KWD_TEXT_FONTSIZE = "text.fontSize"
+KWD_TEXT_FONTWIDTH = "text.fontWidth"
+KWD_TEXT_WEIGHT = "text.weight"
+KWD_TEXT_SLANT = "text.slant"
+KWD_LOGO = "logo"
+KWD_CORNERRADIUS = "cornerRadius"
+KWD_CORNER = "corner"
+KWD_APPROX = "approx"
+KWD_PRIMARY = "primary"
+
+KWD_BASE_COLOR = "baseColor"
+KWD_LABEL_COLOR = "labelColor"
+KWD_KEY_COLOR = "key.color"
+KWD_COLOR = "color"
+KWD_OVERLAY = "overlay"
+KWD_ANGLE = "angle"
+
# componet type
TYPE_SYMBOLS = 1 << 0
TYPE_TYPES = 1 << 1
@@ -103,3 +153,4 @@
ST_CONTROL = 1 << 2
ST_LEVEL_3 = ST_GROUP_2 = ST_ALT_R = 1 << 7 # altgraph / modeswitch / shift-level3
ST_ALT_L = 0x4000048
+ST_NUM_LOCK = 1 << 10
View
8 setup/xkbc/parser.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -120,9 +120,11 @@ def _expand_tokens(self, line):
in_string = False
self._append(buf, start, end, line)
start = end = idx
- elif c in self.escape:
- in_escape = True
else:
+ if c in self.escape:
+ in_escape = True
+ elif in_escape:
+ in_escape = False
end = idx
elif c in self.string_delimiter:
in_string = True
View
28 setup/xkbc/props.py
@@ -1,28 +0,0 @@
-# To change this template, choose Tools | Templates
-# and open the template in the editor.
-
-__author__="naoyuki"
-__date__ ="$Jul 30, 2009 11:24:47 AM$"
-
-from ConfigParser import ConfigParser
-
-CONFIG_FILE = "xkbc.conf"
-config = ConfigParser()
-config.read(CONFIG_FILE)
-
-DATA_SECTION = "DATA"
-DATA_DIR = "data_dir"
-
-
-default_data_dir = "/usr/X11/share/X11/xkb"
-
-data_dir = config.get(DATA_SECTION, DATA_DIR)
-
-def get_data_dir():
- return data_dir
-
-def test():
- print "xkb data comes from " + data_dir;
-
-if __name__ == "__main__":
- test()
View
49 setup/xkbc/unicodeutil.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -1379,7 +1379,7 @@ def unicode_upper(letter):
upper_case = 0x3a3
elif letter == 0x3ac:
upper_case = 0x386
- elif lstter == 0x3ad:
+ elif letter == 0x3ad:
upper_case = 0x388
elif letter == 0x3ae:
upper_case = 0x389
@@ -1457,7 +1457,7 @@ def unicode_lower(letter):
lower_case = 0x3c2
elif letter == 0x386:
lower_case = 0x3ac
- elif lstter == 0x388:
+ elif letter == 0x388:
lower_case = 0x3ad
elif letter == 0x389:
lower_case = 0x3ae
@@ -1587,6 +1587,49 @@ def check_unicode_representation(keysym):
"<AB07>" : "<LatM>"
}
+keypad_keysym_to_label = {
+ "KP_Space" : "",
+ "KP_Tab" : "Tab",
+ "KP_Enter" : "Enter",
+ "KP_F1" : "F1",
+ "KP_F2" : "F2",
+ "KP_F3" : "F3",
+ "KP_F4" : "F4",
+ "KP_Home" : "Home",
+ "KP_Left" : "Left",
+ "KP_Up" : "Up",
+ "KP_Right" : "Right",
+ "KP_Down" : "Down",
+ "KP_Page_Up" : "Pg Up",
+ "KP_Page_Down" : "Pg Dn",
+ "KP_End" : "End",
+ "KP_Begin" : "Begin",
+ "KP_Insert" : "Ins",
+ "KP_Delete" : "Del",
+ "KP_Multiply" : "*",
+ "KP_Add" : "+",
+ "KP_Separator" : "Sep",
+ "KP_Subtract" : "-",
+ "KP_Decimal" : ".",
+ "KP_Divide" : "/",
+ "KP_0" : "0",
+ "KP_1" : "1",
+ "KP_2" : "2",
+ "KP_3" : "3",
+ "KP_4" : "4",
+ "KP_5" : "5",
+ "KP_6" : "6",
+ "KP_7" : "7",
+ "KP_8" : "8",
+ "KP_9" : "9",
+ "KP_Equal" : "=",
+ }
+
+def get_key_pad_label(key_sym):
+ if keypad_keysym_to_label.has_key(key_sym):
+ return keypad_keysym_to_label[key_sym]
+ return None
+
def key_name_alias(key_name):
if key_name in key_name_alias_tbl.keys():
return key_name_alias_tbl[key_name]
View
2  setup/xkbc/xkb_component.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
59 setup/xkbc/xkb_config.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -33,10 +33,14 @@
from unicodeutil import *
DEFAULT_XKB_DATA_DIR = os.getenv('XKB_DATA_DIR')
+VKB_GEOM_DIR = os.getenv('VKB_GEOM_DIR')
# XKB Config database
class XKBCDB:
+ # XKBCDB contains all of necessary information for layout emulation
+ # and virtual keyboard.
+ #
def __init__(self, dir = DEFAULT_XKB_DATA_DIR, type = TYPE_ALL):
self.symbols_dict = None
self.keycodes_dict = None
@@ -54,9 +58,13 @@ def __init__(self, dir = DEFAULT_XKB_DATA_DIR, type = TYPE_ALL):
self.types_dict = TypesParser(dir).get_components()
if type & TYPE_GEOMETRY:
self.geometry_dict = GeometryParser(dir).get_components()
+ tmp_dic = GeometryParser(VKB_GEOM_DIR).get_components()
+ self.geometry_dict.update(tmp_dic)
+
if type & TYPE_KEYMAP:
self.keymap_dict = KeymapParser(dir).get_components()
+ # Selects only default marked symbol component
def select_default_symbols(self, sym_dict):
dd = {}
for v in sym_dict.values():
@@ -69,6 +77,7 @@ def select_default_symbols(self, sym_dict):
dd[name] = v
return dd
+ # Selects subdirectory names in xkb/symbols directory
def select_subdirs(self, keys):
ret_array = []
for k in keys:
@@ -95,6 +104,7 @@ def search_key_name(self, symbol_name, keysym, state):
key_name = akey_name
return key_name
+ # returns symbol dict
def _get_sym_dict(self, symbol_name):
search_default = False
sub_id = symbol_name.find(NAME_START)
@@ -129,6 +139,7 @@ def _get_sym_dict(self, symbol_name):
return sym_dict
+ # returns key name (like <AE01>) if sym_dict has 'keysym'
def _get_key_name(self, sym_dict, keysym, state):
for dict_label, list_label in self.search_order_list:
candidate_dict = sym_dict.get_dict(dict_label)
@@ -158,10 +169,16 @@ def _get_key_name(self, sym_dict, keysym, state):
def get_trans_ustr(self, symbol_name, key_name, state):
keysym = self.get_keysym(symbol_name, key_name, state)
+
if keysym == None:
return None
+ elif keysym.startswith("0x100"):
+ # This seems to mean just UCS-2 representation with 0x100 appened.
+ code = check_unicode_representation(keysym[4:])
+ if code == None:
+ return None
elif keysym.startswith("0x"):
- # This means keysym is likely to represent UCS-4 code string.
+ # This may represents keysym as UCS-4 code string.
code = int(keysym[2:], 16)
if code > 0xffff:
return ucs4_to_utf8(code)
@@ -187,8 +204,24 @@ def _get_sym_array(self, cand_dict, key_name):
akey_name = key_name_alias_r(key_name)
if akey_name != None and cand_dict.has_key(akey_name):
return cand_dict[akey_name]
+
return None
+ def get_unichar_array(self, symbol_name, key_name):
+
+ char_array = []
+ char_array.append(self.get_trans_ustr(symbol_name, key_name, 0))
+ char_array.append(self.get_trans_ustr(symbol_name, key_name, ST_SHIFT))
+ char_array.append(self.get_trans_ustr(symbol_name, key_name, ST_LEVEL_3))
+ char_array.append(self.get_trans_ustr(symbol_name, key_name, ST_SHIFT | ST_LEVEL_3))
+ caps_array = []
+ caps_array.append(self.get_trans_ustr(symbol_name, key_name, ST_CAPS))
+ caps_array.append(self.get_trans_ustr(symbol_name, key_name, ST_CAPS | ST_SHIFT))
+ caps_array.append(self.get_trans_ustr(symbol_name, key_name, ST_CAPS | ST_LEVEL_3))
+ caps_array.append(self.get_trans_ustr(symbol_name, key_name, ST_CAPS | ST_SHIFT | ST_LEVEL_3))
+
+ return (char_array, caps_array)
+
def get_keysym(self, symbol_name, key_name, state):
if not self.symbols_dict.has_key(symbol_name):
@@ -242,15 +275,25 @@ def _calc_sym(self, sym_array, state):
# if g is None, then fallback to e
# if h is None, then fallback to f
- if group > len(sym_array):
+ if group >= len(sym_array):
group = 0
+
grp_array = sym_array[group]
- if level > len(grp_array):
- if level < 2:
+
+ gl = len(grp_array)
+ if level >= len(grp_array):
+ if level == 0:
+ return None
+
+ if level == 3 and gl > 1:
+ level = 1
+ else:
level = 0
- level -= 2
- symbol = grp_array[level]
+ try:
+ symbol = grp_array[level]
+ except:
+ return None
return symbol
@@ -270,7 +313,7 @@ def get_keymap_dict(self):
return self.keymap_dict
def xkbc_get_db():
- xkbc = XKBCDB(type = TYPE_SYMBOLS)
+ xkbc = XKBCDB(type = TYPE_SYMBOLS | TYPE_GEOMETRY)
return xkbc
if __name__ == "__main__":
View
529 setup/xkbc/xkb_geometry.py
@@ -1,8 +1,10 @@
+#!/usr/bin/env python
+#
# vim:set et sts=4 sw=4:
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -18,9 +20,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-__author__="naoyuki"
-__date__ ="$Aug 13, 2009 5:23:29 PM$"
-
from constants import *
from parser import *
@@ -42,10 +41,532 @@ def get_component_dirname(self):
class XKB_Geometry(XKB_Component):
+ # ------------ Public interfaces ----------------
+ def get_sections(self):
+ return self._section_list
+
+ def get_width(self):
+ if self._width:
+ return self._width
+ return 100
+
+ def get_height(self):
+ if self._height:
+ return self._height
+ return 100
+
+ def get_section_left(self):
+ if self._section_left:
+ return self._section_left
+ return 0
+
+ def get_section_top(self):
+ if self._section_top:
+ return self._section_top
+ return 0
+
+ def get_key_gap(self):
+ if self._key_gap:
+ return self._key_gap
+ return 0
+
+ def get_row_left(self):
+ if self._row_left:
+ return self._row_left
+ return 0
+
+ def get_row_top(self):
+ if self._row_top:
+ return self._row_top
+ return 0
+
+ def get_key_shape(self):
+ if self._key_shape:
+ return self._key_shape
+ return "NORM"
+
+ def get_key_color(self):
+ if self._key_color:
+ return self._key_color
+ if self._color:
+ return self._color
+ return "gray10"
+
+ def get_key_gap(self):
+ if self._key_gap:
+ return self._key_gap
+ return 1
+
+ def get_shape_body(self, name):
+ if self._shape_dict.has_key(name):
+ return self._shape_dict[name]
+ print "Unknown shape :", name
+ return self._shape_dict["NORM"]
+
+ # ------------------------------------------------
+
def __init__(self):
XKB_Component.__init__(self)
+ self._description = None
+ self._shape_dict = {}
+ self._outline_list = []
+ self._solid_list = []
+ self._indicator_list = []
+ self._indicator_onColor = None
+ self._indicator_offColor = None
+ self._indicator_top = None
+ self._indicator_shape = None
+ self._indicator_left = None
+ self._indicator_priority = None
+ self._width = None
+ self._height = None
+ self._shape_cornerRadius = None
+ self._section_list = []
+ self._section_left = None
+ self._section_top = None
+ self._row_left = None
+ self._row_top = None
+ self._key_shape = None
+ self._key_gap = None
+ self._key_color = None
+ self._base_color = None
+ self._label_color = None
+ self._text_top = None
+ self._text_color = None
+ self._text_font = None
+ self._text_fontSize = None
+ self._text_fontWidth = None
+ self._text_weight = None
+ self._text_slant = None
+ self._text_list = []
+ self._alias_dict = {}
+ self._include_list = []
+ self._color = None
+ self._logo_list = []
def set_content(self, content):
length = len(content)
i = 0
+ while i < length:
+ token = content[i]; i += 1
+
+ if token == KWD_DESCRIPTION:
+ self._description = content[i + 1]; i += 3
+ elif token == KWD_WIDTH:
+ self._width = float(content[i + 1]); i += 3
+ elif token == KWD_HEIGHT:
+ self._height = float(content[i + 1]); i += 3
+ elif token == KWD_SHAPE_CORNERRADIUS:
+ self._shape_cornerRadius = float(content[i + 1]); i += 3
+ elif token == KWD_SHAPE:
+ shape_name = content[i]
+ try:
+ self._shape_dict[shape_name] = _Shape(content[i + 1]); i+= 3
+ except:
+ print self.get_name(), shape_name, content[i + 1]
+ elif token == KWD_OUTLINE:
+ self._outline_list.append(_Outline(content[i], content[i + 1])); i += 3
+ elif token == KWD_SECTION_LEFT:
+ self._section_left = float(content[i + 1]); i += 3
+ elif token == KWD_SECTION_TOP:
+ self._section_top = float(content[i + 1]); i += 3
+ elif token == KWD_ROW_LEFT:
+ self._row_left = float(content[i + 1]); i += 3
+ elif token == KWD_ROW_TOP:
+ self._row_top = float(content[i + 1]); i += 3
+ elif token == KWD_ROW_VERTICAL:
+ self._row_vertical = bool(content[i + 1]); i += 3
+ elif token == KWD_KEY_SHAPE:
+ self._key_shape = content[i + 1]; i += 3
+ elif token == KWD_KEY_GAP:
+ self._key_gap = float(content[i + 1]); i += 3
+ elif token == KWD_SECTION:
+ self._section_list.append(_Section(content[i], content[i + 1], self)); i += 3
+ elif token == KWD_SOLID:
+ self._solid_list.append(_Solid(content[i], content[i + 1])); i += 3
+ elif token == KWD_INDICATOR_ONCOLOR:
+ self._indicator_onColor = content[i + 1]; i += 3
+ elif token == KWD_INDICATOR_OFFCOLOR:
+ self._indicator_offColor = content[i + 1]; i += 3
+ elif token == KWD_INDICATOR_TOP:
+ self._indicator_top = float(content[i + 1]); i += 3
+ elif token == KWD_INDICATOR_SHAPE:
+ self._indicator_shape = content[i + 1]; i += 3
+ elif token == KWD_INDICATOR_LEFT:
+ self._indicator_left = float(content[i + 1]); i += 3
+ elif token == KWD_INDICATOR:
+ self._indicator_list.append(_Indicator(content[i], content[i + 1])); i += 3
+ elif token == KWD_TEXT_TOP:
+ self._text_top = float(content[i + 1]); i += 3
+ elif token == KWD_TEXT_COLOR:
+ self._text_color = content[i + 1]; i += 3
+ elif token == KWD_TEXT_FONT:
+ self._text_font = content[i + 1]; i += 3
+ elif token == KWD_TEXT_FONTSIZE:
+ self._text_fontSize = float(content[i + 1]); i += 3
+ elif token == KWD_TEXT_FONTWIDTH:
+ self._text_fontWidth = content[i + 1]; i += 3
+ elif token == KWD_TEXT_WEIGHT:
+ self._text_weight = content[i + 1]; i += 3
+ elif token == KWD_TEXT_SLANT:
+ self._text_slant = content[i + 1]; i += 3
+ elif token == KWD_TEXT:
+ self._text_list.append(_Text(content[i], content[i + 1])); i += 3
+ elif token == KWD_ALIAS:
+ alias_name = content[i]
+ self._alias_dict[alias_name] = content[i + 2]; i += 4
+ elif token == KWD_INCLUDE:
+ self._include_list.append(content[i]); i += 1
+ elif token == KWD_BASE_COLOR:
+ self._base_color = content[i + 1]; i += 3
+ elif token == KWD_LABEL_COLOR:
+ self._label_color = content[i + 1]; i += 3
+ elif token == KWD_KEY_COLOR:
+ self._key_color = content[i + 1]; i += 3
+ elif token == KWD_INDICATOR_PRIORITY:
+ self._indicator_priority = float(content[i + 1]); i += 3
+ elif token == KWD_COLOR:
+ self._color = content[i + 1]; i += 3
+ elif token == KWD_LOGO:
+ self._logo_list.append(_Logo(content[i], content[i + 1])); i += 3
+ else:
+ # raise ParserException("Geometry contents: Parse error: " + self._name + " : " + token)
+ print "YET HANDLED", token
+
+class _Shape:
+ # ------------ Public Interfaces -------------
+ def get_coord_list(self):
+ return self._coord_list
+
+ # ---------------------------------------------
+ def __init__(self, content):
+ self._primary = None
+ self._approx = None
+ self._cornerRadius = None
+ self._corner = None
+ self._coord_list = []
+
+ length = len(content)
+ i = 0
+ while i < length:
+ token = content[i]; i += 1
+ if token == KWD_CORNERRADIUS:
+ self._cornerRadius = float(content[i + 1]); i += 2
+ elif token == KWD_CORNER:
+ self._corner = float(content[i + 1]); i += 2
+ elif token == KWD_PRIMARY:
+ self._primary = _Coordinate(content[i + 1]); i += 2
+ elif token == KWD_APPROX:
+ self._primary = _Coordinate(content[i + 1]); i += 2
+ elif token == LIST_START:
+ # this may be format error entry, but handle it anyway
+ # shape "XXXX" {[x, y]} not {{[x, y'}}
+ j = i - 1
+ while content[i] != LIST_END:
+ i += 1
+ i += 1
+ token = list(content[j:i])
+ self._coord_list.append(_Coordinate(token))
+ else:
+ self._coord_list.append(_Coordinate(token))
+
+class _Coordinate:
+ # ------------ Public Interfaces -------------
+ def get_point_list(self):
+ return self._point_list
+
+ # ---------------------------------------------
+ def __init__(self, content):
+ self._point_list = []
+
+ length = len(content)
+ i = 0
+ while i < length:
+ token = content[i]; i += 1
+ if token == LIST_START:
+ x = float(content[i]); i += 1
+ y = float(content[i]); i += 2 # skip LIST_END
+ self._point_list.append((x, y))
+
+class _Section:
+ # ------------ Public Interfaces -------------
+ def get_name(self):
+ return self._name
+
+ def get_left(self):
+ if self._left:
+ return self._left
+ return self._parent.get_section_left()
+
+ def get_top(self):
+ if self._top:
+ return self._top
+ return self._parent.get_section_top()
+
+ def get_key_gap(self):
+ if self._key_gap:
+ return self._key_gap
+ return self._parent.get_key_gap()
+
+ def get_row_list(self):
+ return self._row_list
+
+ def get_row_left(self):
+ if self._row_left:
+ return self._row_left
+ return self._parent.get_row_left()
+
+ def get_row_top(self):
+ if self._row_top:
+ return self._row_top
+ return self._parent.get_row_top()
+
+ def get_key_shape(self):
+ if self._key_shape:
+ return self._key_shape
+ return self._parent.get_key_shape()
+
+ def get_key_color(self):
+ if self._key_color:
+ return self._key_color
+ return self._parent.get_key_color()
+
+ def get_key_gap(self):
+ if self._key_gap:
+ return self._key_gap
+ return self._parent.get_key_gap()
+
+ # ---------------------------------------------
+ def __init__(self, name, content, parent):
+ self._name = name
+ self._parent = parent
+ self._row_list = []
+ self._row_vertical = None
+ self._row_left = None
+ self._row_top = None
+ self._top = None
+ self._left = None
+ self._width = None
+ self._height = None
+ self._priority = None
+ self._key_color = None
+ self._key_gap = None
+ self._key_shape = None
+ self._indicator_top = None
+ self._indicator_onColor = None
+ self._indicator_offColor = None
+ self._indicator_shape = None
+ self._indicator_list = []
+ self._text_list = []
+ self._text_color = None
+ self._solid_list = []
+ self._overlay_list = []
+ self._angle = None
+
+ length = len(content)
+ i = 0
+ while i < length:
+ token = content[i]; i += 1
+ if token == KWD_TOP:
+ self._top = float(content[i + 1]); i += 3
+ elif token == KWD_ROW:
+ self._row_list.append(_Row(content[i], self)); i += 2
+ elif token == KWD_LEFT:
+ self._left = float(content[i + 1]); i += 3
+ elif token == KWD_KEY_COLOR:
+ self._key_color = content[i + 1]; i += 3
+ elif token == KWD_INDICATOR_TOP:
+ self._indicator_top = float(content[i + 1]); i += 3
+ elif token == KWD_INDICATOR_ONCOLOR:
+ self._indicator_onColor = content[i + 1]; i += 3
+ elif token == KWD_INDICATOR_OFFCOLOR:
+ self._indicator_offColor = content[i + 1]; i += 3
+ elif token == KWD_INDICATOR_SHAPE:
+ self._indicator_shape = content[i + 1]; i += 3
+ elif token == KWD_INDICATOR:
+ self._indicator_list.append(_Indicator(content[i], content[i + 1])); i += 3
+ elif token == KWD_TEXT:
+ self._text_list.append(_Text(content[i], content[i + 1])); i += 3
+ elif token == KWD_TEXT_TOP:
+ self._text_top = float(content[i + 1]); i += 3
+ elif token == KWD_KEY_GAP:
+ self._key_gap = float(content[i + 1]); i += 3
+ elif token == KWD_KEY_SHAPE:
+ self._key_shape = content[i + 1]; i += 3
+ elif token == KWD_WIDTH:
+ self._width = float(content[i + 1]); i += 3
+ elif token == KWD_HEIGHT:
+ self._height = float(content[i + 1]); i += 3
+ elif token == KWD_PRIORITY:
+ self._priority = int(content[i + 1]); i += 3
+ elif token == KWD_SOLID:
+ self._solid_list.append(_Solid(content[i], content[i + 1])); i += 3
+ elif token == KWD_OVERLAY:
+ self._overlay_list.append(_Overlay(content[i], content[i + 1])); i += 3
+ elif token == KWD_ROW_VERTICAL:
+ self._row_vertical = bool(content[i + 1]); i += 3
+ elif token == KWD_ANGLE:
+ self._angle = float(content[i + 1]); i += 3
+ elif token == KWD_ROW_LEFT:
+ self._row_left = float(content[i + 1]); i += 3
+ elif token == KWD_ROW_TOP:
+ self._row_top = float(content[i + 1]); i += 3
+ elif token == KWD_TEXT_COLOR:
+ self._text_color = content[i + 1]; i += 3
+ else:
+ print "Unkown: ", token
+
+class _Row:
+ # ------------ Public Interfaces -------------
+ def get_left(self):
+ if self._left:
+ return self._left
+ return self._parent.get_row_left()
+
+ def get_top(self):
+ if self._top:
+ return self._top
+ return self._parent.get_row_top()
+
+ def get_key_list(self):
+ if self._keys:
+ return self._keys.get_key_list()
+ return []
+
+ def get_key_shape(self):
+ if self._key_shape:
+ return self._key_shape
+ return self._parent.get_key_shape()
+
+ def get_key_color(self):
+ return self._parent.get_key_color()
+
+ def get_key_gap(self):
+ return self._parent.get_key_gap()
+
+ # ----------------------------------------------
+ def __init__(self, content, parent):
+ self._parent = parent
+ self._top = None
+ self._left = None
+ self._key_shape = None
+ self._keys = None
+
+ length = len(content)
+ i = 0
+ while i < length:
+ token = content[i]; i += 1
+ if token == KWD_TOP:
+ self._top = float(content[i + 1]); i += 3
+ elif token == KWD_LEFT:
+ self._left = float(content[i + 1]); i += 3
+ elif token == KWD_KEY_SHAPE:
+ self._key_shape = content[i + 1]; i += 3
+ elif token == KWD_KEYS:
+ self._keys = _Keys(content[i], self); i += 2
+ else:
+ "Unkown Row token :", token
+
+class _Keys:
+ # ------------ Public Interfaces -------------
+ def get_key_list(self):
+ return self._key_list
+
+ # ----------------------------------------------
+ def __init__(self, content, parent):
+ self._parent = parent
+ self._key_list = []
+
+ length = len(content)
+ i = 0
+ while i < length:
+ token = content[i]; i += 1
+ self._key_list.append(_Key(token, self._parent))
+
+class _Key:
+ # ------------ Public Interfaces -------------
+ def get_name(self):
+ if self._name:
+ return self._name
+ return "<XXXX>" # should never comes here
+
+ def get_shape(self):
+ if self._shape:
+ return self._shape
+ return self._parent.get_key_shape()
+
+ def get_color(self):
+ if self._color:
+ return self._color
+ return self._parent.get_key_color()
+
+ def get_gap(self):
+ if self._gap:
+ return self._gap
+ return self._parent.get_key_gap()
+
+ # ----------------------------------------------
+ def __init__(self, content, parent):
+ self._parent = parent
+ self._name = None
+ self._shape = None
+ self._color = None
+ self._gap = None
+
+ if type(content) == type(""):
+ self._name = content
+ else:
+ length = len(content)
+ i = 0
+ while i < length:
+ token = content[i]; i += 1
+ if token.startswith(SYM_START):
+ self._name = token
+ elif token == KWD_COLOR:
+ self._color = content[i + 1]; i += 2
+ elif token == KWD_SHAPE:
+ self._shape = content[i + 1]; i += 2
+ else:
+ try:
+ gap = float(token)
+ self._gap = gap
+ except:
+ # assume just string in keys array is shape name
+ self._shape = token
+
+class _Outline:
+ def __init__(self, name, content):
+ self._name = name
+ self._content = content
+
+class _Solid:
+ def __init__(self, name, content):
+ self._name = name
+ self._content = content
+
+class _Logo:
+ def __init__(self, name, content):
+ self._name = name
+ self._content = content
+
+class _Indicator:
+ def __init__(self, name, content):
+ self._name = name
+ self._content = content
+
+class _Text:
+ def __init__(self, name, content):
+ self._name = name
+ self._content = content
+
+class _Overlay:
+ def __init__(self, name, content):
+ self._name = name
+ self._content = content
+
+if __name__ == "__main__":
+ dir = "/usr/share/X11/xkb"
+ geometry_dict = GeometryParser(dir).get_components()
+
+
View
2  setup/xkbc/xkb_keycodes.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
2  setup/xkbc/xkb_keymap.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
2  setup/xkbc/xkb_rules.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
2  setup/xkbc/xkb_symbols.py
@@ -2,7 +2,7 @@
#
# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
#
-# Copyright (c) 2009-2010 Sun Microsystems, Inc All Rights Reserved.
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
#
# 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
View
BIN  setup/xkbc/xkbc.dat
Binary file not shown
View
49 vkb/Makefile.am
@@ -0,0 +1,49 @@
+# vim:set noet ts=4:
+#
+# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
+#
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
+#
+# 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+vkb_xkbc_PYTHON = \
+ vkb.py \
+ vkb_canvas.py \
+ vkb_color.py \
+ vkb_config.py \
+ vkb_constants.py \
+ vkb_key.py \
+ vkb_keymodel.py \
+ vkb_signal.py \
+ vkb_window.py \
+ $(NULL)
+
+vkb_xkbcdir = $(datadir)/ibus-xkbc/vkb
+
+libexec_SCRIPTS = ibus-kbd-xkbc
+
+CLEANFILES = \
+ *.py \
+ *.pyc \
+ *.pyo \
+ $(NULL)
+
+EXTRA_DIST = \
+ ibus-kbd-xkbc.in \
+ $(NULL)
+
+# test:
+# $(ENV) LANG=en_US PYTHONPATH=$(top_srcdir) $(PYTHON) $(srcdir)/main.py
+#
View
69 vkb/geometry/vkb
@@ -0,0 +1,69 @@
+// Virtual Keyboard default simple geometry (subset of pc101)
+//
+
+default xkb_geometry "simple" {
+
+ description= "IBus Virtual Keyboard default";
+ width= 315;
+ height=120;
+
+ shape "NORM" { { [ 18,18] }, { [2,1], [ 16,16] } };
+ shape "BKSP" { { [ 38,18] }, { [2,1], [ 36,16] } };
+ shape "TABK" { { [ 28,18] }, { [2,1], [ 26,16] } };
+ shape "BKSL" { { [ 28,18] }, { [2,1], [ 26,16] } };
+ shape "RTRN" { { [ 42,18] }, { [2,1], [ 40,16] } };
+ shape "CAPS" { { [ 33,18] }, { [2,1], [ 31,16] } };
+ shape "LFSH" { { [ 42,18] }, { [2,1], [ 40,16] } };
+ shape "RTSH" { { [ 52,18] }, { [2,1], [ 50,16] } };
+ shape "MODK" { { [ 27,18] }, { [2,1], [ 25,16] } };
+ shape "SPCE" { { [133,18] }, { [2,1], [131,16] } };
+
+ section.left= 15;
+
+ section "Alpha" {
+ top= 15;
+ row {
+ top= 1;
+ keys { <TLDE>, <AE01>, <AE02>, <AE03>, <AE04>,
+ <AE05>, <AE06>, <AE07>, <AE08>, <AE09>,
+ <AE10>, <AE11>, <AE12>,
+ { <BKSP>, "BKSP", color="grey20" }
+ };
+ };
+ row {
+ top= 20;
+ keys { { <TAB>, "TABK", color="grey20" },
+ <AD01>, <AD02>, <AD03>, <AD04>, <AD05>,
+ <AD06>, <AD07>, <AD08>, <AD09>, <AD10>,
+ <AD11>, <AD12>, { <BKSL>, "BKSL" }
+ };
+ };
+ row {
+ top= 39;
+ keys { { <CAPS>, "CAPS", color="grey20" },
+ <AC01>, <AC02>, <AC03>, <AC04>, <AC05>,
+ <AC06>, <AC07>, <AC08>, <AC09>, <AC10>,
+ <AC11>, { <RTRN>, "RTRN", color="grey20" }
+ };
+ };
+ row {
+ top= 58;
+ keys { { <LFSH>, "LFSH", color="grey20" },
+ <AB01>, <AB02>, <AB03>, <AB04>, <AB05>,
+ <AB06>, <AB07>, <AB08>, <AB09>, <AB10>,
+ { <RTSH>, "RTSH", color="grey20" }
+ };
+ };
+ row {
+ top= 77;
+ key.shape= "MODK";
+ key.color= "grey20";
+ keys { <LCTL>, { <LALT>, 21 },
+ { <SPCE>, "SPCE", color="white" },
+ <RALT>, { <RCTL>, 21 }
+ };
+ };
+
+ }; // End of "Alpha" section
+
+};
View
26 vkb/ibus-kbd-xkbc.in
@@ -0,0 +1,26 @@
+#!/bin/bash
+# vim:set noet ts=4:
+#
+# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
+#
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
+#
+# 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+export LIBEXECDIR=@prefix@/lib/ibus
+export XKB_DATA_DIR=@prefix@/share/X11/xkb
+export XKBC_SETUPDIR=@prefix@/share/ibus-xkbc/setup
+export XKBC_LIBDIR=@prefix@/share/ibus-xkbc/setup/xkbc
+export XKBC_DATAFILE=@prefix@/share/ibus-xkbc/data/xkbc.dat
+exec python @prefix@/share/ibus-xkbc/vkb/vkb.py $@
View
92 vkb/vkb.py
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+# vim:set et sts=4 sw=4:
+#
+# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
+#
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
+#
+# 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import os
+import sys
+import getopt
+import gtk
+
+x = [os.getenv('XKBC_LIBDIR'), os.getenv('XKBC_SETUPDIR')]
+sys.path = x + sys.path
+
+from prefs import *
+from vkb_canvas import *
+from vkb_window import *
+from vkb_config import *
+
+#----------------------------------------------------------
+def print_help(out, v=0):
+ print >> out, "-i", "# for reset option (x, y, scale, transparency etc...)"
+ print >> out, "-h", "# for print this message"
+ sys.exit(v)
+
+def main():
+
+ shortopt = "ih"
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], shortopt)
+ except:
+ print_help(sys.stderr, 1)
+
+ for o, a in opts:
+ if o == "-i":
+ # reset VKBConfig
+ vkb_config_reset()
+ elif o == "-h":
+ print_help(sys.stderr, 0)
+ else:
+ print_help(sys.stderr, 1)
+
+ xkbcdb = prefs_get_xkbc_db()
+
+ window = VKBWindow()
+ window.set_title("Virtual Keyboard")
+ vkb = VKBCanvas(window, xkbcdb)
+ window.set_canvas(vkb)
+ window.set_default_size(int(vkb.get_width()), int(vkb.get_height()))
+ window.connect("destroy", finalize_vkb)
+ if vkb_config_get_x() > -99:
+ window.move(vkb_config_get_x(), vkb_config_get_y())
+ window.show_all()
+
+ try:
+ gtk.main()
+ except:
+ sys.exit(1)
+
+def finalize_vkb(window):
+ # store x, y, x_scale, y_scale
+
+ x, y = window.get_position()
+ xs, ys = window.get_scale()
+ vkb_config_set_x(x)
+ vkb_config_set_y(y)
+ vkb_config_set_x_scale(xs)
+ vkb_config_set_y_scale(ys)
+
+ gtk.main_quit()
+
+def get_user_layouts():
+ return prefs_get_user_layouts()
+
+if __name__ == "__main__":
+ main()
+
View
504 vkb/vkb_canvas.py
@@ -0,0 +1,504 @@
+# vim:set et sts=4 sw=4:
+#
+# ibus-xkbc - The Input Bus Keyboard Layout emulaton engine.
+#
+# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved.
+#
+# 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import gtk
+import cairo
+import os
+
+from vkb import *
+from vkb_key import *
+from vkb_keymodel import *
+from vkb_config import *
+
+class VKBCanvas(gtk.DrawingArea):
+
+ def set_state(self, state):
+ if self._state & state:
+ self._state ^= state
+ else:
+ self._state |= state
+
+ def get_state(self):
+ return self._state
+
+ def get_width(self):
+ return self._scale_factor_x * (self._kbd_width + self._x_gap * 2)
+
+ def get_height(self):
+ return self._scale_factor_y * (self._kbd_height + self._y_gap * 2)
+
+ def get_geometry(self):
+ return self._geom
+
+ def get_scale(self):
+ return (self._scale_factor_x, self._scale_factor_y)
+
+ def get_colors(self):
+ return (self._outer_color, self._inner_color, self._text_color,
+ self._text_color_r, self._inactive_text_color)
+
+ def __init__(self, parent, xkbcdb):
+ gtk.DrawingArea.__init__(self)
+
+ self._parent = parent
+ self._x_gap = 3
+ self._y_gap = 3
+ self._xkbcdb = xkbcdb
+ self._context = None
+ self._context_menu = None
+ self._key_object_list = None
+ self._target_key = None
+ self._state = 0
+
+ self._scale_factor_x = vkb_config_get_x_scale()
+ self._scale_factor_y = vkb_config_get_y_scale()
+ self._geometry_name = vkb_config_get_geometry()
+ self._layout_name = vkb_config_get_layout()
+ self._surface_style = vkb_config_get_surface_style()
+ self._transparency = vkb_config_get_transparency()
+ self._window_keep_below = vkb_config_get_window_keep_below()
+ self._label_style = vkb_config_get_label_style()
+ if vkb_config_get_window_style() == VKB_NORMAL_WINDOW:
+ self._window_style = VKB_NORMAL_WINDOW
+ self._decoration_type = VKB_DECORATION_TITLE
+ self._frame_draw = True
+ else:
+ self._window_style = VKB_KEYS_ONLY_WINDOW
+ self._decoration_type = VKB_DECORATION_NONE
+ self._frame_draw = False
+
+ self._setup_geom_data()
+ self._set_colors()
+ self._move_pos = None
+
+ self.add_events(self.EVENT_MASK)
+ self.connect("expose-event", self._expose)
+ self.connect("configure-event", self._configure)
+ self.connect("button-press-event", self._button_press)
+ self.connect("motion-notify-event", self._button_motion)
+ self.connect("button-release-event", self._button_release)
+ self.connect("style-set", self._style_set)
+
+ def _setup_geom_data(self):
+ self._geom = self._xkbcdb.get_geometry_dict()[self._geometry_name]
+ self._kbd_width = self._geom.get_width()
+ self._kbd_height = self._geom.get_height()
+
+ def _color_adjust(self, color):
+ rc = []
+ for i in (color.red, color.green, color.blue):
+ rc.append(float(i) / 0xffff)
+ return rc
+
+ def _set_colors(self):
+ style = self.get_style()
+ self._outer_color = self._color_adjust(style.bg[gtk.STATE_SELECTED])
+ self._inner_color = self._color_adjust(style.bg[gtk.STATE_NORMAL])
+ self._text_color = self._color_adjust(style.text[gtk.STATE_NORMAL])
+ self._text_color_r = self._color_adjust(style.text[gtk.STATE_SELECTED])
+ self._inactive_text_color = self._color_adjust(style.text[gtk.STATE_INSENSITIVE])
+
+ def _style_set(self, widget, prev_style):
+ self._set_colors()
+ return False
+
+ def _repaint(self):
+ self._expose(self, None)
+
+ def _reshape_window(self):
+ ctx = self.window.cairo_create()
+ ctx.set_source_rgb(self._inner_color[0],
+ self._inner_color[1],
+ self._inner_color[2])
+ w = self.get_width()
+ h = self.get_height()
+ ctx.rectangle(0, 0, w, h)
+ ctx.scale(self._scale_factor_x, self._scale_factor_y)
+ ctx.fill()
+ self._parent.resize(int(self.get_width()), int(self.get_height()))
+
+ def _expose(self, widget, event):
+ self.parent.set_opacity(self._transparency)
+ self.parent.set_keep_below(self._window_keep_below)
+ self._context = ctx = widget.window.cairo_create()
+ w = self.get_width()
+ h = self.get_height()
+ ctx.rectangle(0, 0, w, h)
+ ctx.scale(self._scale_factor_x, self._scale_factor_y)
+ ctx.clip()
+ self._draw(ctx)
+
+ return False
+
+ def draw_keys(self, ctx):
+ ctx.scale(self._scale_factor_x, self._scale_factor_y)
+ self._draw(ctx)
+
+ def fill_kbd(self, ctx):
+ w = self.get_width()
+ h = self.get_height()
+ ctx.rectangle(0, 0, w, h)
+ ctx.scale(self._scale_factor_x, self._scale_factor_y)
+ ctx.fill()
+
+ def _configure(self, widget, event):
+ w = self.get_width()
+ h = self.get_height()
+ self._scale_factor_x *= event.width / w
+ self._scale_factor_y *= event.height / h
+
+ return False
+
+ def _set_layout_name(self, item, layout_name):
+ self._layout_name = layout_name
+ vkb_config_set_layout(layout_name)
+ self._reset_layouts()
+ self._repaint()
+
+ def _set_geometry_name(self, item, geometry_name):
+ self._geometry_name = geometry_name
+ vkb_config_set_geometry(geometry_name)
+ self._setup_geom_data()
+ self._reshape_window()
+ self._reset_layouts()
+ self._repaint()
+
+ def _reset_layouts(self):
+ self._key_object_list = None
+ self._target_key = None
+ self._state = 0
+
+ def get_label_style(self):
+ return self._label_style
+
+ # "Active label only" context menu item callback
+ def _set_label_style(self, item):
+ self._label_style = VKB_ACTIVE_TEXT if item.get_active() else VKB_ALL_TEXT
+ vkb_config_set_label_style(self._label_style)
+ self._repaint()
+
+ # "Gradation surface" context menu item callback
+ def _set_surface_style(self, item):
+ self._surface_style = VKB_GRADIENT if item.get_active() else VKB_SOLID
+ vkb_config_set_surface_style(self._surface_style)
+ self._repaint()
+
+ def get_surface_style(self):
+ return self._surface_style
+
+ # "Keys only window" context menu item callback
+ def _set_window_style(self, item):
+ if item.get_active():
+ self._frame_draw = False
+ self._parent.set_decorated(self._frame_draw)
+ self._parent.set_keys_only(True)
+ self._window_style = VKB_KEYS_ONLY_WINDOW
+ else:
+ self._frame_draw = True
+ self._parent.set_decorated(self._frame_draw)
+ self._parent.set_keys_only(False)
+ self._window_style = VKB_NORMAL_WINDOW
+
+ vkb_config_set_window_style(self._window_style)
+ w, h = self._parent.get_size()
+ self._parent.resize(w, h)
+
+ # "Always below other window" context menu callback
+ def _set_window_keep_below(self, item):
+ if item.get_active():
+ self._window_keep_below = True
+ else:
+ self._window_keep_below = False
+ self.parent.set_keep_below(self._window_keep_below)
+ vkb_config_set_window_keep_below(self._window_keep_below)
+
+ # "Layout Config" context menu callback
+ def _layout_list_setup(self, item):
+ setup_cmd = os.path.join(os.getenv('LIBEXECDIR'), "ibus-setup-xkbc")
+ os.spawnv(os.P_NOWAIT, setup_cmd, ("ibus-setup-xkbc", "-k"))
+
+ # "Transparency" context menu callback
+ def _set_transparency(self, item, val):
+ self._transparency = val
+ vkb_config_set_transparency(self._transparency)
+ self.parent.set_opacity(self._transparency)
+
+ # "Exit" context menu callback
+ def _exit(self, item):
+ finalize_vkb(self._parent)
+
+ def _setup_menu_item(self, parent, label, cb, data=None, select= False, radio=False, group=None):
+
+ item = None
+ if radio:
+ item = gtk.RadioMenuItem(group, label)
+ else:
+ item = gtk.MenuItem(label)
+
+ item.set_active(select)
+ item.connect("activate", cb, data)
+ item.show()