diff options
| author | ZhaoQiang <qzhao@suse.com> | 2025-08-12 20:51:27 +0800 |
|---|---|---|
| committer | Peng Wu <alexepico@gmail.com> | 2025-08-25 15:35:23 +0800 |
| commit | 0e9bebe762778c9b0daef5aa6d9ab4606f42a9c3 (patch) | |
| tree | af5f9fd447ee23c77fc9bfb0188b58ab6b199ac4 | |
| parent | 700b91d115f7f824824b543241bf1b931e4cec13 (diff) | |
| download | ibus-libpinyin-0e9bebe762778c9b0daef5aa6d9ab4606f42a9c3.tar.gz ibus-libpinyin-0e9bebe762778c9b0daef5aa6d9ab4606f42a9c3.tar.xz ibus-libpinyin-0e9bebe762778c9b0daef5aa6d9ab4606f42a9c3.zip | |
Make libpinyin setup could response build config
| -rw-r--r-- | configure.ac | 17 | ||||
| -rw-r--r-- | setup/Makefile.am | 3 | ||||
| -rw-r--r-- | setup/config.py.in | 9 | ||||
| -rw-r--r-- | setup/ibus-libpinyin-preferences.ui | 89 | ||||
| -rw-r--r-- | setup/main2.py | 128 |
5 files changed, 117 insertions, 129 deletions
diff --git a/configure.ac b/configure.ac index 44bb868..303977d 100644 --- a/configure.ac +++ b/configure.ac @@ -165,6 +165,7 @@ AC_ARG_ENABLE(lua-extension, ) # check lua +LUA_EXTENSION="False" PKG_CHECK_MODULES(LUA, [ lua >= 5.1 ], [], @@ -179,8 +180,11 @@ then [enable_lua_extension=no] ); fi - AM_CONDITIONAL(IBUS_BUILD_LUA_EXTENSION, [test x"$enable_lua_extension" = x"yes"]) +if test x"$enable_lua_extension" = x"yes"; then + LUA_EXTENSION="True" +fi +AC_SUBST(LUA_EXTENSION) # --enable-cloud-input-mode CLOUD_INPUT_MODE="False" @@ -207,6 +211,7 @@ AM_CONDITIONAL(ENABLE_CLOUD_INPUT_MODE, test x"$enable_cloud_input_mode" = x"yes AC_SUBST(CLOUD_INPUT_MODE) # --disable-english-input-mode +ENGLISH_INPUT_MODE="False" AC_ARG_ENABLE(english-input-mode, AS_HELP_STRING([--disable-english-input-mode], [do not build english input mode]), @@ -215,16 +220,24 @@ AC_ARG_ENABLE(english-input-mode, ) AM_CONDITIONAL(IBUS_BUILD_ENGLISH_INPUT_MODE, [test x"$enable_english_input_mode" = x"yes"]) +if test x"$enable_english_input_mode" = x"yes"; then + ENGLISH_INPUT_MODE="True" +fi +AC_SUBST(ENGLISH_INPUT_MODE) # --disable-table-input-mode +TABLE_INPUT_MODE="False" AC_ARG_ENABLE(table-input-mode, AS_HELP_STRING([--disable-table-input-mode], [do not build table input mode]), [enable_table_input_mode=$enableval], [enable_table_input_mode=yes] ) - AM_CONDITIONAL(IBUS_BUILD_TABLE_INPUT_MODE, [test x"$enable_table_input_mode" = x"yes"]) +if test x"$enable_table_input_mode" = x"yes"; then + TABLE_INPUT_MODE="True" +fi +AC_SUBST(TABLE_INPUT_MODE) # --disable-libnotify AC_ARG_ENABLE(libnotify, diff --git a/setup/Makefile.am b/setup/Makefile.am index d14e62e..5798916 100644 --- a/setup/Makefile.am +++ b/setup/Makefile.am @@ -35,6 +35,9 @@ libexec_SCRIPTS = \ CLEANFILES = \ *.pyc \ + config.py \ + Makefile.in \ + Makefile \ $(NULL) EXTRA_DIST = \ diff --git a/setup/config.py.in b/setup/config.py.in index c5b858a..a1bfa07 100644 --- a/setup/config.py.in +++ b/setup/config.py.in @@ -31,3 +31,12 @@ def get_longname(): def support_cloud_input(): return @CLOUD_INPUT_MODE@ + +def enable_lua_extension(): + return @LUA_EXTENSION@ + +def enable_table_mode(): + return @TABLE_INPUT_MODE@ + +def enable_english_input_mode(): + return @ENGLISH_INPUT_MODE@ diff --git a/setup/ibus-libpinyin-preferences.ui b/setup/ibus-libpinyin-preferences.ui index 214e3a4..fefa833 100644 --- a/setup/ibus-libpinyin-preferences.ui +++ b/setup/ibus-libpinyin-preferences.ui @@ -2263,7 +2263,7 @@ <property name="orientation">vertical</property> <property name="spacing">16</property> <child> - <object class="GtkFrame"> + <object class="GtkFrame" id="frameInputModes"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="label-xalign">0</property> @@ -2274,96 +2274,11 @@ <property name="can-focus">False</property> <property name="left-padding">12</property> <child> - <!-- n-columns=2 n-rows=3 --> - <object class="GtkGrid"> + <object class="GtkGrid" id="gridInputModes"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="row-homogeneous">True</property> <property name="column-homogeneous">True</property> - <child> - <object class="GtkCheckButton" id="LuaExtension"> - <property name="label" translatable="yes">Lua Extension</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="halign">start</property> - <property name="draw-indicator">True</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="TableMode"> - <property name="label" translatable="yes">Table Mode</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="halign">start</property> - <property name="draw-indicator">True</property> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="EnglishMode"> - <property name="label" translatable="yes">English Mode</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="halign">start</property> - <property name="draw-indicator">True</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="EnglishCandidate"> - <property name="label" translatable="yes">English Candidate</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="halign">start</property> - <property name="draw-indicator">True</property> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="EmojiCandidate"> - <property name="label" translatable="yes">Emoji Candidate</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="halign">start</property> - <property name="draw-indicator">True</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">2</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="SuggestionCandidate"> - <property name="label" translatable="yes">Suggestion Candidate</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="xalign">0</property> - <property name="draw-indicator">True</property> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">2</property> - </packing> - </child> </object> </child> </object> diff --git a/setup/main2.py b/setup/main2.py index 47796b6..4d867a7 100644 --- a/setup/main2.py +++ b/setup/main2.py @@ -420,52 +420,100 @@ class PreferencesDialog: def __init_user_data(self): #page User Data self.__page_user_data.show() + self.__frame_input_modes = self.__builder.get_object("frameInputModes") + grid = self.__builder.get_object("gridInputModes") - self.__frame_lua_script = self.__builder.get_object("frameLuaScript") path = os.path.join(pkgdatadir, 'user.lua') - if not os.access(path, os.R_OK): - self.__frame_lua_script.hide() - self.__frame_user_table = self.__builder.get_object("frameUserTable") - self.__lua_extension = self.__builder.get_object("LuaExtension") - self.__table_mode = self.__builder.get_object("TableMode") - self.__english_mode = self.__builder.get_object("EnglishMode") - self.__emoji_candidate = self.__builder.get_object("EmojiCandidate") - self.__english_candidate = self.__builder.get_object("EnglishCandidate") - self.__suggestion_candidate = self.__builder.get_object("SuggestionCandidate") - self.__import_table = self.__builder.get_object("ImportTable") - self.__export_table = self.__builder.get_object("ExportTable") - self.__clear_user_table = self.__builder.get_object("ClearUserTable") - self.__edit_lua = self.__builder.get_object("EditLua") - self.__import_dictionary = self.__builder.get_object("ImportDictionary") - self.__export_dictionary = self.__builder.get_object("ExportDictionary") - self.__clear_user_data = self.__builder.get_object("ClearUserDictionary") - self.__clear_all_data = self.__builder.get_object("ClearAllDictionary") + if os.access(path, os.R_OK): + lua_visible = config.enable_lua_extension() + else: + lua_visible = False + + input_mode_buttons = [ +# obj_id, label, visible; + ("lua_extension", "Lua Extension", lua_visible), + ("table_mode", "Table Mode", config.enable_table_mode()), + ("english_mode", "English Mode", config.enable_english_input_mode()), + ("english_candidate", "English Candidate", True), + ("emoji_candidate", "Emoji Candidate", True), + ("suggestion_candidate", "Suggestion Candidate", True), + ] - # read values - self.__frame_lua_script.set_sensitive(self.__get_value("lua-extension")) - self.__frame_user_table.set_sensitive(self.__get_value("table-input-mode")) - self.__lua_extension.set_active(self.__get_value("lua-extension")) - self.__table_mode.set_active(self.__get_value("table-input-mode")) - self.__english_mode.set_active(self.__get_value("english-input-mode")) - self.__emoji_candidate.set_active(self.__get_value("emoji-candidate")) - self.__english_candidate.set_active(self.__get_value("english-candidate")) - self.__suggestion_candidate.set_active(self.__get_value("suggestion-candidate")) + row = 0 + col = 0 + self.input_mode_buttons = {} + for obj_id, label, visible in input_mode_buttons: + if not visible: + continue + else: + # Button initial: + button = Gtk.CheckButton(label=label) + button.set_name(obj_id) + button.set_visible(True) + button.set_can_focus(True) + button.set_receives_default(False) + button.set_halign(Gtk.Align.START) + grid.attach(button, col, row, 1, 1) + setattr(self, obj_id, button) + self.obj_id = button + + # Read button value and set connect signal: + if obj_id == "lua_extension": + self.lua_extension.set_active(self.__get_value("lua-extension")) + self.lua_extension.connect("toggled", self.__lua_extension_cb) + elif obj_id == "table_mode": + self.table_mode.set_active(self.__get_value("table-input-mode")) + self.table_mode.connect("toggled", self.__table_mode_cb) + elif obj_id == "english_mode": + self.english_mode.set_active(self.__get_value("english-input-mode")) + self.english_mode.connect("toggled", self.__english_mode_cb) + elif obj_id == "english_candidate": + self.english_candidate.set_active(self.__get_value("english-candidate")) + self.english_candidate.connect("toggled", self.__toggled_cb, "english-candidate") + elif obj_id == "emoji_candidate": + self.emoji_candidate.set_active(self.__get_value("emoji-candidate")) + self.emoji_candidate.connect("toggled", self.__toggled_cb, "emoji-candidate") + elif obj_id == "suggestion_candidate": + self.suggestion_candidate.set_active(self.__get_value("suggestion-candidate")) + self.suggestion_candidate.connect("toggled", self.__toggled_cb, "suggestion-candidate") + + # Move to the next button position: + col += 1 + if col > 1: + col = 0 + row += 1 - # connect signals - self.__lua_extension.connect("toggled", self.__lua_extension_cb) - self.__table_mode.connect("toggled", self.__table_mode_cb) - self.__english_mode.connect("toggled", self.__english_mode_cb) - self.__emoji_candidate.connect("toggled", self.__toggled_cb, "emoji-candidate") - self.__english_candidate.connect("toggled", self.__toggled_cb, "english-candidate") - self.__suggestion_candidate.connect("toggled", self.__toggled_cb, "suggestion-candidate") - self.__edit_lua.connect("clicked", self.__edit_lua_cb) - self.__import_dictionary.connect("clicked", self.__import_dictionary_cb, "import-dictionary") + self.__frame_lua_script = self.__builder.get_object("frameLuaScript") + if lua_visible: + if self.__get_value("lua-extension"): + self.__edit_lua = self.__builder.get_object("EditLua") + self.__edit_lua.connect("clicked", self.__edit_lua_cb) + else: + self.__frame_lua_script.set_sensitive(False) + else: + self.__frame_lua_script.hide() + + self.__frame_user_dictionary = self.__builder.get_object("frameUserDictionary") + self.__export_dictionary = self.__builder.get_object("ExportDictionary") self.__export_dictionary.connect("clicked", self.__export_dictionary_cb, "export-dictionary") - self.__clear_user_data.connect("clicked", self.__clear_user_data_cb, "user") + self.__import_dictionary = self.__builder.get_object("ImportDictionary") + self.__import_dictionary.connect("clicked", self.__import_dictionary_cb, "import-dictionary") + self.__clear_all_data = self.__builder.get_object("ClearAllDictionary") self.__clear_all_data.connect("clicked", self.__clear_user_data_cb, "all") - self.__import_table.connect("clicked", self.__import_table_cb, "import-custom-table") - self.__export_table.connect("clicked", self.__export_table_cb, "export-custom-table") - self.__clear_user_table.connect("clicked", self.__clear_user_table_cb, "clear-custom-table", "user") + self.__clear_user_data = self.__builder.get_object("ClearUserDictionary") + self.__clear_user_data.connect("clicked", self.__clear_user_data_cb, "user") + + self.__frame_user_table = self.__builder.get_object("frameUserTable") + if not config.enable_table_mode(): + self.__frame_user_table.hide() + else: + self.__frame_user_table.set_sensitive(config.enable_table_mode()) + self.__export_table = self.__builder.get_object("ExportTable") + self.__export_table.connect("clicked", self.__export_table_cb, "export-custom-table") + self.__import_table = self.__builder.get_object("ImportTable") + self.__import_table.connect("clicked", self.__import_table_cb, "import-custom-table") + self.__clear_user_table = self.__builder.get_object("ClearUserTable") + self.__clear_user_table.connect("clicked", self.__clear_user_table_cb, "clear-custom-table", "user") def __lua_extension_cb(self, widget): self.__set_value("lua-extension", widget.get_active()) |
