Permalink
Browse files

Updated for ibus 1.5.

  • Loading branch information...
1 parent 4952260 commit 05d426bc9b113ebb89684fca676825a7b4ad9f6d @fujiwarat committed May 16, 2012
Showing with 8,118 additions and 797 deletions.
  1. +3 −3 Makefile.am
  2. +109 −65 configure.ac
  3. +2 −2 data/Makefile.am
  4. +104 −0 engine/Makefile.am
  5. +119 −0 engine/gensimple.py
  6. +69 −0 engine/main.vala
  7. +540 −0 engine/xkb.xml.in.in
  8. +14 −9 ibus-xkb.spec.in
  9. +2 −2 ibus/Makefile.am
  10. +2 −2 ibus/__init__.py
  11. BIN ibus/__init__.pyc
  12. +2 −2 ibus/_config.py.in
  13. +2 −2 ibus/xkblayout.py.in
  14. +2 −2 ibus/xkbxml.py.in
  15. +7 −0 po/POTFILES.in
  16. +2 −2 po/ja.po
  17. +27 −5 setup/Makefile.am
  18. +115 −0 setup/engineabout.py
  19. +64 −51 setup/enginecombobox.py
  20. +96 −80 setup/enginetreeview.py
  21. +0 −35 setup/i18n.py
  22. +1 −0 setup/i18n.py
  23. +9 −0 setup/ibus-setup-xkb.desktop.in
  24. +7 −5 setup/ibus-setup-xkb.in
  25. +18 −10 setup/icon.py
  26. +323 −0 setup/keyboardshortcut.py
  27. +482 −41 setup/main.py
  28. +739 −444 setup/setup.ui
  29. +2 −2 setup/xkbsetup.py
  30. +8 −7 src/Makefile.am
  31. +30 −5 src/ibusxkbxml.c
  32. +14 −3 src/ibusxkbxml.h
  33. +32 −0 ui/Makefile.am
  34. +75 −0 ui/gtk2/Makefile.am
  35. +525 −0 ui/gtk2/candidatepanel.py
  36. +102 −0 ui/gtk2/engineabout.py
  37. +12 −0 ui/gtk2/gtkpanel.xml.in.in
  38. +122 −0 ui/gtk2/handle.py
  39. +36 −0 ui/gtk2/i18n.py
  40. +32 −0 ui/gtk2/ibus-ui-gtk.in
  41. +49 −0 ui/gtk2/icon.py
  42. +412 −0 ui/gtk2/languagebar.py
  43. +133 −0 ui/gtk2/main.py
  44. +279 −0 ui/gtk2/menu.py
  45. +126 −0 ui/gtk2/notifications.py
  46. +549 −0 ui/gtk2/panel.py
  47. +64 −0 ui/gtk2/propitem.py
  48. +182 −0 ui/gtk2/toolitem.py
  49. +117 −0 ui/gtk3/Makefile.am
  50. +144 −0 ui/gtk3/application.vala
  51. +246 −0 ui/gtk3/candidatearea.vala
  52. +272 −0 ui/gtk3/candidatepanel.vala
  53. +106 −0 ui/gtk3/grabkeycode.c
  54. +12 −0 ui/gtk3/gtkxkbpanel.xml.in.in
  55. +165 −0 ui/gtk3/handle.vala
  56. +57 −0 ui/gtk3/iconwidget.vala
  57. +244 −0 ui/gtk3/keybindingmanager.vala
  58. +499 −0 ui/gtk3/panel.vala
  59. +85 −0 ui/gtk3/pango.vala
  60. +202 −0 ui/gtk3/property.vala
  61. +40 −0 ui/gtk3/separator.vala
  62. +268 −0 ui/gtk3/switcher.vala
  63. +2 −2 xkb/Makefile.am
  64. +2 −2 xkb/ibus-engine-xkb-main.c
  65. +3 −4 xkb/ibus-engine-xkb-main.h
  66. +2 −2 xkb/ibus-xkb-main.c
  67. +2 −2 xkb/xkblib.c
  68. +2 −2 xkb/xkblib.h
  69. +2 −2 xkb/xkbxml.c
  70. +2 −2 xkb/xkbxml.h
