Skip to content

Commit

Permalink
Merge pull request #185 from chewing/fix-trayicon
Browse files Browse the repository at this point in the history
Use IBus systray icon for both engine icon and input mode icon
  • Loading branch information
kanru authored Feb 10, 2024
2 parents 7091399 + 7936c02 commit 22fb470
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ add_compile_definitions(
)

# chewing.xml
set(ICON_PROP_KEY "<icon_prop_key>InputMode</icon_prop_key>")
set(SYMBOL_XML "<symbol>&#x9177;</symbol>")
set(CHEWING_HOTKEYS "Super+space")
set(HOTKEYS_XML "<hotkeys>${CHEWING_HOTKEYS}</hotkeys>")
set(SETUP_PROGRAM_XML "<setup>${CMAKE_INSTALL_FULL_LIBEXECDIR}/ibus-setup-chewing</setup>")

if(IBUS_VERSION LESS 1.5.11)
set(ICON_PROP_KEY "<!-- ${ICON_PROP_KEY} -->")
endif()
if(IBUS_VERSION LESS 1.3.99)
set(SYMBOL_XML "<!-- ${SYMBOL_XML} -->")
set(HOTKEYS_XML "<!-- ${HOTKEYS_XML} -->")
Expand Down
29 changes: 15 additions & 14 deletions data/chewing.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@
<textdomain>ibus-chewing</textdomain>
<engines>
<engine>
<name>chewing</name>
<longname>Chewing</longname>
<description>Chinese chewing input method</description>
<language>zh_TW</language>
<license>GPLv2+</license>
<author>Peng Huang, Ding-Yi Chen</author>
<icon>@PRJ_DATA_DIR@/icons/@PROJECT_NAME@.png</icon>
<layout>us</layout>
<version>@PRJ_VER@</version>
<textdomain>@PROJECT_NAME@</textdomain>
<rank>80</rank>
@HOTKEYS_XML@
@SYMBOL_XML@
@SETUP_PROGRAM_XML@
<name>chewing</name>
<longname>Chewing</longname>
<description>Chinese chewing input method</description>
<language>zh_TW</language>
<license>GPLv2+</license>
<author>Peng Huang, Ding-Yi Chen</author>
<icon>@PRJ_DATA_DIR@/icons/@PROJECT_NAME@.png</icon>
<layout>us</layout>
<version>@PRJ_VER@</version>
<textdomain>@PROJECT_NAME@</textdomain>
<rank>80</rank>
@ICON_PROP_KEY@
@HOTKEYS_XML@
@SYMBOL_XML@
@SETUP_PROGRAM_XML@
</engine>
</engines>
</component>
Expand Down
57 changes: 51 additions & 6 deletions po/ibus-setup-chewing.pot → po/ibus-chewing.pot
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Copyright (C) 2024 Kan-Ru Chen
# This file is distributed under the same license as the ibus-setup-chewing package.
# Kan-Ru Chen <kanru@kanru.info>, 2024.
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: ibus-setup-chewing 2.0.0\n"
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-07 22:12+0900\n"
"POT-Creation-Date: 2024-02-10 09:15+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: src/setup/ibus-setup-chewing-window.ui:13
Expand Down Expand Up @@ -243,3 +244,47 @@ msgstr ""
#: src/setup/ibus-setup-chewing-window.ui:211
msgid "Choose from vertical or horizontal panel"
msgstr ""

#: src/main.c:67
msgid "Cannot connect to IBus!"
msgstr ""

#: src/main.c:94
msgid "Chewing"
msgstr ""

#: src/main.c:95
msgid "Chinese chewing input method"
msgstr ""

#: src/ibus-chewing-engine.c:340
msgid "Switch to Alphanumeric Mode"
msgstr ""

#: src/ibus-chewing-engine.c:342
msgid "Switch to Chinese Mode"
msgstr ""

#: src/ibus-chewing-engine.c:345
msgid "Click to toggle Chinese/Alphanumeric Mode"
msgstr ""

#: src/ibus-chewing-engine.c:351
msgid "Fullwidth Form"
msgstr ""

#: src/ibus-chewing-engine.c:353
msgid "Halfwidth Form"
msgstr ""

#: src/ibus-chewing-engine.c:356
msgid "Click to toggle Halfwidth/Fullwidth Form"
msgstr ""

#: src/ibus-chewing-engine.c:362
msgid "IBus-Chewing Preferences"
msgstr ""

#: src/ibus-chewing-engine.c:364
msgid "Click to configure IBus-Chewing"
msgstr ""
6 changes: 3 additions & 3 deletions src/ibus-chewing-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ ibus_chewing_engine_class_init(IBusChewingEngineClass *klass G_GNUC_UNUSED) {
GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass *)klass;
IBusEngineClass *ibus_engine_class = (IBusEngineClass *)klass;

