Skip to content

Commit

Permalink
Merge pull request #69 from Cangjians/release-2.3
Browse files Browse the repository at this point in the history
Release 2.3
  • Loading branch information
yookoala committed Mar 4, 2015
2 parents a9e1e09 + 766921d commit 1f53166
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 15 deletions.
10 changes: 10 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ install it with `yum`:
$ sudo yum install ibus-cangjie
```

## Gentoo

IBus Cangjie is included in the Gentoo repositories. Its currently masked.
You will need to add "app-i18n/ibus-cangjie" to your /etc/portage/package.accept_keywords
or use autounmask. Once unmasked install as root with :

```
$ emerge app-i18n/ibus-cangjie
```

## Ubuntu 14.04

IBus Cangjie is included in the default Ubuntu repositories, **starting with
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AC_PREREQ(2.63)
AC_INIT([ibus-cangjie], [2.2], [https://github.com/Cangjians/ibus-cangjie/issues], [ibus-cangjie], [https://github.com/Cangjians/ibus-cangjie])
AC_INIT([ibus-cangjie], [2.3], [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])
Expand Down
2 changes: 1 addition & 1 deletion po/zh_TW.po
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ msgstr "輸入法版本"
msgid ""
"Only characters common in Hong Kong can be inputted by default.\n"
"The following additional characters can be enabled:"
msgstr "預設情況下只能輸入香港常用字。\n可以額外啟用下列額字元:"
msgstr "預設情況下只能輸入香港常用字。\n可以額外啟用下列字元:"

#. The Taiwanese Zhuyin alphabet is known under two names in English.
#. Obviously, if it only has one name in your language, don't try to keep two
Expand Down
17 changes: 15 additions & 2 deletions src/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def __init__(self):

self.canberra = Canberra()

self.settings = Gio.Settings("org.cangjians.ibus.%s" % self.__name__)
schema_id = "org.cangjians.ibus.%s" % self.__name__
self.settings = Gio.Settings(schema_id=schema_id)
self.settings.connect("changed", self.on_value_changed)

self.current_input = ""
Expand Down Expand Up @@ -249,7 +250,12 @@ def do_other_key(self, keyval):
self.get_candidates(by_shortcode=True)

else:
self.get_candidates()
try:
self.get_candidates()

except cangjie.errors.CangjieNoCharsError:
self.play_error_bell()
return True

if self.lookuptable.get_number_of_candidates():
self.do_select_candidate(1)
Expand Down Expand Up @@ -394,9 +400,16 @@ def get_candidates(self, code=None, by_shortcode=False):
else:
chars = self.cangjie.get_characters_by_shortcode(code)

# Finding an element in a dict is **much** faster than in a list
seen = {}

for c in sorted(chars, key=attrgetter("frequency"), reverse=True):
if c.chchar in seen:
continue

self.lookuptable.append_candidate(IBus.Text.new_from_string(c.chchar))
num_candidates += 1
seen[c.chchar] = True

if num_candidates == 1:
self.do_select_candidate(1)
Expand Down
3 changes: 3 additions & 0 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def on_value_changed(self, settings, key):
We need to react, in case the value was changed from somewhere else,
for example from another setup UI.
"""
if key == "halfwidth-chars":
return

if key == "version":
new_value = self.settings.get_int(key)

Expand Down
45 changes: 34 additions & 11 deletions tests/test_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,38 @@
import unittest


def has_graphical():
"""Detect if we have graphical capabilities
It is very common to run the unit tests in an environment which does not
have any graphical capabilities.
This is for example the case in a CI server, or when building RPMs for
Fedora.
This function is useful to detect these situation, so that we can
automatically skip the tests which can't run without.
"""
try:
from gi.repository import Gtk

except RuntimeError as e:
# On some platforms (e.g Ubuntu 12.04 where our CI is running) we
# can't import Gtk without a display.
return False

# But other platforms (e.g Fedora 21) can import Gtk just fine even
# without a display...

from gi.repository import Gdk

if Gdk.Display.get_default() is None:
# ... We don't have a display
return False

return True


class PrefsTestCase(unittest.TestCase):
def setUp(self):
self.ui_file = os.path.join(os.environ["PREFERENCES_UI_DIR"],
Expand All @@ -37,18 +69,9 @@ def test_ui_file_is_valid_xml(self):
except ET.ParseError as e:
raise AssertionError(e)

@unittest.skipUnless(has_graphical(), "Can't use GtkBuilder")
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)

from gi.repository import Gtk
b = Gtk.Builder()

try:
Expand Down

0 comments on commit 1f53166

Please sign in to comment.