View
6 Makefile.am
@@ -2,8 +2,8 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (C) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (C) 2011-2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2011-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -20,7 +20,7 @@
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
-SUBDIRS = data ibus setup src xkb po
+SUBDIRS = src engine ui setup po
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = ibus-xkb.pc
View
174 configure.ac
@@ -2,8 +2,8 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2011-2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2011-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -26,22 +26,29 @@ AC_CONFIG_HEADERS([config.h])
# if not 1, append datestamp to the version number.
m4_define([ibus_released], [0])
m4_define([ibus_major_version], [1])
-m4_define([ibus_minor_version], [3])
+m4_define([ibus_minor_version], [4])
m4_define([ibus_micro_version], [99])
+m4_define([ibus_abi_current], [5])
+m4_define([ibus_abi_revision],
+ [m4_eval(100 * ibus_minor_version + ibus_micro_version)])
+m4_define([ibus_abi_age], [0])
m4_define(ibus_maybe_datestamp,
m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
-m4_define([ibus_version],
+m4_define([ibus_xkb_version],
ibus_major_version.ibus_minor_version.ibus_micro_version[]ibus_maybe_datestamp)
# This is the X.Y used in -libus-X.Y
-m4_define([ibus_xkb_api_version], [1.0])
-
+m4_define([ibus_xkb_api_version], [ibus_major_version.0])
+m4_define([ibus_abi_current_minus_age],
+ [m4_eval(ibus_abi_current - ibus_abi_age)])
+m4_define([ibus_xkb_binary_version],
+ [ibus_major_version.ibus_abi_current_minus_age.ibus_abi_age.ibus_abi_revision])
# Required versions of other packages
-m4_define([ibus_required_version], [1.3.0])
+m4_define([ibus_required_version], [1.4.99])
m4_define([glib_required_version], [2.26.0])
-AC_INIT([ibus-xkb], [ibus_version],
+AC_INIT([ibus-xkb], [ibus_xkb_version],
[http://code.google.com/p/ibus/issues/entry],
[ibus-xkb])
@@ -57,18 +64,30 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
IBUS_XKB_MAJOR_VERSION=ibus_major_version
IBUS_XKB_MINOR_VERSION=ibus_minor_version
IBUS_XKB_MICRO_VERSION=ibus_micro_version
+IBUS_XKB_ABI_CURRENT=ibus_abi_current
+IBUS_XKB_ABI_REVISION=ibus_abi_revision
+IBUS_XKB_ABI_AGE=ibus_abi_age
+IBUS_XKB_VERSION=ibus_xkb_version
IBUS_XKB_API_VERSION=ibus_xkb_api_version
+IBUS_XKB_BINARY_VERSION=ibus_xkb_binary_version
+
AC_SUBST(IBUS_XKB_MAJOR_VERSION)
AC_SUBST(IBUS_XKB_MINOR_VERSION)
AC_SUBST(IBUS_XKB_MICRO_VERSION)
+AC_SUBST(IBUS_XKB_ABI_CURRENT)
+AC_SUBST(IBUS_XKB_ABI_REVISION)
+AC_SUBST(IBUS_XKB_ABI_AGE)
+AC_SUBST(IBUS_XKB_VERSION)
AC_SUBST(IBUS_XKB_API_VERSION)
+AC_SUBST(IBUS_XKB_BINARY_VERSION)
# Check for programs
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CC_STDC
+AM_PROG_VALAC([0.14])
AC_PROG_INSTALL
-AC_PROG_CXX
+AC_PROG_MAKE_SET
# define PACKAGE_VERSION_* variables
AM_DISABLE_STATIC
@@ -83,12 +102,17 @@ m4_define(ibus_datedisplay,
DATE_DISPLAY="ibus_datedisplay"
AC_SUBST(DATE_DISPLAY)
-# If only source code changed, lt_revision + 1
-# If any interface added, lt_age + 1
-# If any interfaces changed or removed, lt_current + 1, lt_revision = 0, lt_age = 0
-m4_define([lt_current], [0])
-m4_define([lt_revision], [0])
-m4_define([lt_age], [0])
+# libtool versioning
+#
+# If LT_VERSION_INFO="lt_current:lt_revision:lt_age", libibus is
+# libibus-ibus_api_version.so.(lt_current - lt_age).lt_age.lt_revision
+# If the abi is changed, but it is compatible with last version,
+# ibus_abi_current++, ibus_abi_age++;
+# If the abi is not compatible with last version,
+# ibus_abi_current++, ibus_abi_age = 0;
+m4_define([lt_current], [ibus_abi_current])
+m4_define([lt_revision], [ibus_abi_revision])
+m4_define([lt_age], [ibus_abi_age])
LT_VERSION_INFO="lt_current:lt_revision:lt_age"
AC_SUBST(LT_VERSION_INFO)
@@ -97,14 +121,45 @@ PKG_CHECK_MODULES(IBUS, [
ibus-1.0 >= ibus_required_version
])
-# check glib2
+# Check glib2
AM_PATH_GLIB_2_0
PKG_CHECK_MODULES(GLIB2, [
glib-2.0 >= glib_required_version
])
PKG_CHECK_MODULES(GOBJECT2, [
gobject-2.0 >= glib_required_version
])
+PKG_CHECK_MODULES(GIO2, [
+ gio-2.0 >= glib_required_version
+])
+PKG_CHECK_MODULES(GTHREAD2, [
+ gthread-2.0 >= glib_required_version
+])
+
+# --disable-gtk3 option.
+AC_ARG_ENABLE(gtk3,
+ AS_HELP_STRING([--disable-gtk3],
+ [Do not build gtk3 im module]),
+ [enable_gtk3=$enableval],
+ [enable_gtk3=yes]
+)
+AM_CONDITIONAL([ENABLE_GTK3], [test x"$enable_gtk3" = x"yes"])
+
+if test x"$enable_gtk3" = x"yes"; then
+ # check for gtk3, gdk3
+ PKG_CHECK_MODULES(GTK3, [
+ gtk+-3.0
+ ])
+
+ PKG_CHECK_MODULES(GDK3, [
+ gdk-3.0
+ ])
+else
+ enable_gtk3="no (disabled, use --enable-gtk3 to enable)"
+fi
+
+# For source compatibility with ibus patch.
+AM_CONDITIONAL([ENABLE_XKB], [1])
# Check for x11
PKG_CHECK_MODULES(X11, [
@@ -117,7 +172,35 @@ PKG_CHECK_MODULES(XKB,
[XKB_LIBS="-lxkbfile"]
)
-# define XKB rules file
+# For source compatibility with ibus patch.
+AC_DEFINE(HAVE_XKB, 1, [define to 1 if you have xkbfile])
+HAVE_IBUS_XKB=true
+AC_SUBST(HAVE_IBUS_XKB)
+
+# --enable-libgnomekbd option.
+AC_ARG_ENABLE(libgnomekbd,
+ AS_HELP_STRING([--enable-libgnomekbd],
+ [Use libgnomekbd to handle the keymaps]),
+ [enable_libgnomekbd=$enableval],
+ [enable_libgnomekbd=no]
+)
+AM_CONDITIONAL([ENABLE_LIBGNOMEKBD], [test x"$enable_libgnomekbd" = x"yes"])
+if test x"$enable_libgnomekbd" = x"yes"; then
+ # check for libgnomekbd
+ PKG_CHECK_MODULES(LIBGNOMEKBDUI, [
+ libgnomekbdui
+ ])
+ PKG_CHECK_MODULES(ATK, [
+ atk
+ ])
+ HAVE_IBUS_GKBD=true
+else
+ enable_libgnomekbd="no (disabled, use --enable-libgnomekbd to enable)"
+ HAVE_IBUS_GKBD=false
+fi
+AC_SUBST(HAVE_IBUS_GKBD)
+
+# Define XKB rules file
AC_ARG_WITH(xkb-rules-xml,
AS_HELP_STRING([--with-xkb-rules-xml[=$DIR/evdev.xml]],
[Set evdev.xml file path (default: /usr/share/X11/xkb/rules/evdev.xml)]),
@@ -228,45 +311,6 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
AM_GLIB_GNU_GETTEXT
-# option for setup gui
-AC_ARG_ENABLE(setup-gui,
- AS_HELP_STRING([--enable-setup-gui],
- [Enable Setup GUI]),
- [enable_setup_gui=$enableval],
- [enable_setup_gui=yes]
-)
-
-if test x"$enable_setup_gui" = x"yes"; then
- AC_DEFINE(ENABLE_SETUP_GUI, 1, [Define to 1 if you enable Setup GUI.])
-else
- enable_setup_gui="no (disabled, use --enable-setup-gui to enable)"
-fi
-
-# option for bridge hotkey
-AC_ARG_ENABLE(bridge-hotkey,
- AS_HELP_STRING([--enable-bridge-hotkey],
- [Enable bridge hotkey instead of ON/OFF hotkey]),
- [enable_bridge_hotkey=$enableval],
- [enable_bridge_hotkey=no]
-)
-
-if test x"$enable_bridge_hotkey" = x"yes"; then
- USE_BRIDGE_HOTKEY=1
-else
- USE_BRIDGE_HOTKEY=0
- enable_bridge_hotkey="no (disabled, use --enable-bridge-hotkey to enable)"
-fi
-AC_SUBST(USE_BRIDGE_HOTKEY)
-
-# define default bridge engine name
-AC_ARG_WITH(bridge-engine,
- AS_HELP_STRING([--with-bridge-engine[=bridge_engine_name]],
- [Set bridge engine name in IM bridge hotkey. (default: xkb:layout:default:)]),
- [DEFAULT_BRIDGE_ENGINE_NAME=$with_bridge_engine],
- [DEFAULT_BRIDGE_ENGINE_NAME="xkb:layout:default:"]
-)
-AC_SUBST(DEFAULT_BRIDGE_ENGINE_NAME)
-
# check iso-codes
PKG_CHECK_MODULES(ISOCODES, [
iso-codes
@@ -279,25 +323,25 @@ AC_CONFIG_FILES([ po/Makefile.in
Makefile
ibus-xkb.pc
ibus-xkb.spec
-data/Makefile
-ibus/Makefile
-ibus/_config.py
-src/Makefile
+engine/Makefile
+engine/xkb.xml.in
setup/Makefile
setup/ibus-setup-xkb
-xkb/Makefile
+src/Makefile
+ui/Makefile
+ui/gtk3/Makefile
+ui/gtk3/gtkxkbpanel.xml.in
])
AC_OUTPUT
AC_MSG_RESULT([
Build options:
- Version $VERSION
+ Version $IBUS_XKB_VERSION
Install prefix $prefix
+ Build ui gtk3 $enable_gtk3
Build gconf modules $enable_gconf
Build python modules $enable_python
Build introspection $found_introspection
IBus-1.0.gir scannerflags "$IBUS_GIR_SCANNERFLAGS"
- Enable Setup GUI $enable_setup_gui
- Enable bridge hotkey $enable_bridge_hotkey
- Default bridge engine $DEFAULT_BRIDGE_ENGINE_NAME
+ Build libgnomebkd $enable_libgnomekbd
])
View
4 data/Makefile.am
@@ -2,9 +2,9 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2011-2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
# Copyright (c) 2011 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2011-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
View
104 engine/Makefile.am
@@ -0,0 +1,104 @@
+# vim:set noet ts=4:
+#
+# ibus-xkb - IBus XKB
+#
+# Copyright (c) 2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2012 Red Hat, Inc.
+# Copyright (c) 2010, Google Inc. All rights reserved.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA
+
+libibus_xkb = $(top_builddir)/src/libibus-xkb-common.la
+
+INCLUDES = \
+ -I$(top_srcdir)/src \
+ -I$(top_builddir)/src \
+ $(NULL)
+
+AM_CFLAGS = \
+ @GLIB2_CFLAGS@ \
+ @GIO2_CFLAGS@ \
+ @GTHREAD2_CFLAGS@ \
+ @IBUS_CFLAGS@ \
+ $(INCLUDES) \
+ -DG_LOG_DOMAIN=\"IBUS\" \
+ -DPKGDATADIR=\"$(pkgdatadir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DBINDIR=\"@bindir@\" \
+ -DIBUS_DISABLE_DEPRECATED \
+ -Wno-unused-variable \
+ -Wno-unused-but-set-variable \
+ -Wno-unused-function \
+ $(NULL)
+
+AM_LDADD = \
+ @GOBJECT2_LIBS@ \
+ @GLIB2_LIBS@ \
+ @GIO2_LIBS@ \
+ @GTHREAD2_LIBS@ \
+ @IBUS_LIBS@ \
+ $(libibus_xkb) \
+ $(NULL)
+
+AM_VALAFLAGS = \
+ --vapidir=$(top_builddir)/bindings/vala \
+ --pkg=ibus-1.0 \
+ $(NULL)
+
+libexec_PROGRAMS = \
+ ibus-engine-xkb \
+ $(NULL)
+
+ibus_engine_xkb_SOURCES = \
+ main.vala \
+ $(NULL)
+ibus_engine_xkb_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(NULL)
+ibus_engine_xkb_LDADD = \
+ $(AM_LDADD) \
+ $(NULL)
+ibus_engine_xkb_DEPENDENCIES = \
+ $(libibus_xkb) \
+ $(NULL)
+
+component_DATA = \
+ xkb.xml \
+ $(NULL)
+
+componentdir = $(datadir)/ibus/component
+
+CLEANFILES = \
+ xkb.xml \
+ $(NULL)
+
+EXTRA_DIST = \
+ xkb.xml.in.in \
+ $(NULL)
+
+xkb.xml: xkb.xml.in
+ $(AM_V_GEN) \
+ ( \
+ libexecdir=${libexecdir}; \
+ s=`cat $<`; \
+ eval "echo \"$${s}\""; \
+ ) > $@
+
+$(libibus_xkb):
+ $(MAKE) -C $(top_builddir)/src
+
+-include $(top_srcdir)/git.mk
View
119 engine/gensimple.py
@@ -0,0 +1,119 @@
+# vim:set et sts=4 sw=4:
+#
+# ibus-xkb - IBus XKB
+#
+# Copyright (c) 2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2012 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA
+
+import cgi
+import urllib2
+from xml.dom import minidom
+
+def simplfy_dom(node):
+ name = node.nodeName
+ children = {}
+ if len(node.childNodes) == 1 and node.childNodes[0].nodeType == node.TEXT_NODE:
+ return name, node.childNodes[0].nodeValue
+ for child in node.childNodes:
+ if child.nodeType != node.ELEMENT_NODE:
+ continue
+ child_name, child_value = simplfy_dom(child)
+ if child_name not in children:
+ children[child_name] = []
+ children[child_name].append(child_value)
+ return name, children
+
+def parse_xml():
+ filename = "/usr/share/X11/xkb/rules/evdev.xml"
+ dom = minidom.parse(file(filename))
+ name, root = simplfy_dom(dom)
+
+ layouts = root['xkbConfigRegistry'][0]['layoutList'][0]['layout']
+ for layout in layouts:
+ config = layout['configItem'][0]
+ name = config['name'][0]
+ short_desc = config.get('shortDescription', [''])[0]
+ desc = config.get('description', [''])[0]
+ languages = config.get('languageList', [{}])[0].get('iso639Id', [])
+ variants = layout.get('variantList', [{}])[0].get('variant', [])
+ yield name, '', short_desc, desc, languages
+ for variant in variants:
+ variant_config = variant['configItem'][0]
+ variant_name = variant_config['name'][0]
+ variant_short_desc = variant_config.get('shortDescription', [''])[0]
+ variant_desc = variant_config.get('description', [''])[0]
+ variant_languages = variant_config.get('languageList', [{}])[0].get('iso639Id', [])
+ if not isinstance(variant_languages, list):
+ variant_languages = [variant_languages]
+ yield name, variant_name, variant_short_desc, variant_desc, languages + variant_languages
+
+def gen_xml():
+ header = u"""<component>
+ <name>org.freedesktop.IBus.Simple</name>
+ <description>A table based simple engine</description>
+ <exec>${libexecdir}/ibus-engine-simple</exec>
+ <version>@VERSION@</version>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <license>GPL</license>
+ <homepage>http://code.google.com/p/ibus</homepage>
+ <textdomain>ibus</textdomain>
+ <engines>"""
+ engine = u"""\t\t<engine>
+ <name>%s</name>
+ <language>%s</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>%s</layout>
+ <longname>%s</longname>
+ <description>%s</description>
+ <icon>ibus-keyboard</icon>
+ <rank>%d</rank>
+ </engine>"""
+ footer = u"""\t</engines>
+</component>"""
+
+ print header
+
+ whitelist = parse_whitelist()
+ for name, vname, sdesc, desc, languages in parse_xml():
+ layout = "%s(%s)" % (name, vname) if vname else name
+ for lang in languages:
+ ibus_name = "xkb:%s:%s:%s" % (name, vname, lang)
+ if ibus_name not in whitelist:
+ continue
+ desc = cgi.escape(desc)
+ out = engine % (ibus_name, lang, layout, desc, desc, 99)
+ print out.encode("utf8")
+
+ print footer
+
+def parse_whitelist():
+ url = "http://git.chromium.org/gitweb/?p=chromium/chromium.git;a=blob_plain;f=chrome/browser/chromeos/input_method/ibus_input_methods.txt;hb=HEAD"
+ whitelist = []
+ for line in urllib2.urlopen(url):
+ line = line.strip()
+ if not line:
+ continue
+ if line.startswith("#"):
+ continue
+ whitelist.append(line.split()[0])
+ return set(whitelist)
+
+if __name__ == "__main__":
+ gen_xml()
View
69 engine/main.vala
@@ -0,0 +1,69 @@
+/* vim:set et sts=4 sw=4:
+ *
+ * ibus-xkb - IBus XKB
+ *
+ * Copyright(c) 2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+ * Copyright(c) 2011 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (c) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or(at your option) any later version.
+ *
+ * This library 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ */
+
+using IBus;
+
+class DummyEngine : IBus.EngineSimple {
+}
+
+public int main(string[] args) {
+ IBus.init();
+
+ IBus.Bus bus = new IBus.Bus();
+ if (!bus.is_connected()) {
+ warning("ibus-daemon does not exist.");
+ return 1;
+ }
+
+ uint flags =
+ IBus.BusNameFlag.REPLACE_EXISTING |
+ IBus.BusNameFlag.ALLOW_REPLACEMENT;
+ uint retval = bus.request_name("org.freedesktop.IBus.XKB", flags);
+
+ if (retval == 0) {
+ warning("Registry bus name org.freedesktop.IBus.XKB failed!");
+ return 1;
+ }
+
+ bus.disconnected.connect((bus) => {
+ debug("bus disconnected");
+ IBus.quit();
+ });
+
+ IBus.Factory factory = new IBus.Factory(bus.get_connection());
+
+ int id = 0;
+
+ factory.create_engine.connect((factory, name) => {
+ const string path = "/org/freedesktop/IBus/engine/xkb/%d";
+ IBus.Engine engine = new IBus.Engine.with_type(
+ typeof(IBus.EngineSimple), name,
+ path.printf(++id), bus.get_connection());
+ return engine;
+ });
+
+ IBus.main();
+
+ return 0;
+}
View
540 engine/xkb.xml.in.in
@@ -0,0 +1,540 @@
+<component>
+ <name>org.freedesktop.IBus.XKB</name>
+ <description>A table based xkb engine</description>
+ <exec>${libexecdir}/ibus-engine-xkb</exec>
+ <version>@VERSION@</version>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <license>GPL</license>
+ <homepage>http://code.google.com/p/ibus</homepage>
+ <textdomain>ibus</textdomain>
+ <engines>
+ <engine>
+ <name>xkb:us::eng</name>
+ <language>eng</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>us</layout>
+ <longname>English (US)</longname>
+ <description>English (US)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:us:intl:eng</name>
+ <language>eng</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>us(intl)</layout>
+ <longname>English (US, international with dead keys)</longname>
+ <description>English (US, international with dead keys)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:us:colemak:eng</name>
+ <language>eng</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>us(colemak)</layout>
+ <longname>English (Colemak)</longname>
+ <description>English (Colemak)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:us:dvorak:eng</name>
+ <language>eng</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>us(dvorak)</layout>
+ <longname>English (Dvorak)</longname>
+ <description>English (Dvorak)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:us:altgr-intl:eng</name>
+ <language>eng</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>us(altgr-intl)</layout>
+ <longname>English (international AltGr dead keys)</longname>
+ <description>English (international AltGr dead keys)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:us:altgr-intl:eng</name>
+ <language>eng</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>us(altgr-intl)</layout>
+ <longname>English (international AltGr dead keys)</longname>
+ <description>English (international AltGr dead keys)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:be::ger</name>
+ <language>ger</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>be</layout>
+ <longname>Belgian</longname>
+ <description>Belgian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:be::nld</name>
+ <language>nld</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>be</layout>
+ <longname>Belgian</longname>
+ <description>Belgian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:be::fra</name>
+ <language>fra</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>be</layout>
+ <longname>Belgian</longname>
+ <description>Belgian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:br::por</name>
+ <language>por</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>br</layout>
+ <longname>Portuguese (Brazil)</longname>
+ <description>Portuguese (Brazil)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:bg::bul</name>
+ <language>bul</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>bg</layout>
+ <longname>Bulgarian</longname>
+ <description>Bulgarian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:bg:phonetic:bul</name>
+ <language>bul</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>bg(phonetic)</layout>
+ <longname>Bulgarian (traditional phonetic)</longname>
+ <description>Bulgarian (traditional phonetic)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:ca::fra</name>
+ <language>fra</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>ca</layout>
+ <longname>French (Canada)</longname>
+ <description>French (Canada)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:ca:eng:eng</name>
+ <language>eng</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>ca(eng)</layout>
+ <longname>English (Canada)</longname>
+ <description>English (Canada)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:hr::scr</name>
+ <language>scr</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>hr</layout>
+ <longname>Croatian</longname>
+ <description>Croatian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:cz::cze</name>
+ <language>cze</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>cz</layout>
+ <longname>Czech</longname>
+ <description>Czech</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:dk::dan</name>
+ <language>dan</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>dk</layout>
+ <longname>Danish</longname>
+ <description>Danish</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:ee::est</name>
+ <language>est</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>ee</layout>
+ <longname>Estonian</longname>
+ <description>Estonian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:fi::fin</name>
+ <language>fin</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>fi</layout>
+ <longname>Finnish</longname>
+ <description>Finnish</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:fr::fra</name>
+ <language>fra</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>fr</layout>
+ <longname>French</longname>
+ <description>French</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:de::ger</name>
+ <language>ger</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>de</layout>
+ <longname>German</longname>
+ <description>German</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:de:neo:ger</name>
+ <language>ger</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>de(neo)</layout>
+ <longname>German (Neo 2)</longname>
+ <description>German (Neo 2)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:gr::gre</name>
+ <language>gre</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>gr</layout>
+ <longname>Greek</longname>
+ <description>Greek</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:hu::hun</name>
+ <language>hun</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>hu</layout>
+ <longname>Hungarian</longname>
+ <description>Hungarian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:il::heb</name>
+ <language>heb</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>il</layout>
+ <longname>Hebrew</longname>
+ <description>Hebrew</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:it::ita</name>
+ <language>ita</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>it</layout>
+ <longname>Italian</longname>
+ <description>Italian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:jp::jpn</name>
+ <language>jpn</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>jp</layout>
+ <longname>Japanese</longname>
+ <description>Japanese</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:latam::spa</name>
+ <language>spa</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>latam</layout>
+ <longname>Spanish (Latin American)</longname>
+ <description>Spanish (Latin American)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:lt::lit</name>
+ <language>lit</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>lt</layout>
+ <longname>Lithuanian</longname>
+ <description>Lithuanian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:lv:apostrophe:lav</name>
+ <language>lav</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>lv(apostrophe)</layout>
+ <longname>Latvian (apostrophe variant)</longname>
+ <description>Latvian (apostrophe variant)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:pl::pol</name>
+ <language>pol</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>pl</layout>
+ <longname>Polish</longname>
+ <description>Polish</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:pt::por</name>
+ <language>por</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>pt</layout>
+ <longname>Portuguese</longname>
+ <description>Portuguese</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:ro::rum</name>
+ <language>rum</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>ro</layout>
+ <longname>Romanian</longname>
+ <description>Romanian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:ru::rus</name>
+ <language>rus</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>ru</layout>
+ <longname>Russian</longname>
+ <description>Russian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:ru:phonetic:rus</name>
+ <language>rus</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>ru(phonetic)</layout>
+ <longname>Russian (phonetic)</longname>
+ <description>Russian (phonetic)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:rs::srp</name>
+ <language>srp</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>rs</layout>
+ <longname>Serbian</longname>
+ <description>Serbian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:si::slv</name>
+ <language>slv</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>si</layout>
+ <longname>Slovenian</longname>
+ <description>Slovenian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:sk::slo</name>
+ <language>slo</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>sk</layout>
+ <longname>Slovak</longname>
+ <description>Slovak</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:es::spa</name>
+ <language>spa</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>es</layout>
+ <longname>Spanish</longname>
+ <description>Spanish</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:es:cat:cat</name>
+ <language>cat</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>es(cat)</layout>
+ <longname>Catalan (Spain, with middle-dot L)</longname>
+ <description>Catalan (Spain, with middle-dot L)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:se::swe</name>
+ <language>swe</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>se</layout>
+ <longname>Swedish</longname>
+ <description>Swedish</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:ch::ger</name>
+ <language>ger</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>ch</layout>
+ <longname>German (Switzerland)</longname>
+ <description>German (Switzerland)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:ch:fr:fra</name>
+ <language>fra</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>ch(fr)</layout>
+ <longname>French (Switzerland)</longname>
+ <description>French (Switzerland)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:tr::tur</name>
+ <language>tur</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>tr</layout>
+ <longname>Turkish</longname>
+ <description>Turkish</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:ua::ukr</name>
+ <language>ukr</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>ua</layout>
+ <longname>Ukrainian</longname>
+ <description>Ukrainian</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:gb:extd:eng</name>
+ <language>eng</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>gb(extd)</layout>
+ <longname>English (UK, extended WinKeys)</longname>
+ <description>English (UK, extended WinKeys)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:gb:dvorak:eng</name>
+ <language>eng</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>gb(dvorak)</layout>
+ <longname>English (UK, Dvorak)</longname>
+ <description>English (UK, Dvorak)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ <engine>
+ <name>xkb:kr:kr104:kor</name>
+ <language>kor</language>
+ <license>GPL</license>
+ <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+ <layout>kr(kr104)</layout>
+ <longname>Korean (101/104 key compatible)</longname>
+ <description>Korean (101/104 key compatible)</description>
+ <icon>ibus-keyboard</icon>
+ <rank>99</rank>
+ </engine>
+ </engines>
+</component>
View
23 ibus-xkb.spec.in
@@ -1,7 +1,6 @@
-%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
-
%define gconf2_version 2.12.0
%define dbus_python_version 0.83.0
+%define with_dconf 1
Name: ibus-xkb
Version: @PACKAGE_VERSION@
@@ -69,6 +68,7 @@ docs for ibus-xkb.
%build
%configure \
--disable-static \
+ --enable-libgnomekbd \
--enable-introspection
# make -C po update-gmo
@@ -77,28 +77,34 @@ make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
-rm -f $RPM_BUILD_ROOT%{_libdir}/libibus-xkb.la
+rm -f $RPM_BUILD_ROOT%{_libdir}/libibus-xkb-1.0.la
%find_lang %{name}
%clean
rm -rf $RPM_BUILD_ROOT
%post
+%if !%with_dconf
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/ibus-xkb.schemas >& /dev/null || :
+%endif
%pre
+%if !%with_dconf
if [ "$1" -gt 1 ]; then
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-uninstall-rule %{_sysconfdir}/gconf/schemas/ibus-xkb.schemas >& /dev/null || :
fi
+%endif
%preun
+%if !%with_dconf
if [ "$1" -eq 0 ]; then
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-uninstall-rule %{_sysconfdir}/gconf/schemas/ibus-xkb.schemas >& /dev/null || :
fi
+%endif
%post libs -p /sbin/ldconfig
@@ -107,18 +113,17 @@ fi
%files -f %{name}.lang
%defattr(-,root,root,-)
%doc AUTHORS COPYING README
-%{python_sitelib}/ibusxkb
+%{_bindir}/ibus-setup-xkb
+%{_datadir}/applications/*.desktop
+%{_datadir}/ibus/setup-xkb
%{_datadir}/ibus/component/*.xml
-%{_datadir}/ibus/xkb/*.xml
-%{_datadir}/ibus-xkb/*
-%{_libexecdir}/ibus-setup-xkb
%{_libexecdir}/ibus-engine-xkb
+%{_libexecdir}/ibus-xkb-ui-gtk3
%{_libexecdir}/ibus-xkb
-%{_sysconfdir}/gconf/schemas/ibus-xkb.schemas
%files libs
%defattr(-,root,root,-)
-%{_libdir}/libibus-xkb.so.*
+%{_libdir}/libibus-xkb-1.0.so.*
%{_libdir}/girepository-1.0/IBusXKB-1.0.typelib
%files devel
View
4 ibus/Makefile.am
@@ -2,8 +2,8 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2011-2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2011-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
View
4 ibus/__init__.py
@@ -2,8 +2,8 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2011-2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2011-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
View
BIN ibus/__init__.pyc
Binary file not shown.
View
4 ibus/_config.py.in
@@ -2,8 +2,8 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2011-2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2011-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
View
4 ibus/xkblayout.py.in
@@ -2,8 +2,8 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2011-2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2011-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
View
4 ibus/xkbxml.py.in
@@ -2,8 +2,8 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2011-2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2011-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
View
7 po/POTFILES.in
@@ -1,11 +1,18 @@
# Files with translatable strings.
# Please keep this file in alphabetical order.
data/ibus-xkb.schemas.in
+setup/engineabout.py
setup/enginecombobox.py
setup/enginetreeview.py
+setup/ibus-setup-xkb.desktop.in
+setup/keyboardshortcut.py
setup/main.py
setup/setup.ui
setup/xkbsetup.py
+ui/gtk2/candidatepanel.py
+ui/gtk2/engineabout.py
+ui/gtk2/languagebar.py
+ui/gtk2/panel.py
xkb/ibus-engine-xkb-main.c
xkb/ibus-simple-engine.c
xkb/ibus-xkb-main.c
View
4 po/ja.po
@@ -1,8 +1,8 @@
# Japanese translations for ibus-xkb
-# Copyright (C) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (C) 2011-2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
# This file is distributed under the same license as the ibus-xkb package.
#
-# Takao Fujiwara <takao.fujiwara1@gmail.com>, 2011.
+# Takao Fujiwara <takao.fujiwara1@gmail.com>, 2011-2012.
msgid ""
msgstr ""
"Project-Id-Version: ibus-xkb HEAD\n"
View
32 setup/Makefile.am
@@ -2,8 +2,9 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -26,15 +27,21 @@ ibussetup_PYTHON = \
icon.py \
enginecombobox.py \
enginetreeview.py \
- xkbsetup.py \
+ engineabout.py \
+ keyboardshortcut.py \
$(NULL)
ibussetup_DATA = \
setup.ui \
$(NULL)
-libexec_SCRIPTS = ibus-setup-xkb
-ibussetupdir = $(pkgdatadir)/setup
+bin_SCRIPTS = ibus-setup-xkb
+ibussetupdir = $(datadir)/ibus/setup-xkb
+
+desktop_in_files = ibus-setup-xkb.desktop.in
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+desktopdir = $(datadir)/applications
+@INTLTOOL_DESKTOP_RULE@
CLEANFILES = \
*.pyc \
@@ -44,4 +51,19 @@ CLEANFILES = \
EXTRA_DIST = \
ibus-setup-xkb.in \
setup.ui \
+ ibus-setup-xkb.desktop.in \
+ $(NULL)
+
+DISTCLEANFILES = \
+ $(desktop_DATA) \
$(NULL)
+
+test:
+ $(ENV_IBUS_TEST) \
+ PYTHONPATH=$(top_srcdir) \
+ IBUS_PREFIX="@prefix@" \
+ IBUS_LOCALEDIR="@localedir@" \
+ $(PYTHON) \
+ $(srcdir)/main.py
+
+-include $(top_srcdir)/git.mk
View
115 setup/engineabout.py
@@ -0,0 +1,115 @@
+# vim:set et sts=4 sw=4:
+#
+# ibus-xkb - IBus XKB
+#
+# Copyright (c) 2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2012 Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA
+
+from gi.repository import IBus
+from gi.repository import Gdk
+from gi.repository import GdkPixbuf
+from gi.repository import Gtk
+from gi.repository import Pango
+
+from i18n import _, N_
+
+class EngineAbout(Gtk.Dialog):
+ def __init__(self, enginedesc):
+ self.__engine_desc = enginedesc
+ super(EngineAbout, self).__init__(_("About"), None,
+ Gtk.DialogFlags.MODAL,
+ (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
+
+ self.__init_ui()
+
+ def __init_ui(self):
+ self.set_icon_name(Gtk.STOCK_ABOUT)
+ sw = Gtk.ScrolledWindow()
+ sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
+ sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ sw.set_size_request(400, 400)
+ self.__text_view = Gtk.TextView()
+ self.__text_view.set_editable(False)
+ sw.add(self.__text_view)
+ sw.show_all()
+ self.vbox.pack_start(sw, True, True, 0)
+
+ self.__fill_text_view()
+
+ def __fill_text_view(self):
+ text_buffer = self.__text_view.get_buffer()
+ self.__create_tags(text_buffer)
+
+ iter = text_buffer.get_iter_at_offset(0)
+ text_buffer.insert_with_tags_by_name(iter, "\n ",
+ "left_margin_16")
+ text_buffer.insert_pixbuf(iter,
+ self.__load_icon(self.__engine_desc.get_icon()))
+ text_buffer.insert_with_tags_by_name(iter,
+ "\n%s\n" % self.__engine_desc.get_longname(),
+ "heading", "left_margin_16")
+ text_buffer.insert_with_tags_by_name(iter,
+ _("Language: %s\n") % IBus.get_language_name(self.__engine_desc.get_language()),
+ "small", "bold", "left_margin_16")
+ text_buffer.insert_with_tags_by_name(iter,
+ _("Keyboard layout: %s\n") % self.__engine_desc.get_layout(),
+ "small", "bold", "left_margin_16")
+ text_buffer.insert_with_tags_by_name(iter,
+ _("Author: %s\n") % self.__engine_desc.get_author(),
+ "small", "bold", "left_margin_16")
+ text_buffer.insert_with_tags_by_name(iter,
+ _("Description:\n"), "small", "bold", "left_margin_16")
+ text_buffer.insert_with_tags_by_name(iter,
+ self.__engine_desc.get_description(),
+ "wrap_text", "left_margin_32")
+
+
+ def __create_tags(self, text_buffer):
+ text_buffer.create_tag("heading",
+ weight=Pango.Weight.BOLD,
+ size = 16 * Pango.SCALE)
+ text_buffer.create_tag("bold",
+ weight=Pango.Weight.BOLD)
+ text_buffer.create_tag("italic",
+ style=Pango.Style.ITALIC)
+ text_buffer.create_tag("small",
+ scale=0.833333333333) # Pango.SCALE_SMALL ?
+ text_buffer.create_tag("gray_foreground",
+ foreground="dark gray")
+ text_buffer.create_tag("wrap_text",
+ wrap_mode=Gtk.WrapMode.WORD)
+ text_buffer.create_tag("left_margin_16",
+ left_margin=16)
+ text_buffer.create_tag("left_margin_32",
+ left_margin=32)
+
+ def __load_icon(self, icon):
+ try:
+ pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(icon, 48, 48, True)
+ except:
+ theme = Gtk.IconTheme.get_default()
+ icon = theme.lookup_icon("ibus-engine", 48, 0)
+ if icon == None:
+ icon = theme.lookup_icon(Gtk.STOCK_MISSING_IMAGE, 48, 0)
+ pixbuf = icon.load_icon()
+ return pixbuf
+
+if __name__ == "__main__":
+ desc = IBus.EngineDesc()
+ EngineAbout(desc).run()
View
115 setup/enginecombobox.py
@@ -2,9 +2,9 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -21,81 +21,91 @@
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
-import gtk
-import gobject
-import pango
-import ibus
-import ibusxkb
import locale
+
+from gi.repository import GObject
+from gi.repository import Gtk
+from gi.repository import IBus
+from gi.repository import Pango
+
from icon import load_icon
from i18n import _, N_
-class EngineComboBox(gtk.ComboBox):
+class EngineComboBox(Gtk.ComboBox):
__gtype_name__ = 'EngineComboBox'
__gproperties__ = {
'active-engine' : (
- gobject.TYPE_PYOBJECT,
+ object,
'selected engine',
'selected engine',
- gobject.PARAM_READABLE)
+ GObject.ParamFlags.READABLE)
}
def __init__(self):
super(EngineComboBox, self).__init__()
self.connect("notify::active", self.__notify_active_cb)
self.__model = None
- self.__title = _("Select an input method")
- renderer = gtk.CellRendererPixbuf()
+ renderer = Gtk.CellRendererPixbuf()
renderer.set_property("xalign", 0)
renderer.set_property("xpad", 2)
self.pack_start(renderer, False)
- self.set_cell_data_func(renderer, self.__icon_cell_data_cb)
+ self.set_cell_data_func(renderer, self.__icon_cell_data_cb, None)
- renderer = gtk.CellRendererText()
+ renderer = Gtk.CellRendererText()
renderer.set_property("xalign", 0)
renderer.set_property("xpad", 2)
self.pack_start(renderer, True)
- self.set_cell_data_func(renderer, self.__name_cell_data_cb)
+ self.set_cell_data_func(renderer, self.__name_cell_data_cb, None)
def set_engines(self, engines):
- self.__model = gtk.TreeStore(gobject.TYPE_PYOBJECT)
+ self.__model = Gtk.TreeStore(object)
iter1 = self.__model.append(None)
self.__model.set(iter1, 0, 0)
- lang = {}
+ langs = {}
for e in engines:
- if ibusxkb.use_bridge_hotkey() and \
- e.name.startswith(ibusxkb.DEFAULT_BRIDGE_ENGINE_NAME):
- continue
- l = ibus.get_language_name(e.language)
- if l not in lang:
- lang[l] = []
- lang[l].append(e)
-
- keys = lang.keys()
+ print e.get_language()
+ l = IBus.get_language_name(e.get_language())
+ if l == None:
+ l = ""
+ if l not in langs:
+ langs[l] = []
+ langs[l].append(e)
+
+ keys = langs.keys()
keys.sort(locale.strcoll)
+ loc = locale.getlocale()[0]
+ # None on C locale
+ if loc == None:
+ loc = 'en_US'
+ current_lang = IBus.get_language_name(loc)
+ # move current language to the first place
+ if current_lang in keys:
+ keys.remove(current_lang)
+ keys.insert(0, current_lang)
+
#add "Others" to the end of the combo box
- if ibus.get_language_name("Other") in keys:
- keys.remove(ibus.get_language_name("Other"))
- keys += [ibus.get_language_name("Other")]
+ if IBus.get_language_name("Other") in keys:
+ keys.remove(IBus.get_language_name("Other"))
+ keys += [IBus.get_language_name("Other")]
for l in keys:
iter1 = self.__model.append(None)
self.__model.set(iter1, 0, l)
def cmp_engine(a, b):
- if a.rank == b.rank:
- return locale.strcoll(a.longname, b.longname)
- return int(b.rank - a.rank)
- lang[l].sort(cmp_engine)
- for e in lang[l]:
+ if a.get_rank() == b.get_rank():
+ return locale.strcoll(a.get_longname(), b.get_longname())
+ return int(b.get_rank() - a.get_rank())
+ langs[l].sort(cmp_engine)
+ for e in langs[l]:
iter2 = self.__model.append(iter1)
self.__model.set(iter2, 0, e)
self.set_model(self.__model)
self.set_active(0)
- def __icon_cell_data_cb(self, celllayout, renderer, model, iter):
+ def __icon_cell_data_cb(self, celllayout, renderer, model, iter, data):
engine = self.__model.get_value(iter, 0)
if isinstance(engine, str) or isinstance (engine, unicode):
@@ -107,28 +117,30 @@ def __icon_cell_data_cb(self, celllayout, renderer, model, iter):
else:
renderer.set_property("visible", True)
renderer.set_property("sensitive", True)
- pixbuf = load_icon(engine.icon, gtk.ICON_SIZE_LARGE_TOOLBAR)
+ pixbuf = load_icon(engine.get_icon(), Gtk.IconSize.LARGE_TOOLBAR)
if pixbuf == None:
- pixbuf = load_icon("ibus-engine", gtk.ICON_SIZE_LARGE_TOOLBAR)
+ pixbuf = load_icon("ibus-engine", Gtk.IconSize.LARGE_TOOLBAR)
if pixbuf == None:
- pixbuf = load_icon("gtk-missing-image", gtk.ICON_SIZE_LARGE_TOOLBAR)
+ pixbuf = load_icon(Gtk.STOCK_MISSING_IMAGE,
+ Gtk.IconSize.LARGE_TOOLBAR)
renderer.set_property("pixbuf", pixbuf)
- def __name_cell_data_cb(self, celllayout, renderer, model, iter):
+ def __name_cell_data_cb(self, celllayout, renderer, model, iter, data):
engine = self.__model.get_value(iter, 0)
if isinstance (engine, str) or isinstance (engine, unicode):
renderer.set_property("sensitive", False)
renderer.set_property("text", engine)
- renderer.set_property("weight", pango.WEIGHT_NORMAL)
+ renderer.set_property("weight", Pango.Weight.NORMAL)
elif isinstance(engine, int):
renderer.set_property("sensitive", True)
- renderer.set_property("text", self.__title)
- renderer.set_property("weight", pango.WEIGHT_NORMAL)
+ renderer.set_property("text", _("Select an input method"))
+ renderer.set_property("weight", Pango.Weight.NORMAL)
else:
renderer.set_property("sensitive", True)
- renderer.set_property("text", engine.longname)
- renderer.set_property("weight", pango.WEIGHT_BOLD if engine.rank > 0 else pango.WEIGHT_NORMAL)
+ renderer.set_property("text", engine.get_longname())
+ renderer.set_property("weight",
+ Pango.Weight.BOLD if engine.get_rank() > 0 else Pango.Weight.NORMAL)
def __notify_active_cb(self, combobox, property):
self.notify("active-engine")
@@ -146,9 +158,10 @@ def do_get_property(self, property):
def get_active_engine(self):
return self.get_property("active-engine")
- def get_title(self):
- return self.__title
-
- def set_title(self, title):
- self.__title = title
-
+if __name__ == "__main__":
+ combo = EngineComboBox()
+ combo.set_engines([IBus.EngineDesc(language="zh")])
+ w = Gtk.Window()
+ w.add(combo)
+ w.show_all()
+ Gtk.main()
View
176 setup/enginetreeview.py
@@ -2,9 +2,9 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -21,29 +21,28 @@
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
-import gtk
-import glib
-import gobject
-import pango
-import ibus
-import ibusxkb
+from gi.repository import GLib
+from gi.repository import GObject
+from gi.repository import Gtk
+from gi.repository import IBus
+from gi.repository import Pango
from icon import load_icon
from i18n import _, N_
-class EngineTreeView(gtk.TreeView):
+class EngineTreeView(Gtk.TreeView):
__gtype_name__ = 'EngineTreeView'
__gproperties__ = {
'active-engine' : (
- gobject.TYPE_PYOBJECT,
+ object,
'selected engine',
'selected engine',
- gobject.PARAM_READABLE),
+ GObject.ParamFlags.READABLE),
'engines' : (
- gobject.TYPE_PYOBJECT,
+ object,
'engines',
'engines',
- gobject.PARAM_READABLE)
+ GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE)
}
def __init__(self):
@@ -55,32 +54,32 @@ def __init__(self):
# self.set_headers_visible(True)
self.set_reorderable(True)
- self.__model = gtk.ListStore(gobject.TYPE_PYOBJECT, gobject.TYPE_STRING)
+ self.__model = Gtk.ListStore(GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
self.set_model(self.__model)
self.__model.connect("row-changed", self.__emit_changed_delay_cb, "row-changed")
self.__model.connect("row-deleted", self.__emit_changed_delay_cb, "row-deleted")
self.__model.connect("row-inserted", self.__emit_changed_delay_cb, "row-inserted")
self.__model.connect("rows-reordered", self.__emit_changed_delay_cb, "rows-reordered")
# create im name & icon column
- column = gtk.TreeViewColumn(_("Input Method"))
+ column = Gtk.TreeViewColumn(_("Input Method"))
column.set_min_width(220)
- renderer = gtk.CellRendererPixbuf()
+ renderer = Gtk.CellRendererPixbuf()
renderer.set_property("xalign", 0)
column.pack_start(renderer, False)
column.set_cell_data_func(renderer, self.__icon_cell_data_cb)
- renderer = gtk.CellRendererText()
+ renderer = Gtk.CellRendererText()
renderer.set_property("xalign", 0)
- renderer.set_property("ellipsize", pango.ELLIPSIZE_END)
+ renderer.set_property("ellipsize", Pango.EllipsizeMode.END)
column.pack_start(renderer, True)
column.set_cell_data_func(renderer, self.__name_cell_data_cb)
self.append_column(column)
# create im keyboard layout column
- renderer = gtk.CellRendererCombo()
- model = gtk.ListStore(gobject.TYPE_STRING)
+ renderer = Gtk.CellRendererCombo()
+ model = Gtk.ListStore(GObject.TYPE_STRING)
model.append(("us",))
model.append(("jp",))
model.append(("xkb",))
@@ -91,15 +90,18 @@ def __init__(self):
renderer.set_property("editable", True)
renderer.connect("changed", self.__engine_layout_changed_cb)
- column = gtk.TreeViewColumn(_("Kbd"))
+ column = Gtk.TreeViewColumn(_("Kbd"))
column.set_expand(False)
column.set_fixed_width(32)
- column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
+ column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
column.pack_start(renderer, False)
column.set_cell_data_func(renderer, self.__layout_cell_data_cb)
# self.append_column(column)
- self.get_selection().connect("changed", lambda *args: self.notify("active-engine"))
+ self.get_selection().connect("changed", self.__selection_changed_cb)
+
+ def __selection_changed_cb(self, *args):
+ self.notify("active-engine");
def __emit_changed(self, *args):
if self.__changed:
@@ -109,77 +111,83 @@ def __emit_changed(self, *args):
def __emit_changed_delay_cb(self, *args):
if not self.__changed:
self.__changed = True
- glib.idle_add(self.__emit_changed)
+ GLib.idle_add(self.__emit_changed)
- def __icon_cell_data_cb(self, celllayout, renderer, model, iter):
- engine = self.__model.get_value(iter, 0)
+ def __icon_cell_data_cb(self, celllayout, renderer, model, it, data):
+ engine = self.__model.get_value(it, 0)
- icon_size = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)[0]
- pixbuf = load_icon(engine.icon, gtk.ICON_SIZE_LARGE_TOOLBAR)
+ icon_size = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)[0]
+ pixbuf = load_icon(engine.get_icon(), Gtk.IconSize.LARGE_TOOLBAR)
if pixbuf == None:
- pixbuf = load_icon("ibus-engine", gtk.ICON_SIZE_LARGE_TOOLBAR)
+ pixbuf = load_icon("ibus-engine", Gtk.IconSize.LARGE_TOOLBAR)
if pixbuf == None:
- pixbuf = load_icon("gtk-missing-image", gtk.ICON_SIZE_LARGE_TOOLBAR)
+ pixbuf = load_icon(Gtk.STOCK_MISSING_IMAGE,
+ Gtk.IconSize.LARGE_TOOLBAR)
renderer.set_property("pixbuf", pixbuf)
- def __name_cell_data_cb(self, celllayout, renderer, model, iter):
- engine = self.__model.get_value(iter, 0)
+ def __name_cell_data_cb(self, celllayout, renderer, model, it, data):
+ engine = self.__model.get_value(it, 0)
renderer.set_property("sensitive", True)
- language = ibus.get_language_name(engine.language)
- renderer.set_property("text", "%s - %s" % (language, engine.longname))
- if self.__model.get_path(iter)[0] == 0:
+ language = IBus.get_language_name(engine.get_language())
+ renderer.set_property("text",
+ "%s - %s" % (language, engine.get_longname()))
+ if self.__model.get_path(it).get_indices()[0] == 0:
# default engine
- renderer.set_property("weight", pango.WEIGHT_BOLD)
+ renderer.set_property("weight", Pango.Weight.BOLD)
else:
- renderer.set_property("weight", pango.WEIGHT_NORMAL)
+ renderer.set_property("weight", Pango.Weight.NORMAL)
- def __layout_cell_data_cb(self, celllayout, renderer, model, iter):
- engine = self.__model.get_value(iter, 0)
- layout = self.__model.get_value(iter, 1)
+ def __layout_cell_data_cb(self, celllayout, renderer, model, it, data):
+ engine = self.__model.get_value(it, 0)
+ layout = self.__model.get_value(it, 1)
renderer.set_property("sensitive", True)
if not layout:
layout = engine.layout
renderer.set_property("text", layout)
- if self.__model.get_path(iter)[0] == 0:
+ if self.__model.get_path(it).get_indices()[0] == 0:
#default engine
- renderer.set_property("weight", pango.WEIGHT_BOLD)
+ renderer.set_property("weight", Pango.Weight.BOLD)
else:
- renderer.set_property("weight", pango.WEIGHT_NORMAL)
+ renderer.set_property("weight", Pango.Weight.NORMAL)
- def __engine_layout_changed_cb(self, combo, path, iter):
+ def __engine_layout_changed_cb(self, combo, path, it):
return
i = self.__model.get_iter(path)
- layout = combo.get_property("model").get_value(iter, 0)
+ layout = combo.get_property("model").get_value(it, 0)
self.__model.set_value(i, 1, layout)
- def do_get_property(self, property):
- if property.name == "active-engine":
- iter = self.get_selected_iter()
- if iter == None:
+ def do_get_property(self, prop):
+ if prop.name == "active-engine":
+ it = self.get_selected_iter()
+ if it == None:
return None
- row = self.__model.get(iter, 0)
+ row = self.__model.get(it, 0)
return row[0]
- elif property.name == "engines":
+ elif prop.name == "engines":
engines = [ r[0] for r in self.__model if r[0] != None]
return engines
else:
- raise AttributeError, 'unknown property %s' % property.name
+ raise AttributeError, 'unknown property %s' % prop.name
+
+ def do_set_property(self, prop, value):
+ if prop.name == "active-engine":
+ raise AttributeError, "active-engine is readonly"
+ elif prop.name == "engines":
+ set_engines(value)
+ else:
+ raise AttributeError, 'unknown property %s' % prop.name
def set_engines(self, engines):
self.__model.clear()
self.__engines = set([])
for e in engines:
if e in self.__engines:
continue
- if ibusxkb.use_bridge_hotkey() and \
- e.name.startswith(ibusxkb.DEFAULT_BRIDGE_ENGINE_NAME):
- pass
- else:
- iter = self.__model.append(None)
- self.__model.set(iter, 0, e)
+ it = self.__model.append(None)
+ self.__model.set(it, 0, e)
self.__engines.add(e)
self.__emit_changed()
@@ -197,28 +205,28 @@ def get_active_engine(self):
def prepend_engine(self, engine):
if engine == None or engine in self.__engines:
return
- iter = self.__model.prepend(None)
- self.__model.set(iter, 0, engine)
+ it = self.__model.prepend(None)
+ self.__model.set(it, 0, engine)
self.__engines.add(engine)
self.scroll_to_cell(self.__model[0].path, None)
def append_engine(self, engine):
if engine == None or engine in self.__engines:
return
- iter = self.__model.append(None)
- self.__model.set(iter, 0, engine)
+ it = self.__model.append(None)
+ self.__model.set(it, 0, engine)
self.__engines.add(engine)
self.scroll_to_cell(self.__model[-1].path, None)
def remove_engine(self):
- iter = self.get_selected_iter()
- if iter == None:
+ it = self.get_selected_iter()
+ if it == None:
return
- row = self.__model[iter]
+ row = self.__model[it]
engine = row[0]
self.__engines.remove(engine)
- index = row.path[0]
- self.__model.remove(iter)
+ index = row.path.get_indices()[0]
+ self.__model.remove(it)
try:
row = self.__model[index]
selection = self.get_selection()
@@ -227,27 +235,35 @@ def remove_engine(self):
pass
def move_up_engine(self):
- iter = self.get_selected_iter()
- if iter == None:
+ it = self.get_selected_iter()
+ if it == None:
return
- row = self.__model[iter]
- index = row.path[0]
+ row = self.__model[it]
+ index = row.path.get_indices()[0]
if index == 0:
return
- self.__model.swap(iter, self.__model[index - 1].iter)
+ self.__model.swap(it, self.__model[index - 1].iter)
self.scroll_to_cell(row.path, None)
def move_down_engine(self):
- iter = self.get_selected_iter()
- if iter == None:
+ it = self.get_selected_iter()
+ if it == None:
return
- row = self.__model[iter]
- index = row.path[0]
+ row = self.__model[it]
+ index = row.path.get_indices()[0]
last_row = self.__model[-1]
- last_index = last_row.path[0]
+ last_index = last_row.path.get_indices()[0]
if index == last_index:
return
- self.__model.swap(iter, self.__model[index + 1].iter)
+ self.__model.swap(it, self.__model[index + 1].iter)
self.scroll_to_cell(row.path, None)
-gobject.type_register(EngineTreeView)
+GObject.type_register(EngineTreeView)
+
+if __name__ == "__main__":
+ tree = EngineTreeView()
+ tree.set_engines([IBus.EngineDesc(language="zh")])
+ w = Gtk.Window()
+ w.add(tree)
+ w.show_all()
+ Gtk.main()
View
35 setup/i18n.py
@@ -1,35 +0,0 @@
-# vim:set et sts=4 sw=4:
-#
-# ibus-xkb - IBus XKB
-#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or(at your option) any later version.
-#
-# This library 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 Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this program; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-# Boston, MA 02111-1307 USA
-
-import gettext
-import os
-
-DOMAINNAME = "ibus-xkb"
-
-_ = lambda a: gettext.dgettext(DOMAINNAME, a)
-N_ = lambda a: a
-
-def init():
- localedir = os.getenv("IBUS_LOCALEDIR")
- gettext.bindtextdomain(DOMAINNAME, localedir)
- gettext.bind_textdomain_codeset(DOMAINNAME, "UTF-8")
View
1 setup/i18n.py
View
9 setup/ibus-setup-xkb.desktop.in
@@ -0,0 +1,9 @@
+[Desktop Entry]
+_Name=IBus Preferences
+_Comment=Set IBus Preferences
+Exec=ibus-setup-xkb
+Icon=ibus-setup-xkb
+Terminal=false
+Type=Application
+StartupNotify=true
+Categories=Settings;
View
12 setup/ibus-setup-xkb.in
@@ -1,10 +1,10 @@
#!/bin/sh
#
-# ibus-xkb - IBus XKB
+# ibus-xkb - The Input Bus
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -24,8 +24,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
datarootdir=@datarootdir@
+libexecdir=@libexecdir@
export IBUS_PREFIX=@prefix@
export IBUS_DATAROOTDIR=@datarootdir@
export IBUS_LOCALEDIR=@localedir@
-exec @PYTHON@ @prefix@/share/ibus-xkb/setup/main.py $@
+export IBUS_LIBEXECDIR=${libexecdir}
+exec @PYTHON@ @prefix@/share/ibus/setup-xkb/main.py $@
View
28 setup/icon.py
@@ -2,9 +2,9 @@
#
# ibus-xkb - IBus XKB
#
-# Copyright (c) 2011 Takao Fujiwara <takao.fujiwara1@gmail.com>
-# Copyright (c) 2011 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2011 Red Hat, Inc.
+# Copyright (c) 2012 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -25,12 +25,13 @@
"load_icon"
)
-import gtk
-from gtk import gdk
+from gi.repository import Gdk
+from gi.repository import GdkPixbuf
+from gi.repository import Gtk
from os import path
-icon_theme = gtk.icon_theme_get_default()
+icon_theme = Gtk.IconTheme.get_default()
dir = path.dirname(__file__)
icondir = path.join(dir, "..", "icons")
icon_theme.prepend_search_path(icondir)
@@ -41,22 +42,29 @@ def load_icon(icon, size):
if (icon, size) in icon_cache:
return icon_cache[(icon, size)]
- icon_size = gtk.icon_size_lookup(size)[0]
+ icon_size = Gtk.icon_size_lookup(size)
+ if icon_size[0]:
+ icon_size = icon_size[1]
+
pixbuf = None
try:
- pixbuf = gdk.pixbuf_new_from_file(icon)
+ pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon)
w, h = pixbuf.get_width(), pixbuf.get_height()
rate = max(w, h) / float(icon_size)
w = int(w / rate)
h = int(h / rate)
- pixbuf = pixbuf.scale_simple(w, h, gdk.INTERP_BILINEAR)
+ pixbuf = pixbuf.scale_simple(w, h, GdkPixbuf.InterpType.BILINEAR)
except:
+ # import traceback
+ # traceback.print_exc()
pass
if pixbuf == None:
try:
- theme = gtk.icon_theme_get_default()
+ theme = Gtk.IconTheme.get_default()
pixbuf = theme.load_icon(icon, icon_size, 0)
except:
+ # import traceback
+ # traceback.print_exc()
pass
icon_cache[(icon, size)] = pixbuf
return pixbuf