Commit 7b2d4274 authored by Anthony Wong's avatar Anthony Wong

Imported Upstream version 2.1

parent 322ff71a
......@@ -2,6 +2,7 @@
#
# IBus Cangjie was written by these people:
Anthony Wong <anthony.wong@ubuntu.com>
Benau <benau2006@yahoo.com.hk>
Koala Yeung <koalay@gmail.com>
Mathieu Bridon <bochecha@fedoraproject.org>
......@@ -70,6 +70,7 @@ icon_files = $(icon16_DATA) $(iconscalable_DATA)
# -- src/ ----------------------------
ibus_cangjie_PYTHON = \
src/__init__.py \
src/canberra.py \
src/engine.py \
src/setup.py \
$(NULL)
......@@ -82,7 +83,7 @@ TESTS = tests/run_tests
tests/run_tests: tests/run_tests.in
$(MKDIR_P) tests
sed -e 's&@PYTHON_BIN@&$(PYTHON)&g' \
-e 's&@SRCDIR@&$(srcdir)&g' $< > $@
-e 's&@SRCDIR@&$(srcdir)&g' \
-e 's&@BUILDDIR@&$(builddir)&g' $< > $@
chmod +x $@
......@@ -117,8 +118,13 @@ CLEANFILES = \
$(pkglibexec_SCRIPTS) \
src/*.pyc \
tests/run_tests \
data/gschemas.compiled \
$(NULL)
clean-local:
-rm -rf src/__pycache__
-rm -rf tests/__pycache__
EXTRA_DIST = \
autogen.sh \
data/setup.ui \
......
......@@ -593,6 +593,7 @@ icon_files = $(icon16_DATA) $(iconscalable_DATA)
# -- src/ ----------------------------
ibus_cangjie_PYTHON = \
src/__init__.py \
src/canberra.py \
src/engine.py \
src/setup.py \
$(NULL)
......@@ -616,6 +617,7 @@ CLEANFILES = \
$(pkglibexec_SCRIPTS) \
src/*.pyc \
tests/run_tests \
data/gschemas.compiled \
$(NULL)
EXTRA_DIST = \
......@@ -1429,7 +1431,7 @@ maintainer-clean-generic:
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
clean-am: clean-generic clean-local mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
......@@ -1508,15 +1510,15 @@ uninstall-am: uninstall-appdataDATA uninstall-binSCRIPTS \
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-TESTS check-am clean clean-cscope \
clean-generic cscope cscopelist-am ctags ctags-am dist \
dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
dist-xz dist-zip distcheck distclean distclean-generic \
distclean-hdr distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-appdataDATA install-binSCRIPTS \
install-componentDATA install-data install-data-am \
install-desktopDATA install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am \
clean-generic clean-local cscope cscopelist-am ctags ctags-am \
dist dist-all dist-bzip2 dist-gzip dist-lzip dist-shar \
dist-tarZ dist-xz dist-zip distcheck distclean \
distclean-generic distclean-hdr distclean-tags distcleancheck \
distdir distuninstallcheck dvi dvi-am html html-am info \
info-am install install-am install-appdataDATA \
install-binSCRIPTS install-componentDATA install-data \
install-data-am install-desktopDATA install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-ibus_cangjiePYTHON install-ibus_cangjie_dataDATA \
install-icon16DATA install-iconscalableDATA install-info \
install-info-am install-man install-pdf install-pdf-am \
......@@ -1560,7 +1562,7 @@ scripts/ibus-%-cangjie: scripts/ibus-%-cangjie.in Makefile
tests/run_tests: tests/run_tests.in
$(MKDIR_P) tests
sed -e 's&@PYTHON_BIN@&$(PYTHON)&g' \
-e 's&@SRCDIR@&$(srcdir)&g' $< > $@
-e 's&@SRCDIR@&$(srcdir)&g' \
-e 's&@BUILDDIR@&$(builddir)&g' $< > $@
chmod +x $@
......@@ -1579,6 +1581,10 @@ AUTHORS:
$(top_builddir)/data:
$(AM_V_GEN) $(MKDIR_P) $(top_builddir)/data
clean-local:
-rm -rf src/__pycache__
-rm -rf tests/__pycache__
.PHONY: AUTHORS $(top_builddir)/data
# Tell versions [3.59,3.63) of GNU make to not export all variables.
......
......@@ -9,7 +9,10 @@ Note that the actual input logic is handled by
[libcangjie](https://github.com/Cangjians/libcangjie).
Development happens [on github](https://github.com/Cangjians/ibus-cangjie),
and stable release tarballs will be available when we reach that point.
table release tarballs can be found in
[the download section](http://cangjians.github.io/downloads/ibus-cangjie/) of
our website.
## Legalities
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for ibus-cangjie 2.0.
# Generated by GNU Autoconf 2.69 for ibus-cangjie 2.1.
#
# Report bugs to <https://github.com/Cangjians/ibus-cangjie/issues>.
#
......@@ -579,8 +579,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='ibus-cangjie'
PACKAGE_TARNAME='ibus-cangjie'
PACKAGE_VERSION='2.0'
PACKAGE_STRING='ibus-cangjie 2.0'
PACKAGE_VERSION='2.1'
PACKAGE_STRING='ibus-cangjie 2.1'
PACKAGE_BUGREPORT='https://github.com/Cangjians/ibus-cangjie/issues'
PACKAGE_URL='https://github.com/Cangjians/ibus-cangjie'
......@@ -1313,7 +1313,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures ibus-cangjie 2.0 to adapt to many kinds of systems.
\`configure' configures ibus-cangjie 2.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1383,7 +1383,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of ibus-cangjie 2.0:";;
short | recursive ) echo "Configuration of ibus-cangjie 2.1:";;
esac
cat <<\_ACEOF
......@@ -1495,7 +1495,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
ibus-cangjie configure 2.0
ibus-cangjie configure 2.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -1705,7 +1705,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by ibus-cangjie $as_me 2.0, which was
It was created by ibus-cangjie $as_me 2.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -2579,7 +2579,7 @@ fi
# Define the identity of the package.
PACKAGE='ibus-cangjie'
VERSION='2.0'
VERSION='2.1'
cat >>confdefs.h <<_ACEOF
......@@ -7608,7 +7608,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by ibus-cangjie $as_me 2.0, which was
This file was extended by ibus-cangjie $as_me 2.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -7675,7 +7675,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
ibus-cangjie config.status 2.0
ibus-cangjie config.status 2.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
AC_PREREQ(2.63)
AC_INIT([ibus-cangjie], [2.0], [https://github.com/Cangjians/ibus-cangjie/issues], [ibus-cangjie], [https://github.com/Cangjians/ibus-cangjie])
AC_INIT([ibus-cangjie], [2.1], [https://github.com/Cangjians/ibus-cangjie/issues], [ibus-cangjie], [https://github.com/Cangjians/ibus-cangjie])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
......
......@@ -202,7 +202,6 @@ The following additional characters can be enabled:</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">25</property>
<property name="label" translatable="yes">
<property name="label" translatable="yes" comments="This is a list of examples. Do not translate the characters themselves, only translate it so it looks like a list of examples in your own language, but keep these characters as examples.">Eg. 诉, 䜣, 㻹</property>
<attributes>
<attribute name="foreground" value="#88888a8a8484"/>
......
......@@ -4,13 +4,14 @@
#
# Translators:
# Enrico Nicoletto <enrico.BR@gmx.co.uk>, 2013
# bochecha <bochecha@fedoraproject.org>, 2014
msgid ""
msgstr ""
"Project-Id-Version: ibus-cangjie\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-10 14:58+0800\n"
"PO-Revision-Date: 2013-12-15 15:29+0000\n"
"Last-Translator: Enrico Nicoletto <enrico.BR@gmx.co.uk>\n"
"PO-Revision-Date: 2014-01-11 10:14+0000\n"
"Last-Translator: bochecha <bochecha@fedoraproject.org>\n"
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/projects/p/ibus-cangjie/language/pt_BR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
......@@ -41,18 +42,18 @@ msgstr "Já que tal método é dificilmente usado fora de Hong Kong (onde este
#: ../data/quick.appdata.xml.in.h:1
msgid "Quick"
msgstr "Rápido"
msgstr "Quick"
#: ../data/quick.appdata.xml.in.h:2
msgid "Quick input method"
msgstr "Método rápido de entrada"
msgstr "Método de entrada Quick"
#: ../data/quick.appdata.xml.in.h:3
msgid ""
"Quick (also known as “Simplified Cangjie”) is a radical-based input method, "
"designed to input both Traditional and Simplified Chinese, as well as "
"Japanese."
msgstr "Rápido (também conhecido como “Cangjie Simplificado”) é um método de entrada baseado no radical da palavra, projetado para permitir a entrada de caracteres tanto de Chinês Tradicional quanto de Chinês Simplificado, bem como de Japonês."
msgstr "Quick (também conhecido como “Cangjie Simplificado”) é um método de entrada baseado no radical da palavra, projetado para permitir a entrada de caracteres tanto de Chinês Tradicional quanto de Chinês Simplificado, bem como de Japonês."
#. The title of the preferences window for Cangjie
#: ../data/ibus-setup-cangjie.desktop.in.in.h:2 ../src/setup.py:55
......@@ -67,12 +68,12 @@ msgstr "Define as preferências para o método de entrada Cangjie"
#. The title of the preferences window for Quick
#: ../data/ibus-setup-quick.desktop.in.in.h:2 ../src/setup.py:57
msgid "Quick Preferences"
msgstr "Preferências rápidas"
msgstr "Preferências do Quick"
#. Tooltip for the preferences "app" for Quick
#: ../data/ibus-setup-quick.desktop.in.in.h:4
msgid "Set preferences for the Quick input method"
msgstr "Define as preferências para o método de entrada rápido"
msgstr "Define as preferências para o método de entrada Quick"
#. We support versions 3 and 5 of Cangjie. Most people will think version 3 is
#. the 'standard' one as it is the one used on Windows
......@@ -136,6 +137,6 @@ msgstr "Símbolos"
msgid "Eg. ○, ㈤, →"
msgstr "Ex.: ○, ㈤, →"
#: ../src/engine.py:69
#: ../src/engine.py:67
msgid "Half-Width Characters"
msgstr "Caracteres de meia largura"
......@@ -138,6 +138,6 @@ msgstr "符號"
msgid "Eg. ○, ㈤, →"
msgstr "例如:○,㈤,→"
#: ../src/engine.py:69
#: ../src/engine.py:67
msgid "Half-Width Characters"
msgstr "半形字元"
......@@ -137,6 +137,6 @@ msgstr "符號"
msgid "Eg. ○, ㈤, →"
msgstr "例:○,㈤,→"
#: ../src/engine.py:69
#: ../src/engine.py:67
msgid "Half-Width Characters"
msgstr "半形字元"
# Copyright (c) 2012-2013 - The IBus Cangjie authors
#
# This file is part of ibus-cangjie, the IBus Cangjie input method engine.
#
# ibus-cangjie 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 3 of the License, or
# (at your option) any later version.
#
# ibus-cangjie 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 ibus-cangjie. If not, see <http://www.gnu.org/licenses/>.
try:
from pycanberra import (Canberra as _Canberra,
CA_PROP_EVENT_ID, CA_PROP_MEDIA_ROLE)
except ImportError:
# pycanberra is optional, make it all noops if it's not installed
class _Canberra:
def play(self, *args, **kwargs):
pass
CA_PROP_EVENT_ID = None
CA_PROP_MEDIA_ROLE = None
class Canberra:
def __init__(self):
self.__canberra = _Canberra()
def play_error(self):
self.__canberra.play(1, CA_PROP_EVENT_ID, "dialog-error",
CA_PROP_MEDIA_ROLE, "error", None)
......@@ -25,14 +25,10 @@ from operator import attrgetter
from gi.repository import Gio
from gi.repository import IBus
try:
import pycanberra
except ImportError:
# Too bad, the user won't get sound feedback on errors
pass
import cangjie
from .canberra import Canberra
# FIXME: Find a way to de-hardcode the gettext package
_ = lambda x: gettext.dgettext("ibus-cangjie", x)
......@@ -48,6 +44,8 @@ class Engine(IBus.Engine):
def __init__(self):
super(Engine, self).__init__()
self.canberra = Canberra()
self.settings = Gio.Settings("org.cangjians.ibus.%s" % self.__name__)
self.settings.connect("changed", self.on_value_changed)
......@@ -433,16 +431,7 @@ class Engine(IBus.Engine):
def play_error_bell(self):
"""Play an error sound, to notify the user of invalid input."""
try:
if not hasattr(self, "canberra"):
self.canberra = pycanberra.Canberra()
self.canberra.play(1, pycanberra.CA_PROP_EVENT_ID, "dialog-error",
pycanberra.CA_PROP_MEDIA_ROLE, "error", None)
except:
# Playing a sound is a nice indication for the user, but if it
# fails, it should never take down the input system
pass
self.canberra.play_error()
class EngineCangjie(Engine):
......
......@@ -28,6 +28,7 @@ import unittest
sys.path.insert(0, "@SRCDIR@")
import src
sys.modules["ibus_cangjie"] = src
sys.path.pop(0)
# -- Define some mock classes for the tests ----------------------------------
......@@ -96,9 +97,8 @@ class MockCanberra:
def __init__(self):
self._mock_played_events = []
def play(self, playId, *args):
if "dialog-error" in args:
self._mock_played_events.append("dialog-error")
def play_error(self):
self._mock_played_events.append("error")
# -- Monkey patch the environment with the mock classes ----------------------
......@@ -108,19 +108,19 @@ sys.modules["gi.repository.IBus"].LookupTable = MockLookupTable
sys.modules["gi.repository.IBus"].Property = MockProperty
sys.modules["gi.repository.IBus"].PropList = MockPropList
try:
import pycanberra
sys.modules["pycanberra"].Canberra = MockCanberra
os.environ["IBUS_CANGJIE_TESTS_HAVE_PYCANBERRA"] = "true"
except ImportError:
# Let the tests know that they shouldn't try pycanberra
os.environ["IBUS_CANGJIE_TESTS_HAVE_PYCANBERRA"] = "false"
import ibus_cangjie.canberra
sys.modules["ibus_cangjie.canberra"].Canberra = MockCanberra
# -- Set some environment variables for the tests ----------------------------
# The unit tests will need this to find the settings schemas
os.environ["GSETTINGS_SCHEMA_DIR"] = "@BUILDDIR@/data"
subprocess.check_call(["glib-compile-schemas", os.environ["GSETTINGS_SCHEMA_DIR"]])
# The unit tests will need this to find the preferences UI
os.environ["PREFERENCES_UI_DIR"] = "@SRCDIR@/data"
# -- Load and run our unit tests ---------------------------------------------
loader = unittest.TestLoader()
suite = loader.discover("@SRCDIR@/tests")
......
......@@ -92,18 +92,14 @@ class CangjieTestCase(unittest.TestCase):
self.assertEqual(len(self.engine._mock_auxiliary_text), 5)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
if os.environ["IBUS_CANGJIE_TESTS_HAVE_PYCANBERRA"] == "true":
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
# And once more
self.engine.do_process_key_event(IBus.a, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 5)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
if os.environ["IBUS_CANGJIE_TESTS_HAVE_PYCANBERRA"] == "true":
self.assertEqual(len(self.engine.canberra._mock_played_events), 2)
self.assertEqual(len(self.engine.canberra._mock_played_events), 2)
def test_inexistent_combination(self):
self.engine.do_process_key_event(IBus.z, 0, 0)
......@@ -116,9 +112,7 @@ class CangjieTestCase(unittest.TestCase):
self.assertEqual(len(self.engine._mock_auxiliary_text), 5)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
if os.environ["IBUS_CANGJIE_TESTS_HAVE_PYCANBERRA"] == "true":
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
def test_wildcard(self):
self.engine.do_process_key_event(IBus.d, 0, 0)
......@@ -151,9 +145,7 @@ class CangjieTestCase(unittest.TestCase):
self.assertEqual(len(self.engine._mock_auxiliary_text), 2)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
if os.environ["IBUS_CANGJIE_TESTS_HAVE_PYCANBERRA"] == "true":
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
def test_backspace(self):
self.engine.do_process_key_event(IBus.a, 0, 0)
......@@ -221,9 +213,7 @@ class CangjieTestCase(unittest.TestCase):
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.space, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 2)
if os.environ["IBUS_CANGJIE_TESTS_HAVE_PYCANBERRA"] == "true":
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
# Now go on inputting
self.engine.do_process_key_event(IBus.z, 0, 0)
......@@ -240,9 +230,7 @@ class CangjieTestCase(unittest.TestCase):
self.engine.do_process_key_event(IBus.z, 0, 0)
self.engine.do_process_key_event(IBus.space, 0, 0)
self.assertEqual(len(self.engine._mock_auxiliary_text), 5)
if os.environ["IBUS_CANGJIE_TESTS_HAVE_PYCANBERRA"] == "true":
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
# Now go on inputting
self.engine.do_process_key_event(IBus.z, 0, 0)
......
# Copyright (c) 2013 - The IBus Cangjie authors
#
# This file is part of ibus-cangjie, the IBus Cangjie input method engine.
#
# ibus-cangjie 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 3 of the License, or
# (at your option) any later version.
#
# ibus-cangjie 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 ibus-cangjie. If not, see <http://www.gnu.org/licenses/>.
import os
import unittest
class PrefsTestCase(unittest.TestCase):
def setUp(self):
self.ui_file = os.path.join(os.environ["PREFERENCES_UI_DIR"],
"setup.ui")
def tearDown(self):
pass
def test_ui_file_is_valid_xml(self):
from xml.etree import ElementTree as ET
try:
ET.parse(self.ui_file)
except ET.ParseError as e:
raise AssertionError(e)
def test_ui_file_is_valid_gtk_builder(self):
try:
from gi.repository import Gtk
except RuntimeError as e:
# It seems on some platforms (notably, Ubuntu 12.04 where are CI
# is running) we can't import Gtk without a display, but on others
# (e.g Fedora 20) we can. There isn't much we can do except
# skipping this test if importing Gtk fails, but the test is still
# useful on those platforms where it works.
self.skipTest("Could not import Gtk: %s" % e)
b = Gtk.Builder()
try:
b.add_from_file(self.ui_file)
except Exception as e:
raise AssertionError(e)
......@@ -94,9 +94,7 @@ class QuickTestCase(unittest.TestCase):
self.assertEqual(len(self.engine._mock_auxiliary_text), 2)
self.assertEqual(len(self.engine._mock_committed_text), 0)
self.assertEqual(self.engine.lookuptable.get_number_of_candidates(), 0)
if os.environ["IBUS_CANGJIE_TESTS_HAVE_PYCANBERRA"] == "true":
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
self.assertEqual(len(self.engine.canberra._mock_played_events), 1)
def test_nowildcard(self):
self.engine.do_process_key_event(IBus.d, 0, 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment