From 6bd7a309b36a306af825bfd8d8929c120d7698cb Mon Sep 17 00:00:00 2001 From: deepend Date: Tue, 17 Feb 2026 18:55:38 -0700 Subject: [PATCH] =?UTF-8?q?Updated=20Windows=20GTK=20startup=20environment?= =?UTF-8?q?=20handling=20so=20ZoiteChat=20always=20prepends=20its=20bundle?= =?UTF-8?q?d=20share=20directory=20to=20XDG=5FDATA=5FDIRS=20(without=20bre?= =?UTF-8?q?aking=20existing=20values),=20which=20enables=20GTK=20to=20disc?= =?UTF-8?q?over=20packaged=20runtime=20data=20used=20by=20icon/theme=20and?= =?UTF-8?q?=20emoji=20resources.=20Also=20changed=20GSETTINGS=5FSCHEMA=5FD?= =?UTF-8?q?IR=20logic=20so=20it=20no=20longer=20short-circuits=20this=20se?= =?UTF-8?q?tup=20when=20GSETTINGS=5FSCHEMA=5FDIR=20is=20already=20set.=20A?= =?UTF-8?q?dded=20a=20Win32=20icon-theme=20setup=20helper=20that=20appends?= =?UTF-8?q?=20bundled=20share/icons=20to=20GtkIconTheme=20search=20paths?= =?UTF-8?q?=20and=20forces=20Adwaita=20when=20available,=20so=20the=20emoj?= =?UTF-8?q?i=20chooser=E2=80=99s=20category/menu=20symbolic=20icons=20reso?= =?UTF-8?q?lve=20instead=20of=20showing=20placeholder=20squares.=20Invoked?= =?UTF-8?q?=20the=20new=20Win32=20icon-theme=20configuration=20immediately?= =?UTF-8?q?=20after=20gtk=5Finit()=20so=20it=20applies=20before=20UI=20usa?= =?UTF-8?q?ge,=20including=20the=20emoji=20chooser=20popover=20created=20f?= =?UTF-8?q?rom=20entries.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fe-gtk/fe-gtk.c | 80 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index f823fdc8..46678e74 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -121,22 +121,90 @@ static void win32_set_gsettings_schema_dir (void) { char *base_path; + char *share_path; char *schema_path; - - if (g_getenv ("GSETTINGS_SCHEMA_DIR") != NULL) - return; + char *xdg_data_dirs; + char **xdg_parts; + gboolean have_share_path = FALSE; + gint i; base_path = g_win32_get_package_installation_directory_of_module (NULL); if (base_path == NULL) return; + share_path = g_build_filename (base_path, "share", NULL); + + /* Ensure GTK can discover bundled icon themes and other shared data. */ + xdg_data_dirs = g_strdup (g_getenv ("XDG_DATA_DIRS")); + if (xdg_data_dirs && *xdg_data_dirs) + { + xdg_parts = g_strsplit (xdg_data_dirs, G_SEARCHPATH_SEPARATOR_S, -1); + for (i = 0; xdg_parts[i] != NULL; i++) + { + if (g_ascii_strcasecmp (xdg_parts[i], share_path) == 0) + { + have_share_path = TRUE; + break; + } + } + g_strfreev (xdg_parts); + + if (!have_share_path) + { + char *updated = g_strdup_printf ("%s%c%s", share_path, + G_SEARCHPATH_SEPARATOR, + xdg_data_dirs); + g_setenv ("XDG_DATA_DIRS", updated, TRUE); + g_free (updated); + } + } + else + { + g_setenv ("XDG_DATA_DIRS", share_path, TRUE); + } + schema_path = g_build_filename (base_path, "share", "glib-2.0", "schemas", NULL); - if (g_file_test (schema_path, G_FILE_TEST_IS_DIR)) + if (g_getenv ("GSETTINGS_SCHEMA_DIR") == NULL + && g_file_test (schema_path, G_FILE_TEST_IS_DIR)) g_setenv ("GSETTINGS_SCHEMA_DIR", schema_path, FALSE); + g_free (xdg_data_dirs); + g_free (share_path); g_free (schema_path); g_free (base_path); } + +static void +win32_configure_icon_theme (void) +{ + GtkIconTheme *theme; + char *base_path; + char *icons_path; + char *adwaita_path; + + theme = gtk_icon_theme_get_default (); + if (!theme) + return; + + base_path = g_win32_get_package_installation_directory_of_module (NULL); + if (!base_path) + return; + + icons_path = g_build_filename (base_path, "share", "icons", NULL); + adwaita_path = g_build_filename (icons_path, "Adwaita", NULL); + + if (g_file_test (icons_path, G_FILE_TEST_IS_DIR)) + gtk_icon_theme_append_search_path (theme, icons_path); + + /* GtkEntry's emoji chooser uses symbolic category/menu icons only present in + * Adwaita in our Windows bundle. Force it when available. */ + if (g_file_test (adwaita_path, G_FILE_TEST_IS_DIR)) + gtk_icon_theme_set_custom_theme (theme, "Adwaita"); + + g_free (adwaita_path); + g_free (icons_path); + g_free (base_path); +} #endif int @@ -272,6 +340,10 @@ fe_args (int argc, char *argv[]) #endif gtk_init (&argc, &argv); +#ifdef WIN32 + win32_configure_icon_theme (); +#endif + #ifdef HAVE_GTK_MAC osx_app = g_object_new(GTKOSX_TYPE_APPLICATION, NULL); #endif