Skip to content

Commit

Permalink
Update ibus-setup-pinyin.in: to avoid ibus-pinyin-setup crash in pure…
Browse files Browse the repository at this point in the history
… python3 env.
  • Loading branch information
ZhaoQiang committed Nov 30, 2018
1 parent 97565d0 commit 6167700
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
5 changes: 5 additions & 0 deletions configure.ac
Expand Up @@ -82,6 +82,11 @@ AC_PATH_PROG(ENV_IBUS_TEST, env)
AC_SUBST(ENV_IBUS_TEST)

# check python
AC_ARG_WITH(python,
AS_HELP_STRING([--with-python[=PATH]],
[Select python2 or python3]),
[PYTHON=$with_python], []
)
AM_PATH_PYTHON([2.5])

# --enable-boost
Expand Down
2 changes: 1 addition & 1 deletion setup/ibus-setup-pinyin.in
Expand Up @@ -26,5 +26,5 @@ export IBUS_PREFIX=@prefix@
export IBUS_DATAROOTDIR=@datarootdir@
export IBUS_LOCALEDIR=@localedir@
cd @prefix@/share/ibus-pinyin/setup/
exec python main.py $@
exec @PYTHON@ main.py $@

18 changes: 12 additions & 6 deletions setup/main.py
Expand Up @@ -20,15 +20,21 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

from __future__ import print_function

import gettext
import locale
import os
import sys

from gi import require_version as gi_require_version
gi_require_version('GLib', '2.0')
gi_require_version('Gtk', '3.0')
gi_require_version('IBus', '1.0')

from gi.repository import GLib
from gi.repository import Gtk
from gi.repository import IBus
from xdg import BaseDirectory

import version

Expand Down Expand Up @@ -250,8 +256,8 @@ def __init_correct_pinyin(self):

def __correct_pinyin_toggled_cb(widget):
val = widget.get_active()
map(lambda w: self.__builder.get_object(w[0]).set_sensitive(val),
self.__correct_pinyin_widgets)
for w in self.__correct_pinyin_widgets:
self.__builder.get_object(w[0]).set_sensitive(val)
self.__correct_pinyin.connect("toggled", __correct_pinyin_toggled_cb)

# init value
Expand Down Expand Up @@ -300,8 +306,8 @@ def __init_fuzzy(self):

def __fuzzy_pinyin_toggled_cb(widget):
val = widget.get_active()
map(lambda w: self.__builder.get_object(w[0]).set_sensitive(val),
self.__fuzzy_pinyin_widgets)
for w in self.__fuzzy_pinyin_widgets:
self.__builder.get_object(w[0]).set_sensitive(val)
self.__fuzzy_pinyin.connect("toggled", __fuzzy_pinyin_toggled_cb)

# init value
Expand Down Expand Up @@ -404,7 +410,7 @@ def __set_value(self, name, val):
elif isinstance(val, str):
var = GLib.Variant.new_string(val)
else:
print >> sys.stderr, "val(%s) is not in support type." % repr(val)
print("val(%s) is not in support type." % repr(val), file=sys.stderr)
return

self.__values[name] = val
Expand Down

0 comments on commit 6167700

Please sign in to comment.