diff --git a/ibus-pinyin.spec.in b/ibus-pinyin.spec.in index 4e02b07..ade89f5 100644 --- a/ibus-pinyin.spec.in +++ b/ibus-pinyin.spec.in @@ -16,7 +16,6 @@ BuildRequires: libtool BuildRequires: pkgconfig BuildRequires: sqlite-devel BuildRequires: libuuid-devel -BuildRequires: boost-devel >= 1.39 BuildRequires: ibus-devel >= 1.3 # Requires(post): sqlite @@ -52,7 +51,11 @@ The phrase database for ibus Pinyin and Bopomofo from android project. cp %{SOURCE1} data/db/open-phrase %build -%configure --disable-static --enable-db-open-phrase +%configure \ + --disable-static \ + --enable-db-open-phrase \ + --disable-english-input-mode \ + --disable-lua-extension # make -C po update-gmo make %{?_smp_mflags} diff --git a/setup/ibus-pinyin-preferences.ui b/setup/ibus-pinyin-preferences.ui index febe032..6388006 100644 --- a/setup/ibus-pinyin-preferences.ui +++ b/setup/ibus-pinyin-preferences.ui @@ -1,26 +1,68 @@ - + + 1 + 11 + 1 + 1 + 1 + 1 + 400 + False 5 Preferences center-always gtk-preferences normal - + True + False + vertical 2 + + + True + False + end + + + gtk-close + True + True + True + True + True + True + True + False + True + + + False + False + 0 + + + + + False + True + end + 0 + + True True - 3 True + False 12 12 12 @@ -28,20 +70,24 @@ True + False 18 True + False 0 none True + False 6 12 True + False 4 3 12 @@ -50,6 +96,7 @@ True + False 0 Language: @@ -57,6 +104,7 @@ True + False 0 Half/full width: @@ -68,6 +116,7 @@ True + False 0 Punctuations: @@ -82,6 +131,7 @@ True True False + False True InitEnglish @@ -96,6 +146,7 @@ True True False + False True True @@ -110,6 +161,7 @@ True True False + False True InitHalf @@ -126,6 +178,7 @@ True True False + False True True @@ -142,6 +195,7 @@ True True False + False True InitHalfPunct @@ -158,6 +212,7 @@ True True False + False True True @@ -171,6 +226,7 @@ True + False 0 Chinese: @@ -185,6 +241,7 @@ True True False + False True InitTraditionalChinese @@ -201,6 +258,7 @@ True True False + False True True @@ -218,6 +276,7 @@ True + False <b>Initial state</b> True @@ -232,61 +291,83 @@ True + False 0 none True + False 6 12 True + False 6 True + False 12 True True + False 0 Orientation of candidates: True + True + True 0 True + False liststoreLookupTableOrientation on + + + + 0 + + + True + True 1 + True + True 0 True + False 12 True True + False 0 Number of candidates: True + True + True 0 @@ -294,17 +375,20 @@ True True - delayed LookupTablePageSize 0 left + True + True 1 + True + True 1 @@ -315,6 +399,7 @@ True + False <b>UI</b> True @@ -333,6 +418,7 @@ True + False General @@ -342,6 +428,7 @@ True + False 12 12 12 @@ -349,24 +436,29 @@ True + False 18 True + False 0 none True + False 6 12 True + False 6 True + False 6 True @@ -375,17 +467,20 @@ True True False + False True DoublePinyin False + True 0 True + False 6 @@ -393,11 +488,13 @@ True True False + False True True False + True 0 @@ -405,21 +502,33 @@ True False + False liststoreDoublePinyin on + + + + 0 + + + True + True 1 False + True 1 + True + True 0 @@ -429,9 +538,12 @@ True True False + False True + True + True 1 @@ -441,10 +553,13 @@ True True False + False True True + True + True 2 @@ -455,6 +570,7 @@ True + False <b>Pinyin mode</b> True @@ -462,26 +578,31 @@ False + True 0 True + False 0 none True + False 6 12 True + False 6 True + False 2 2 6 @@ -493,6 +614,7 @@ True True False + False True @@ -502,6 +624,7 @@ True True False + False True True @@ -516,6 +639,7 @@ True True False + False True True @@ -530,6 +654,7 @@ True True False + False True @@ -541,6 +666,8 @@ + True + True 0 @@ -551,6 +678,7 @@ True + False <b>Input Custom</b> True @@ -558,22 +686,26 @@ False + True 1 True + False 0 none True + False 6 12 True + False 6 2 6 @@ -584,6 +716,7 @@ True True False + False True True @@ -598,6 +731,7 @@ True True False + False True True @@ -612,6 +746,7 @@ True True False + False True True @@ -626,6 +761,7 @@ True True False + False True True @@ -642,6 +778,7 @@ True True False + False True True @@ -658,6 +795,7 @@ True True False + False True True @@ -674,6 +812,7 @@ True True False + False True True @@ -689,6 +828,7 @@ True True False + False True True @@ -702,6 +842,7 @@ True True False + False True True @@ -720,12 +861,15 @@ True + False <b>Correct pinyin</b> True + True + True 2 @@ -739,6 +883,7 @@ True + False Pinyin mode @@ -749,6 +894,7 @@ True + False 12 12 12 @@ -756,20 +902,24 @@ True + False 18 True + False 0 none True + False 6 12 True + False 6 @@ -777,38 +927,56 @@ True True False + False True True + True + True 0 True + False True + False 0 Keyboard Mapping: + True + True 0 True + False liststoreBopomofoKeyboardMapping on + + + + 0 + + + True + True 1 + True + True 1 @@ -819,6 +987,7 @@ True + False <b>Bopomofo mode</b> True @@ -833,42 +1002,60 @@ True + False 0 none True + False 6 12 True + False 6 True + False True + False 0 Selection Keys: + True + True 0 True + False liststoreSelectionKeys on + + + + 0 + + + True + True 1 + True + True 0 @@ -878,10 +1065,13 @@ True True False + False True True + True + True 1 @@ -891,10 +1081,13 @@ True True False + False True True + True + True 2 @@ -904,10 +1097,13 @@ True True False + False True True + True + True 3 @@ -918,6 +1114,7 @@ True + False <b>Selection mode</b> True @@ -932,24 +1129,30 @@ True + False 0 none True + False 6 12 True + False 6 True + False 0 Feature of Enter key: + True + True 0 @@ -959,11 +1162,14 @@ True True False + False True True CommitOriginalText + True + True 1 @@ -973,9 +1179,12 @@ True True False + False True + True + True 2 @@ -986,6 +1195,7 @@ True + False <b>Other</b> True @@ -1007,6 +1217,7 @@ True + False Bopomofo mode @@ -1017,6 +1228,7 @@ True + False 12 12 12 @@ -1024,15 +1236,18 @@ True + False 12 True + False 6 12 True + False 12 2 6 @@ -1045,6 +1260,7 @@ False True False + False True True @@ -1060,6 +1276,7 @@ False True False + False True True @@ -1075,6 +1292,7 @@ False True False + False True True @@ -1090,6 +1308,7 @@ False True False + False True True @@ -1105,6 +1324,7 @@ False True False + False True True @@ -1120,6 +1340,7 @@ False True False + False True @@ -1134,6 +1355,7 @@ False True False + False True True @@ -1149,6 +1371,7 @@ False True False + False True True @@ -1164,6 +1387,7 @@ False True False + False True True @@ -1179,6 +1403,7 @@ False True False + False True True @@ -1194,6 +1419,7 @@ False True False + False True @@ -1210,6 +1436,7 @@ False True False + False True @@ -1226,6 +1453,7 @@ False True False + False True @@ -1242,6 +1470,7 @@ False True False + False True @@ -1258,6 +1487,7 @@ False True False + False True @@ -1274,6 +1504,7 @@ False True False + False True @@ -1290,6 +1521,7 @@ False True False + False True @@ -1306,6 +1538,7 @@ False True False + False True @@ -1322,6 +1555,7 @@ False True False + False True @@ -1338,6 +1572,7 @@ False True False + False True @@ -1353,6 +1588,7 @@ True True False + False True @@ -1369,6 +1605,8 @@ + True + True 0 @@ -1382,6 +1620,7 @@ True + False Fuzzy syllable @@ -1392,6 +1631,7 @@ True + False 12 12 12 @@ -1399,23 +1639,28 @@ True + False True + False 0 none True + False 6 12 True + False 6 True + False 12 @@ -1423,10 +1668,12 @@ True True False + False True False + True 0 @@ -1436,6 +1683,7 @@ True True True + False False @@ -1457,12 +1705,15 @@ True + False <b>Dictionary option</b> True + True + True 0 @@ -1476,6 +1727,7 @@ True + False Dictionary @@ -1486,6 +1738,7 @@ True + False 12 12 12 @@ -1493,10 +1746,12 @@ True + False 6 True + False 6 @@ -1506,39 +1761,50 @@ gtk-about + True + True 0 True + False <big><b>IBus Pinyin %s</b></big> True True + True + True 1 True + False Pinyin input method for IBus True + True + True 2 True + False <small>Copyright (c) 2009-2010 Peng Huang</small> True True True + True + True 3 @@ -1548,6 +1814,7 @@ True True True + False none http://ibus.googlecode.com @@ -1560,6 +1827,7 @@ True + False <small> <b>Authors:</b> Peng Huang @@ -1574,11 +1842,14 @@ koterpilla, Zerng07 True + True + True 5 + True False 0 @@ -1593,6 +1864,7 @@ koterpilla, Zerng07 True + False About @@ -1601,37 +1873,10 @@ koterpilla, Zerng07 - - 1 - - - - - True - end - - - gtk-close - True - True - True - True - True - True - True - True - - - False - False - 0 - - - False - end - 0 + True + 1 @@ -1640,6 +1885,26 @@ koterpilla, Zerng07 buttonClose + + + + + + + + Standard + + + GinYieh + + + Eten + + + IBM + + + @@ -1666,14 +1931,6 @@ koterpilla, Zerng07 - - 1 - 1 - 11 - 1 - 1 - 1 - @@ -1688,26 +1945,6 @@ koterpilla, Zerng07 - - - - - - - - Standard - - - GinYieh - - - Eten - - - IBM - - - diff --git a/setup/main.py b/setup/main.py index 0e3a729..3d97645 100644 --- a/setup/main.py +++ b/setup/main.py @@ -19,34 +19,39 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import sys -import gtk -import ibus + +import gettext import locale import os -import version -import gettext +import sys + +from gi.repository import GLib +from gi.repository import Gtk +from gi.repository import IBus from xdg import BaseDirectory +import version + _ = lambda a : gettext.dgettext("ibus-pinyin", a) class PreferencesDialog: - def __init__(self,engine): + def __init__(self, engine): locale.setlocale(locale.LC_ALL, "") localedir = os.getenv("IBUS_LOCALEDIR") gettext.bindtextdomain("ibus-pinyin", localedir) gettext.bind_textdomain_codeset("ibus-pinyin", "UTF-8") - self.__bus = ibus.Bus() + self.__bus = IBus.Bus() self.__config = self.__bus.get_config() - self.__builder = gtk.Builder() + self.__builder = Gtk.Builder() self.__builder.set_translation_domain("ibus-pinyin") self.__builder.add_from_file("ibus-pinyin-preferences.ui") self.__dialog = self.__builder.get_object("dialog") self.__init_pages() - + if engine == "pinyin": self.__config_namespace = "engine/Pinyin" + self.__values = dict(self.__config.get_values(self.__config_namespace)) self.__init_general() self.__init_pinyin() self.__init_fuzzy() @@ -54,17 +59,17 @@ def __init__(self,engine): self.__init_about() elif engine == "bopomofo": self.__config_namespace = "engine/Bopomofo" + self.__values = dict(self.__config.get_values(self.__config_namespace)) self.__init_general() self.__init_bopomofo() self.__init_fuzzy() self.__init_dictionary() self.__init_about() self.__convert_fuzzy_pinyin_to_bopomofo() - else: print("Error: Unknown Engine") exit() - + self.__pages.set_current_page(0) def __init_pages(self): @@ -75,7 +80,7 @@ def __init_pages(self): self.__page_fuzzy = self.__builder.get_object("pageFuzzy") self.__page_dictionary = self.__builder.get_object("pageDictionary") self.__page_about = self.__builder.get_object("pageAbout") - + self.__page_general.hide() self.__page_pinyin_mode.hide() self.__page_bopomofo_mode.hide() @@ -86,7 +91,7 @@ def __init_pages(self): def __init_general(self): # page General self.__page_general.show() - + # init state self.__init_chinese = self.__builder.get_object("InitChinese") self.__init_english = self.__builder.get_object("InitEnglish") @@ -96,13 +101,10 @@ def __init_general(self): self.__init_half_punct = self.__builder.get_object("InitHalfPunct") self.__init_simp = self.__builder.get_object("InitSimplifiedChinese") self.__init_trad = self.__builder.get_object("IniTraditionalChinese") - + # UI self.__lookup_table_page_size = self.__builder.get_object("LookupTablePageSize") self.__lookup_table_orientation = self.__builder.get_object("LookupTableOrientation") - renderer = gtk.CellRendererText() - self.__lookup_table_orientation.pack_start(renderer) - self.__lookup_table_orientation.set_attributes(renderer, text=0) # read values self.__init_chinese.set_active(self.__get_value("InitChinese", True)) @@ -130,7 +132,7 @@ def __lookup_table_orientation_changed_cb(widget): def __init_pinyin(self): # page self.__page_pinyin_mode.show() - + # pinyin self.__full_pinyin = self.__builder.get_object("FullPinyin") self.__incomplete_pinyin = self.__builder.get_object("IncompletePinyin") @@ -139,10 +141,6 @@ def __init_pinyin(self): # self.__double_pinyin_schema_label = self.__builder.get_object("labelDoublePinyinSchema") self.__double_pinyin_show_raw = self.__builder.get_object("DoublePinyinShowRaw") - renderer = gtk.CellRendererText() - self.__double_pinyin_schema.pack_start(renderer) - self.__double_pinyin_schema.set_attributes(renderer, text=0) - # read value self.__incomplete_pinyin.set_active(self.__get_value("IncompletePinyin", True)) self.__full_pinyin.set_active(not self.__get_value("DoublePinyin", False)) @@ -173,25 +171,20 @@ def __double_pinyin_schema_changed_cb(widget): self.__incomplete_pinyin.connect("toggled", self.__toggled_cb, "IncompletePinyin") self.__double_pinyin_schema.connect("changed", __double_pinyin_schema_changed_cb) self.__double_pinyin_show_raw.connect("toggled", self.__toggled_cb, "DoublePinyinShowRaw") - + self.__init_input_custom() self.__init_correct_pinyin() - + def __init_bopomofo(self): # page Bopomodo Mode self.__page_bopomofo_mode.show() - + # bopomofo mode self.__incomplete_bopomofo = self.__builder.get_object("IncompleteBopomofo") self.__bopomofo_keyboard_mapping = self.__builder.get_object("BopomofoKeyboardMapping") - renderer = gtk.CellRendererText() - self.__bopomofo_keyboard_mapping.pack_start(renderer) - self.__bopomofo_keyboard_mapping.set_attributes(renderer, text=0) - + # selection mode self.__select_keys = self.__builder.get_object("SelectKeys") - self.__select_keys.pack_start(renderer) - self.__select_keys.set_attributes(renderer, text=0) self.__guide_key = self.__builder.get_object("GuideKey") self.__auxiliary_select_key_f = self.__builder.get_object("AuxiliarySelectKey_F") self.__auxiliary_select_key_kp = self.__builder.get_object("AuxiliarySelectKey_KP") @@ -213,7 +206,7 @@ def __bopomofo_keyboard_mapping_changed_cb(widget): self.__set_value("BopomofoKeyboardMapping", widget.get_active()) def __select_keys_changed_cb(widget): self.__set_value("SelectKeys", widget.get_active()) - + self.__bopomofo_keyboard_mapping.connect("changed", __bopomofo_keyboard_mapping_changed_cb) self.__incomplete_bopomofo.connect("toggled", self.__toggled_cb, "IncompletePinyin") self.__select_keys.connect("changed", __select_keys_changed_cb) @@ -275,7 +268,7 @@ def __correct_pinyin_toggled_cb(widget): def __init_fuzzy(self): # page Fuzzy self.__page_fuzzy.show() - + # fuzzy pinyin self.__fuzzy_pinyin = self.__builder.get_object("FuzzyPinyin") self.__fuzzy_pinyin_widgets = [ @@ -357,7 +350,7 @@ def __convert_fuzzy_pinyin_to_bopomofo(self): def __init_dictionary(self): # page Dictionary self.__page_dictionary.show() - + # dictionary self.__special_phrases = self.__builder.get_object("SpecialPhrases") self.__edit_special_phrases = self.__builder.get_object("EditSpecialPhrases") @@ -384,7 +377,7 @@ def __edit_special_phrases_clicked_cb(widget): def __init_about(self): # page About self.__page_about.show() - + self.__name_version = self.__builder.get_object("NameVersion") self.__name_version.set_markup(_("IBus Pinyin %s") % version.get_version()) @@ -395,14 +388,27 @@ def __toggled_cb(self, widget, name): self.__set_value(name, widget.get_active ()) def __get_value(self, name, defval): - value = self.__config.get_value(self.__config_namespace, name, "test_default_value_9898") - if value != "test_default_value_9898": - return value + if name in self.__values: + var = self.__values[name] + if isinstance(defval, type(var)): + return var self.__set_value(name, defval) return defval def __set_value(self, name, val): - self.__config.set_value(self.__config_namespace, name, val) + var = None + if isinstance(val, bool): + var = GLib.Variant.new_boolean(val) + elif isinstance(val, int): + var = GLib.Variant.new_int32(val) + elif isinstance(val, str): + var = GLib.Variant.new_string(val) + else: + print >> sys.stderr, "val(%s) is not in support type." % repr(val) + return + + self.__values[name] = val + self.__config.set_value(self.__config_namespace, name, var) def run(self): return self.__dialog.run()