diff --git a/client-demo.c b/client-demo.c index 2cab911db0b0eb57cdc468c604efea1323b52e55..154442595d9e664eb4710d4a7ac1a4bb5e421792 100644 --- a/client-demo.c +++ b/client-demo.c @@ -12,6 +12,7 @@ * limitations under the License. */ #include <gio/gio.h> +#include <locale.h> #include <glib.h> #ifdef G_OS_UNIX #include <glib-unix.h> @@ -101,6 +102,7 @@ startup(GApplication *app, /* show panel, wait 3s, then hide panel and exit app */ err = NULL; const gchar *const candidates[] = {"第一个", "第二个", "第三个"}; + /* g_message("first: %s", candidates[0]); */ GVariant *hints = NULL; GVariantBuilder b = {0}; g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); @@ -147,6 +149,7 @@ main(int argc, char *argv[]) GApplication *app = NULL; int status = 0; + setlocale(LC_ALL, ""); app = g_application_new("com.emacsos.zero.ZeroPanelClientDemo", G_APPLICATION_FLAGS_NONE); g_assert_nonnull(app); diff --git a/meson.build b/meson.build index bdb40f12e9bffaa95698e00e81645352e20f91b7..3f47a645586181ac1daa3d5a77e7b368c72adb25 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ # -*- mode: conf -*- project('zero-panel', 'c', - version: '1.3.2', + version: '1.3.3', license: 'EPL-2.0', meson_version: '>=0.46.0', default_options: [ diff --git a/operational b/operational index a6d69d94a0eebc0762400c68a526bad124b2a23d..614c9cc778436fd277b8e2c927dbe3c86673afb6 100644 --- a/operational +++ b/operational @@ -1,6 +1,6 @@ * COMMENT -*- mode: org -*- #+Date: 2019-09-02 -Time-stamp: <2023-08-15> +Time-stamp: <2023-08-16> #+STARTUP: content * notes :entry: ** 2023-08-15 how to build from source? :doc: @@ -208,9 +208,86 @@ I already set this in ui file: They don't work properly in Wayland. - see minimal test application at ~/c/testing-only/do-not-focus/main.c +- 2023-08-16 search: how to mark a window as not focus on gtk window on wayland? + search: does gtk3 support wayland properly? * current :entry: ** +** 2023-08-16 bug: ./build/zero-panel-client-demo segfault on RHEL9. +- it runs fine on lat21. but has a few warnings. fix the warnings. + #+BEGIN_SRC sh + sylecn@lat21:~/projects/zero-panel$ ./build/zero-panel-client-demo + + (zero-panel-client-demo:56547): GLib-CRITICAL **: 12:11:37.488: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed + + (zero-panel-client-demo:56547): GLib-CRITICAL **: 12:11:37.488: g_variant_ref_sink: assertion 'value != NULL' failed + + (zero-panel-client-demo:56547): GLib-CRITICAL **: 12:11:37.488: g_variant_ref: assertion 'value != NULL' failed + + (zero-panel-client-demo:56547): GLib-CRITICAL **: 12:11:37.490: g_variant_unref: assertion 'value != NULL' failed + ,** Message: 12:11:37.490: call ShowCandidates() okay + ,** Message: 12:11:37.490: activate() + ,** Message: 12:11:41.111: call Hide() okay + ,** Message: 12:11:41.111: shutdown() + #+END_SRC +- search: GLib-CRITICAL assert how to debug get source code line? + + rm -rf build/ + meson setup --buildtype debug build/ + cd build && ninja + ./build/zero-panel-client-demo + the warning is gone when I use debug build. + + env G_DEBUG=fatal-criticals ./build/zero-panel-client-demo + +- I think the Chinese char* literal is most suspicious. + try use ascii string there. + yes. debugoptimized build warning is gone when only use ascii string. + + search: how to use unicode utf-8 string literal in gtk gchar + + all char* is assumed to be utf-8. it is supported out of the box. + +- I got a minimal reproducible demo. + #+BEGIN_SRC c + const gchar* first = "第一个"; + g_assert_true(g_utf8_validate(first, -1, NULL)); + const gchar* second = "第二个"; + const gchar* third = "第三个"; + + const gchar *const candidates[] = {first, second, third}; + g_message("first is: %s", first); + g_message("first is: %s", candidates[0]); + #+END_SRC + the g_message() call output garbage. + + add setlocale(LC_ALL, "en_US.UTF-8"); worked. + default locale must be C. // confirmed. default locale is C. + +- TODO if default locale is C, always set locale for all my glib programs. + + #include <locale.h> + + setlocale(LC_ALL, "en_US.UTF-8"); + + is there a method call to use system locale instead of "C" locale? + can I assume en_US.UTF-8 exist? I don't think so. + any UTF-8 will do. + + https://docs.gtk.org/glib/running.html#locale + + A number of interfaces in GLib depend on the current locale in which an + application is running. Therefore, most GLib-using applications should call + setlocale (LC_ALL, "") to set up the current locale. + + // good. + +- warning still persist after adding setlocale() call. + +** 2023-08-16 what's new in gtk4? should I upgrade? +- Gtk – 4.0: Migrating from GTK 3.x to GTK 4 + https://docs.gtk.org/gtk4/migrating-3to4.html +- ** 2019-09-02 support user configuration of theme and panel orientation. is it supported by zero-el? - 2023-08-01 diff --git a/server.c b/server.c index 7e58e9214674216be7bb01639721df8e3937886f..3895ef7bd41357261f82fd25dfaf56cbb77c3178 100644 --- a/server.c +++ b/server.c @@ -12,6 +12,7 @@ * limitations under the License. */ #include <stdlib.h> +#include <locale.h> #include <gtk/gtk.h> #ifdef G_OS_UNIX #include <glib-unix.h> @@ -651,6 +652,9 @@ main(int argc, char *argv[]) GtkApplication *app = NULL; int status = 0; + // use current system locale instead of C locale. + setlocale(LC_ALL, ""); + parse_command_line_args(argc, argv, &appdata); app = gtk_application_new(ZERO_PANEL_GTK_APP_ID, G_APPLICATION_FLAGS_NONE);