klass->InputMode_label_chi =
g_object_ref_sink(ibus_text_new_from_static_string(_("Chinese Mode")));
klass->InputMode_label_chi = g_object_ref_sink(
ibus_text_new_from_static_string(_("Switch to Alphanumeric Mode")));
klass->InputMode_label_eng = g_object_ref_sink(
ibus_text_new_from_static_string(_("Alphanumeric Mode")));
ibus_text_new_from_static_string(_("Switch to Chinese Mode")));
klass->InputMode_tooltip =
g_object_ref_sink(ibus_text_new_from_static_string(
_("Click to toggle Chinese/Alphanumeric Mode")));
Expand Down
35 changes: 25 additions & 10 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,37 @@ static void start_component(void) {
component = ibus_component_new_from_file(
QUOTE_ME(DATA_DIR) "/ibus/component/chewing.xml");
} else {
// clang-format off
component = ibus_component_new(
QUOTE_ME(PROJECT_SCHEMA_ID), _("Chewing component"),
QUOTE_ME(PRJ_VER), "GPLv2+", _("Peng Huang, Ding-Yi Chen"),
"http://code.google.com/p/ibus",
QUOTE_ME(PROJECT_SCHEMA_ID),
"Chewing component",
QUOTE_ME(PRJ_VER),
"GPLv2+",
"Peng Huang, Ding-Yi Chen",
"https://github.com/chewing/ibus-chewing",
QUOTE_ME(LIBEXEC_DIR) "/ibus-engine-chewing --ibus",
QUOTE_ME(PROJECT_NAME));
QUOTE_ME(PROJECT_NAME)
);
// clang-format on
}

// clang-format off
IBusEngineDesc *engineDesc = ibus_engine_desc_new_varargs(
"name", "chewing", "longname", _("Chewing"), "description",
_("Chinese chewing input method"), "language", "zh_TW", "license",
"GPLv2+", "author", _("Peng Huang, Ding-Yi Chen"), "icon",
QUOTE_ME(PRJ_DATA_DIR) "/icons/" QUOTE_ME(PROJECT_NAME) ".png",
"layout", "us", "setup", QUOTE_ME(LIBEXEC_DIR) "/ibus-setup-chewing",
"version", QUOTE_ME(PRJ_VER), "textdomain", QUOTE_ME(PROJECT_NAME),
"name", "chewing",
"longname", _("Chewing"),
"description", _("Chinese chewing input method"),
"language", "zh_TW",
"license", "GPLv2+",
"author", "Peng Huang, Ding-Yi Chen",
"icon", QUOTE_ME(PRJ_DATA_DIR) "/icons/" QUOTE_ME(PROJECT_NAME) ".png",
"icon_prop_key", "InputMode",
"symbol", "&#x9177;",
"layout", "us",
"setup", QUOTE_ME(LIBEXEC_DIR) "/ibus-setup-chewing",
"version", QUOTE_ME(PRJ_VER),
"textdomain", QUOTE_ME(PROJECT_NAME),
NULL);
// clang-format on

ibus_component_add_engine(component, engineDesc);

Expand Down
2 changes: 0 additions & 2 deletions src/setup/ibus-setup-chewing-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ struct _IbusSetupChewingWindow {
AdwComboRow *kb_type;
AdwComboRow *sel_keys;
AdwSwitchRow *plain_zhuyin;
AdwSwitchRow *show_systray;
AdwSwitchRow *auto_shift_cur;
AdwSwitchRow *add_phrase_direction;
AdwSwitchRow *clean_buffer_focus_out;
Expand Down Expand Up @@ -60,7 +59,6 @@ ibus_setup_chewing_window_class_init(IbusSetupChewingWindowClass *klass) {
bind_child(kb_type);
bind_child(sel_keys);
bind_child(plain_zhuyin);
bind_child(show_systray);
bind_child(auto_shift_cur);
bind_child(add_phrase_direction);
bind_child(clean_buffer_focus_out);
Expand Down
8 changes: 0 additions & 8 deletions src/setup/ibus-setup-chewing-window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@
<property name="subtitle" translatable="yes">Enable or disable automatic candidate selection</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="show_systray">
<property name="title" translatable="yes">Show Systray Icon</property>
<property name="subtitle" translatable="yes">Whether to show the systray icon</property>
<property name="tooltip-text" translatable="yes">This feature is currently not implemented.</property>
<property name="sensitive">False</property>
</object>
</child>
</object>
</child>
<child>
Expand Down

0 comments on commit 22fb470

Please sign in to comment.