From 7028dc66b5ccda27d7acfc8e72df74d89f8b48e6 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sat, 15 Jun 2024 17:39:06 +0900 Subject: [PATCH 1/7] feat: Add about dialog in setup program --- po/ibus-chewing.pot | 157 ++++++++++++++----------- po/update-pot.sh | 7 ++ src/CMakeLists.txt | 4 +- src/setup/ibus-setup-chewing-about.c | 56 +++++++++ src/setup/ibus-setup-chewing-about.h | 25 ++++ src/setup/ibus-setup-chewing-window.c | 6 + src/setup/ibus-setup-chewing-window.ui | 17 ++- 7 files changed, 204 insertions(+), 68 deletions(-) create mode 100755 po/update-pot.sh create mode 100644 src/setup/ibus-setup-chewing-about.c create mode 100644 src/setup/ibus-setup-chewing-about.h diff --git a/po/ibus-chewing.pot b/po/ibus-chewing.pot index 6ab8ce1..cc88941 100644 --- a/po/ibus-chewing.pot +++ b/po/ibus-chewing.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-10 16:42+0900\n" +"POT-Creation-Date: 2024-06-15 17:36+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -21,262 +21,287 @@ msgstr "" msgid "Chewing Settings" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:13 +#: src/setup/ibus-setup-chewing-window.ui:14 msgid "Configure the input method" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:14 +#: src/setup/ibus-setup-chewing-window.ui:15 msgid "Input Method" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:20 +#: src/setup/ibus-setup-chewing-window.ui:18 +msgid "About" +msgstr "" + +#: src/setup/ibus-setup-chewing-window.ui:19 +#: src/setup/ibus-setup-chewing-about.c:42 +msgid "IBus Chewing" +msgstr "" + +#: src/setup/ibus-setup-chewing-window.ui:35 msgid "Standard" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:21 +#: src/setup/ibus-setup-chewing-window.ui:36 msgid "Hsu" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:22 +#: src/setup/ibus-setup-chewing-window.ui:37 msgid "IBM" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:23 +#: src/setup/ibus-setup-chewing-window.ui:38 msgid "Gin-Yieh" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:24 +#: src/setup/ibus-setup-chewing-window.ui:39 msgid "Eten" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:25 +#: src/setup/ibus-setup-chewing-window.ui:40 msgid "Eten 26" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:26 +#: src/setup/ibus-setup-chewing-window.ui:41 msgid "Dvorak" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:27 +#: src/setup/ibus-setup-chewing-window.ui:42 msgid "Dvorak-Hsu" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:28 +#: src/setup/ibus-setup-chewing-window.ui:43 msgid "DaChen 26" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:29 +#: src/setup/ibus-setup-chewing-window.ui:44 msgid "Hanyu Pinyin" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:30 +#: src/setup/ibus-setup-chewing-window.ui:45 msgid "THL Pinyin" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:31 +#: src/setup/ibus-setup-chewing-window.ui:46 msgid "MPS2 Pinyin" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:35 +#: src/setup/ibus-setup-chewing-window.ui:47 +msgid "Carpalx" +msgstr "" + +#: src/setup/ibus-setup-chewing-window.ui:48 +msgid "Colemak-DH ANSI" +msgstr "" + +#: src/setup/ibus-setup-chewing-window.ui:49 +msgid "Colemak-DH Ortholinear" +msgstr "" + +#: src/setup/ibus-setup-chewing-window.ui:53 msgid "Keyboard Type" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:54 +#: src/setup/ibus-setup-chewing-window.ui:72 msgid "Selection Keys" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:55 +#: src/setup/ibus-setup-chewing-window.ui:73 msgid "Keys used to select candidate" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:61 +#: src/setup/ibus-setup-chewing-window.ui:79 msgid "Intelligent Phrasing" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:62 +#: src/setup/ibus-setup-chewing-window.ui:80 msgid "Enable or disable automatic candidate selection" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:69 +#: src/setup/ibus-setup-chewing-window.ui:87 msgid "Editing" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:70 +#: src/setup/ibus-setup-chewing-window.ui:88 msgid "Configure the input method behavior" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:74 +#: src/setup/ibus-setup-chewing-window.ui:92 msgid "Auto Move Cursor" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:75 +#: src/setup/ibus-setup-chewing-window.ui:93 msgid "Automatically move the cursor to the next character after selection" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:81 +#: src/setup/ibus-setup-chewing-window.ui:99 msgid "Add Phrase Before Cursor" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:82 +#: src/setup/ibus-setup-chewing-window.ui:100 msgid "Use Ctrl + Numbers (2-9) to save new phrase before or after the cursor" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:88 +#: src/setup/ibus-setup-chewing-window.ui:106 msgid "Clear Pre-Edit Buffer When Focus Out" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:94 +#: src/setup/ibus-setup-chewing-window.ui:112 msgid "Easy Symbol Input" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:95 +#: src/setup/ibus-setup-chewing-window.ui:113 msgid "Press Shift + keys to input Chinese punctuation symbols" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:100 +#: src/setup/ibus-setup-chewing-window.ui:118 msgid "Esc Clean All Buffer" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:101 +#: src/setup/ibus-setup-chewing-window.ui:119 msgid "Escape key discards all uncommitted texts" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:114 +#: src/setup/ibus-setup-chewing-window.ui:132 msgid "Maximum Chinese Characters" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:115 +#: src/setup/ibus-setup-chewing-window.ui:133 msgid "Until how many characters should trigger auto-commit" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:120 +#: src/setup/ibus-setup-chewing-window.ui:138 msgid "Chinese/Alphanumeric Mode Toggle Key" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:124 +#: src/setup/ibus-setup-chewing-window.ui:142 msgid "Caps Lock" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:125 +#: src/setup/ibus-setup-chewing-window.ui:143 msgid "Shift" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:126 +#: src/setup/ibus-setup-chewing-window.ui:144 msgid "Shift_L" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:127 +#: src/setup/ibus-setup-chewing-window.ui:145 msgid "Shift_R" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:138 +#: src/setup/ibus-setup-chewing-window.ui:157 msgid "Disable Syncing" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:139 +#: src/setup/ibus-setup-chewing-window.ui:158 msgid "Sync with Keyboard State" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:143 +#: src/setup/ibus-setup-chewing-window.ui:163 msgid "Sync Caps Lock and IM" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:151 +#: src/setup/ibus-setup-chewing-window.ui:171 msgid "No Default" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:152 +#: src/setup/ibus-setup-chewing-window.ui:172 msgid "Lower Case" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:153 +#: src/setup/ibus-setup-chewing-window.ui:173 msgid "Upper Case" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:157 +#: src/setup/ibus-setup-chewing-window.ui:177 msgid "Default English Letter Case" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:158 +#: src/setup/ibus-setup-chewing-window.ui:178 msgid "The letter case without pressing the Shift key" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:165 +#: src/setup/ibus-setup-chewing-window.ui:185 msgid "Selecting" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:166 +#: src/setup/ibus-setup-chewing-window.ui:186 msgid "Configure the candidate selection behavior" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:177 +#: src/setup/ibus-setup-chewing-window.ui:197 msgid "Candidates Per Page" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:183 +#: src/setup/ibus-setup-chewing-window.ui:203 msgid "Show Page Number" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:189 +#: src/setup/ibus-setup-chewing-window.ui:209 msgid "Choose Phrases Backwards" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:190 +#: src/setup/ibus-setup-chewing-window.ui:210 msgid "Open candidate list from the last character of a phrase" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:196 +#: src/setup/ibus-setup-chewing-window.ui:216 msgid "Use Space Key as Selection Key" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:202 +#: src/setup/ibus-setup-chewing-window.ui:222 msgid "Use Vertical Candidate Panel" msgstr "" -#: src/setup/ibus-setup-chewing-window.ui:203 +#: src/setup/ibus-setup-chewing-window.ui:223 msgid "Choose from vertical or horizontal panel" msgstr "" -#: src/ibus-chewing-engine.c:339 +#: src/setup/ibus-setup-chewing-about.c:52 +msgid "translator-credits" +msgstr "" + +#: src/ibus-chewing-engine.c:291 msgid "Switch to Alphanumeric Mode" msgstr "" -#: src/ibus-chewing-engine.c:341 +#: src/ibus-chewing-engine.c:293 msgid "Switch to Chinese Mode" msgstr "" -#: src/ibus-chewing-engine.c:344 +#: src/ibus-chewing-engine.c:296 msgid "Click to toggle Chinese/Alphanumeric Mode" msgstr "" -#: src/ibus-chewing-engine.c:350 +#: src/ibus-chewing-engine.c:302 msgid "Fullwidth Form" msgstr "" -#: src/ibus-chewing-engine.c:352 +#: src/ibus-chewing-engine.c:304 msgid "Halfwidth Form" msgstr "" -#: src/ibus-chewing-engine.c:355 +#: src/ibus-chewing-engine.c:307 msgid "Click to toggle Halfwidth/Fullwidth Form" msgstr "" -#: src/ibus-chewing-engine.c:361 +#: src/ibus-chewing-engine.c:313 msgid "IBus-Chewing Preferences" msgstr "" -#: src/ibus-chewing-engine.c:363 +#: src/ibus-chewing-engine.c:315 msgid "Click to configure IBus-Chewing" msgstr "" -#: src/main.c:67 +#: src/main.c:68 msgid "Cannot connect to IBus!" msgstr "" -#: src/main.c:94 +#: src/main.c:95 msgid "Chewing" msgstr "" -#: src/main.c:95 +#: src/main.c:96 msgid "Chinese chewing input method" msgstr "" diff --git a/po/update-pot.sh b/po/update-pot.sh new file mode 100755 index 0000000..2670035 --- /dev/null +++ b/po/update-pot.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +xgettext -ktranslatable -k_ \ + -o po/ibus-chewing.pot \ + src/setup/ibus-setup-chewing-window.ui \ + src/setup/*.c \ + src/*.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9aa4da8..15ac4a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,6 +55,8 @@ add_executable(ibus-setup-chewing setup/ibus-setup-chewing-application.h setup/ibus-setup-chewing-window.c setup/ibus-setup-chewing-window.h + setup/ibus-setup-chewing-about.c + setup/ibus-setup-chewing-about.h setup/main.c ${CMAKE_CURRENT_BINARY_DIR}/ibus-setup-chewing-window-ui.c ) @@ -90,7 +92,7 @@ install(FILES setup/${PROJECT_GSCHEMA_XML} DESTINATION ${GSETTINGS_SCHEMAS_DIR} ) if(GLIB_COMPILE_SCHEMAS) - install(CODE "execute_process(COMMAND glib-compile-schemas ${CMAKE_INSTALL_PREFIX}/${GSETTINGS_SCHEMAS_DIR})") + install(CODE "execute_process(COMMAND glib-compile-schemas \${CMAKE_INSTALL_PREFIX}/${GSETTINGS_SCHEMAS_DIR})") endif() install(TARGETS ibus-engine-chewing ibus-setup-chewing diff --git a/src/setup/ibus-setup-chewing-about.c b/src/setup/ibus-setup-chewing-about.c new file mode 100644 index 0000000..5bc771d --- /dev/null +++ b/src/setup/ibus-setup-chewing-about.c @@ -0,0 +1,56 @@ +/* ibus-setup-chewing-window.h + * + * Copyright 2024 Kan-Ru Chen + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "ibus-setup-chewing-about.h" + +#include + +#define QUOTE_ME_INNER(s) #s +#define QUOTE_ME(s) QUOTE_ME_INNER(s) + +void show_about(GtkWidget *self) { + // clang-format off + const char *developers[] = { + "Peng Huang", + "Ding-Yi Chen", + "Hiunn-hué", + "Kan-Ru Chen", + NULL + }; + // clang-format on + + // clang-format off + adw_show_about_dialog( + GTK_WIDGET(self), + "application-name", _("IBus Chewing"), + "application-icon", "application-x-executable", + "version", QUOTE_ME(PRJ_VER), + "website", "https://chewing.im", + "issue-url", "https://github.com/chewing/ibus-chewing", + "support-url", "https://github.com/chewing/ibus-chewing/discussions", + //"debug-info", TODO return settings, + "copyright", "© 2024 libchewing Core Team", + "license-type", GTK_LICENSE_GPL_2_0, + "developers", developers, + "translator-credits", _("translator-credits"), + NULL + ); + // clang-format on +} \ No newline at end of file diff --git a/src/setup/ibus-setup-chewing-about.h b/src/setup/ibus-setup-chewing-about.h new file mode 100644 index 0000000..371548a --- /dev/null +++ b/src/setup/ibus-setup-chewing-about.h @@ -0,0 +1,25 @@ +/* ibus-setup-chewing-window.h + * + * Copyright 2024 Kan-Ru Chen + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include + +void show_about(GtkWidget *self); \ No newline at end of file diff --git a/src/setup/ibus-setup-chewing-window.c b/src/setup/ibus-setup-chewing-window.c index b976023..23ff521 100644 --- a/src/setup/ibus-setup-chewing-window.c +++ b/src/setup/ibus-setup-chewing-window.c @@ -19,6 +19,7 @@ */ #include "ibus-setup-chewing-window.h" +#include "ibus-setup-chewing-about.h" struct _IbusSetupChewingWindow { AdwPreferencesWindow parent_instance; @@ -45,9 +46,11 @@ struct _IbusSetupChewingWindow { G_DEFINE_FINAL_TYPE(IbusSetupChewingWindow, ibus_setup_chewing_window, ADW_TYPE_PREFERENCES_WINDOW) + #define bind_child(child_id) \ gtk_widget_class_bind_template_child(widget_class, IbusSetupChewingWindow, \ child_id) + static void ibus_setup_chewing_window_class_init(IbusSetupChewingWindowClass *klass) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); @@ -73,6 +76,9 @@ ibus_setup_chewing_window_class_init(IbusSetupChewingWindowClass *klass) { bind_child(phrase_choice_from_last); bind_child(space_as_selection); bind_child(vertical_lookup_table); + + gtk_widget_class_install_action(widget_class, "about", NULL, + (GtkWidgetActionActivateFunc)show_about); } const gchar *kb_type_ids[] = { diff --git a/src/setup/ibus-setup-chewing-window.ui b/src/setup/ibus-setup-chewing-window.ui index de61f12..bb4f96a 100644 --- a/src/setup/ibus-setup-chewing-window.ui +++ b/src/setup/ibus-setup-chewing-window.ui @@ -6,12 +6,27 @@ - + \ No newline at end of file From 8ea6eb42d21a91cc1d6efe55cf918a6bc43c9803 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sat, 15 Jun 2024 17:50:46 +0900 Subject: [PATCH 2/7] ci: Add dependabot for github-actions --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d4b6194 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 + +updates: + - package-ecosystem: "github-actions" + directory: "/" + groups: + github-actions: + patterns: + - "*" + schedule: + interval: "monthly" From 0d029f8e9783b07e59dcc853673b79cc8c69d323 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sat, 15 Jun 2024 19:17:04 +0900 Subject: [PATCH 3/7] test: Add options to show about dialog directly --- src/setup/ibus-setup-chewing-about.c | 1 + src/setup/ibus-setup-chewing-application.c | 16 ++++++++++++++++ src/setup/main.c | 14 ++++++++++++++ test/CMakeLists.txt | 4 ++++ 4 files changed, 35 insertions(+) diff --git a/src/setup/ibus-setup-chewing-about.c b/src/setup/ibus-setup-chewing-about.c index 5bc771d..79b88e4 100644 --- a/src/setup/ibus-setup-chewing-about.c +++ b/src/setup/ibus-setup-chewing-about.c @@ -21,6 +21,7 @@ #include "ibus-setup-chewing-about.h" #include +#include #define QUOTE_ME_INNER(s) #s #define QUOTE_ME(s) QUOTE_ME_INNER(s) diff --git a/src/setup/ibus-setup-chewing-application.c b/src/setup/ibus-setup-chewing-application.c index e7e3666..08d64b8 100644 --- a/src/setup/ibus-setup-chewing-application.c +++ b/src/setup/ibus-setup-chewing-application.c @@ -19,7 +19,9 @@ */ #include "ibus-setup-chewing-application.h" +#include "ibus-setup-chewing-about.h" #include "ibus-setup-chewing-window.h" +#include struct _IbusSetupChewingApplication { AdwApplication parent_instance; @@ -67,8 +69,22 @@ static void ibus_setup_chewing_application_quit_action(GSimpleAction *action, g_application_quit(G_APPLICATION(self)); } +static void ibus_setup_chewing_application_about_action(GSimpleAction *action, + GVariant *parameter, + gpointer user_data) { + GtkWindow *window; + IbusSetupChewingApplication *self = user_data; + + g_assert(IBUS_SETUP_CHEWING_IS_APPLICATION(self)); + + window = gtk_application_get_active_window(GTK_APPLICATION(self)); + + show_about(GTK_WIDGET(window)); +} + static const GActionEntry app_actions[] = { {"quit", ibus_setup_chewing_application_quit_action}, + {"about", ibus_setup_chewing_application_about_action}, }; static void diff --git a/src/setup/main.c b/src/setup/main.c index d0ce8fb..2379209 100644 --- a/src/setup/main.c +++ b/src/setup/main.c @@ -23,10 +23,13 @@ #include "ibus-setup-chewing-application.h" static gboolean quit = FALSE; +static gboolean about = FALSE; static GOptionEntry entries[] = { {"quit", 'q', 0, G_OPTION_ARG_NONE, &quit, "Cause the application to quit immediately after launch", NULL}, + {"about", 0, 0, G_OPTION_ARG_NONE, &about, + "Cause the application to show about dialog after launch", NULL}, G_OPTION_ENTRY_NULL}; static void application_quit(gpointer user_data) { @@ -37,6 +40,14 @@ static void application_quit(gpointer user_data) { g_action_activate(G_ACTION(quit_action), NULL); } +static void application_about(gpointer user_data) { + IbusSetupChewingApplication *self = user_data; + GAction *about_action; + + about_action = g_action_map_lookup_action(G_ACTION_MAP(self), "about"); + g_action_activate(G_ACTION(about_action), NULL); +} + int main(int argc, char *argv[]) { GError *error = NULL; GOptionContext *context; @@ -58,6 +69,9 @@ int main(int argc, char *argv[]) { app = ibus_setup_chewing_application_new( "org.freedesktop.IBus.Chewing.Setup", G_APPLICATION_DEFAULT_FLAGS); + if (about) { + g_idle_add(G_SOURCE_FUNC(application_about), app); + } if (quit) { g_idle_add(G_SOURCE_FUNC(application_quit), app); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0f14d21..e12308c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -57,3 +57,7 @@ add_test(NAME ibus-setup-chewing COMMAND ${CMAKE_BINARY_DIR}/bin/ibus-setup-chewing -q) set_tests_properties(ibus-setup-chewing PROPERTIES ENVIRONMENT "GSETTINGS_SCHEMA_DIR=${CMAKE_BINARY_DIR}/bin") +add_test(NAME ibus-setup-chewing-about + COMMAND ${CMAKE_BINARY_DIR}/bin/ibus-setup-chewing --about -q) +set_tests_properties(ibus-setup-chewing-about PROPERTIES + ENVIRONMENT "GSETTINGS_SCHEMA_DIR=${CMAKE_BINARY_DIR}/bin") From acb2d14ac72dbc90b8fe86e130f033692f731efb Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sun, 16 Jun 2024 22:33:40 +0900 Subject: [PATCH 4/7] feat: Add debug-info --- CMakeLists.txt | 4 ++ src/setup/ibus-setup-chewing-about.c | 100 ++++++++++++++++++++++++++- src/setup/ibus-setup-chewing-about.h | 6 +- 3 files changed, 108 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 553dc14..6180cc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,8 @@ set(LICENSE "GPLv2+") set(PRJ_GROUP "System Environment/Libraries") set(RRJ_URL "https://github.com/chewing/${PROJECT_NAME}") +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + enable_testing() include(GNUInstallDirs) @@ -75,6 +77,8 @@ add_compile_definitions( PRJ_DATA_DIR=${PRJ_DATA_DIR} PRJ_VER=${PRJ_VER} PRJ_URL=${PRJ_URL} + IBUS_VERSION=${IBUS_VERSION} + CHEWING_VERSION=${CHEWING_VERSION} LIBEXEC_DIR=${LIBEXEC_DIR} CHEWING_DATADIR_REAL=${CHEWING_DATADIR_REAL} ) diff --git a/src/setup/ibus-setup-chewing-about.c b/src/setup/ibus-setup-chewing-about.c index 79b88e4..f0d6fd6 100644 --- a/src/setup/ibus-setup-chewing-about.c +++ b/src/setup/ibus-setup-chewing-about.c @@ -26,7 +26,103 @@ #define QUOTE_ME_INNER(s) #s #define QUOTE_ME(s) QUOTE_ME_INNER(s) +static char *generate_debug_info(void) { + GString *string = g_string_new(NULL); + + g_string_append_printf(string, "ibus-chewing: %s\n\n", QUOTE_ME(PRJ_VER)); + g_string_append(string, "Compiled against:\n"); + g_string_append_printf(string, "- ibus: %s\n", QUOTE_ME(IBUS_VERSION)); + g_string_append_printf(string, "- libchewing: %s\n", + QUOTE_ME(CHEWING_VERSION)); + + g_string_append(string, "\nRunning against:\n"); + g_string_append_printf(string, "- libchewing: n/a\n"); + + g_string_append(string, "\n"); + { + g_autoptr(GSettings) settings = + g_settings_new("org.freedesktop.IBus.Chewing"); + gchar *kb_type = g_settings_get_string(settings, "kb-type"); + gchar *sel_keys = g_settings_get_string(settings, "sel-keys"); + gchar *chi_eng_mode_toggle = + g_settings_get_string(settings, "chi-eng-mode-toggle"); + gchar *sync_caps_lock = + g_settings_get_string(settings, "sync-caps-lock"); + gchar *default_english_case = + g_settings_get_string(settings, "default-english-case"); + + g_string_append(string, "Settings:\n"); + g_string_append_printf(string, "- kb-type: %s\n", kb_type); + g_string_append_printf(string, "- sel-keys: %s\n", sel_keys); + g_string_append_printf( + string, "- plain-zhuyin: %d\n", + g_settings_get_boolean(settings, "plain-zhuyin")); + g_string_append_printf( + string, "- auto-shift-cur: %d\n", + g_settings_get_boolean(settings, "auto-shift-cur")); + g_string_append_printf( + string, "- add-phrase-direction: %d\n", + g_settings_get_boolean(settings, "add-phrase-direction")); + g_string_append_printf( + string, "- clean-buffer-focus-out: %d\n", + g_settings_get_boolean(settings, "clean-buffer-focus-out")); + g_string_append_printf( + string, "- easy-symbol-input: %d\n", + g_settings_get_boolean(settings, "easy-symbol-input")); + g_string_append_printf( + string, "- esc-clean-all-buf: %d\n", + g_settings_get_boolean(settings, "esc-clean-all-buf")); + g_string_append_printf( + string, "- max-chi-symbol-len: %d\n", + g_settings_get_int(settings, "max-chi-symbol-len")); + g_string_append_printf(string, "- chi-eng-mode-toggle: %s\n", + chi_eng_mode_toggle); + g_string_append_printf(string, "- sync-caps-lock: %s\n", + sync_caps_lock); + g_string_append_printf(string, "- default-english-case: %s\n", + default_english_case); + g_string_append_printf(string, "- cand-per-page: %d\n", + g_settings_get_uint(settings, "cand-per-page")); + g_string_append_printf( + string, "- show-page-number: %d\n", + g_settings_get_boolean(settings, "show-page-number")); + g_string_append_printf( + string, "- phrase-choice-from-last: %d\n", + g_settings_get_boolean(settings, "phrase-choice-from-last")); + g_string_append_printf( + string, "- space-as-selection: %d\n", + g_settings_get_boolean(settings, "space-as-selection")); + g_string_append_printf( + string, "- vertical-lookup-table: %d\n", + g_settings_get_boolean(settings, "vertical-lookup-table")); + + g_free(kb_type); + g_free(sel_keys); + g_free(chi_eng_mode_toggle); + g_free(sync_caps_lock); + g_free(default_english_case); + } + + g_string_append(string, "\n"); + { + const char *desktop = g_getenv("XDG_CURRENT_DESKTOP"); + const char *session_desktop = g_getenv("XDG_SESSION_DESKTOP"); + const char *session_type = g_getenv("XDG_SESSION_TYPE"); + const char *lang = g_getenv("LANG"); + + g_string_append(string, "Environment:\n"); + g_string_append_printf(string, "- Desktop: %s\n", desktop); + g_string_append_printf(string, "- Session: %s (%s)\n", session_desktop, + session_type); + g_string_append_printf(string, "- Language: %s\n", lang); + } + + return g_string_free_and_steal(string); +} + void show_about(GtkWidget *self) { + char *debug_info = generate_debug_info(); + // clang-format off const char *developers[] = { "Peng Huang", @@ -46,7 +142,7 @@ void show_about(GtkWidget *self) { "website", "https://chewing.im", "issue-url", "https://github.com/chewing/ibus-chewing", "support-url", "https://github.com/chewing/ibus-chewing/discussions", - //"debug-info", TODO return settings, + "debug-info", debug_info, "copyright", "© 2024 libchewing Core Team", "license-type", GTK_LICENSE_GPL_2_0, "developers", developers, @@ -54,4 +150,6 @@ void show_about(GtkWidget *self) { NULL ); // clang-format on + + g_free(debug_info); } \ No newline at end of file diff --git a/src/setup/ibus-setup-chewing-about.h b/src/setup/ibus-setup-chewing-about.h index 371548a..44832f1 100644 --- a/src/setup/ibus-setup-chewing-about.h +++ b/src/setup/ibus-setup-chewing-about.h @@ -22,4 +22,8 @@ #include -void show_about(GtkWidget *self); \ No newline at end of file +G_BEGIN_DECLS + +void show_about(GtkWidget *self); + +G_END_DECLS \ No newline at end of file From 280c25af50d51677400f63b435da664333ec4cff Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Mon, 17 Jun 2024 08:21:51 +0900 Subject: [PATCH 5/7] feat: Adjust about urls --- src/setup/ibus-setup-chewing-about.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/setup/ibus-setup-chewing-about.c b/src/setup/ibus-setup-chewing-about.c index f0d6fd6..6cbed46 100644 --- a/src/setup/ibus-setup-chewing-about.c +++ b/src/setup/ibus-setup-chewing-about.c @@ -121,6 +121,7 @@ static char *generate_debug_info(void) { } void show_about(GtkWidget *self) { + AdwDialog *about; char *debug_info = generate_debug_info(); // clang-format off @@ -134,15 +135,15 @@ void show_about(GtkWidget *self) { // clang-format on // clang-format off - adw_show_about_dialog( - GTK_WIDGET(self), + about = g_object_new( + ADW_TYPE_ABOUT_DIALOG, "application-name", _("IBus Chewing"), "application-icon", "application-x-executable", "version", QUOTE_ME(PRJ_VER), "website", "https://chewing.im", - "issue-url", "https://github.com/chewing/ibus-chewing", - "support-url", "https://github.com/chewing/ibus-chewing/discussions", + "issue-url", "https://github.com/chewing/ibus-chewing/issues", "debug-info", debug_info, + "debug-info-filename", "ibus-chewing-debug-info.txt", "copyright", "© 2024 libchewing Core Team", "license-type", GTK_LICENSE_GPL_2_0, "developers", developers, @@ -151,5 +152,13 @@ void show_about(GtkWidget *self) { ); // clang-format on + adw_about_dialog_add_link(ADW_ABOUT_DIALOG(about), _("_Mailing list"), + "https://groups.google.com/g/chewing"); + + adw_about_dialog_add_link(ADW_ABOUT_DIALOG(about), _("_Chat"), + "https://matrix.to/#/#chewing-users:matrix.org"); + + adw_dialog_present(about, GTK_WIDGET(self)); + g_free(debug_info); } \ No newline at end of file From aa9de0933bd03c1cc6fa5943521b1c534f848cd0 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Tue, 18 Jun 2024 22:22:37 +0900 Subject: [PATCH 6/7] feat: Add new chewing icon --- src/setup/ibus-setup-chewing-about.c | 2 +- src/setup/ibus-setup-chewing.gresource.xml | 1 + src/setup/im.chewing.Chewing.svg | 796 +++++++++++++++++++++ 3 files changed, 798 insertions(+), 1 deletion(-) create mode 100644 src/setup/im.chewing.Chewing.svg diff --git a/src/setup/ibus-setup-chewing-about.c b/src/setup/ibus-setup-chewing-about.c index 6cbed46..4b277ac 100644 --- a/src/setup/ibus-setup-chewing-about.c +++ b/src/setup/ibus-setup-chewing-about.c @@ -138,7 +138,7 @@ void show_about(GtkWidget *self) { about = g_object_new( ADW_TYPE_ABOUT_DIALOG, "application-name", _("IBus Chewing"), - "application-icon", "application-x-executable", + "application-icon", "im.chewing.Chewing", "version", QUOTE_ME(PRJ_VER), "website", "https://chewing.im", "issue-url", "https://github.com/chewing/ibus-chewing/issues", diff --git a/src/setup/ibus-setup-chewing.gresource.xml b/src/setup/ibus-setup-chewing.gresource.xml index 6aab55f..6c4ff0c 100644 --- a/src/setup/ibus-setup-chewing.gresource.xml +++ b/src/setup/ibus-setup-chewing.gresource.xml @@ -2,5 +2,6 @@ ibus-setup-chewing-window.ui + im.chewing.Chewing.svg \ No newline at end of file diff --git a/src/setup/im.chewing.Chewing.svg b/src/setup/im.chewing.Chewing.svg new file mode 100644 index 0000000..14ccf62 --- /dev/null +++ b/src/setup/im.chewing.Chewing.svg @@ -0,0 +1,796 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 171d323a9d36dcc90e2dd5e419ea2377a6ffc6be Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sun, 23 Jun 2024 06:43:39 +0900 Subject: [PATCH 7/7] feat: install new icon --- CMakeLists.txt | 2 + data/ibus-setup-chewing.desktop.in | 2 +- icons/org.freedesktop.IBus.Chewing.Setup.svg | 101 +++ src/setup/ibus-setup-chewing.gresource.xml | 4 +- src/setup/im.chewing.Chewing.svg | 796 ------------------- 5 files changed, 106 insertions(+), 799 deletions(-) create mode 100644 icons/org.freedesktop.IBus.Chewing.Setup.svg delete mode 100644 src/setup/im.chewing.Chewing.svg diff --git a/CMakeLists.txt b/CMakeLists.txt index 6180cc4..a54cf71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,8 @@ install(FILES ${CMAKE_BINARY_DIR}/data/ibus-setup-chewing.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) install(DIRECTORY icons DESTINATION ${CMAKE_INSTALL_DATADIR}/ibus-chewing) +install(FILES icons/org.freedesktop.IBus.Chewing.Setup.svg + DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps) set(CPACK_PACKAGE_CHECKSUM SHA256) set(CPACK_SOURCE_IGNORE_FILES "/build" "/out" "/\\\\..*") diff --git a/data/ibus-setup-chewing.desktop.in b/data/ibus-setup-chewing.desktop.in index ed8b4f1..eb72876 100644 --- a/data/ibus-setup-chewing.desktop.in +++ b/data/ibus-setup-chewing.desktop.in @@ -4,7 +4,7 @@ Name[zh_TW]=IBus 酷音偏好設定 Comment=Set IBus Chewing Preferences Comment[zh_TW]=設定 IBus 酷音偏好 Exec=@LIBEXEC_DIR@/ibus-setup-chewing -Icon=ibus-setup-chewing +Icon=org.freedesktop.IBus.Chewing.Setup NoDisplay=true Terminal=false Type=Application diff --git a/icons/org.freedesktop.IBus.Chewing.Setup.svg b/icons/org.freedesktop.IBus.Chewing.Setup.svg new file mode 100644 index 0000000..54d551a --- /dev/null +++ b/icons/org.freedesktop.IBus.Chewing.Setup.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/setup/ibus-setup-chewing.gresource.xml b/src/setup/ibus-setup-chewing.gresource.xml index 6c4ff0c..f2c62fa 100644 --- a/src/setup/ibus-setup-chewing.gresource.xml +++ b/src/setup/ibus-setup-chewing.gresource.xml @@ -2,6 +2,6 @@ ibus-setup-chewing-window.ui - im.chewing.Chewing.svg + ../../icons/org.freedesktop.IBus.Chewing.Setup.svg - \ No newline at end of file + diff --git a/src/setup/im.chewing.Chewing.svg b/src/setup/im.chewing.Chewing.svg deleted file mode 100644 index 14ccf62..0000000 --- a/src/setup/im.chewing.Chewing.svg +++ /dev/null @@ -1,796 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -