From 329a641adfbced9721c0f5b5566fa5927109a173 Mon Sep 17 00:00:00 2001 From: deepend Date: Tue, 17 Feb 2026 22:03:51 -0700 Subject: [PATCH] =?UTF-8?q?I=20added=20a=20Windows-specific=20fallback=20t?= =?UTF-8?q?o=20load=20custom=20menu=20icons=20directly=20from=20the=20inst?= =?UTF-8?q?alled=20share/icons/menu//=20path=20when=20GResource?= =?UTF-8?q?=20lookup=20doesn=E2=80=99t=20return=20an=20icon.=20This=20uses?= =?UTF-8?q?=20g=5Fwin32=5Fget=5Fpackage=5Finstallation=5Fdirectory=5Fof=5F?= =?UTF-8?q?module()=20plus=20g=5Fbuild=5Ffilename()=20to=20avoid=20separat?= =?UTF-8?q?or/path=20issues.=20The=20new=20fallback=20tries=20*.svg=20firs?= =?UTF-8?q?t,=20then=20*.png,=20so=20if=20resources=20aren=E2=80=99t=20ava?= =?UTF-8?q?ilable=20at=20runtime=20but=20files=20were=20installed,=20menu?= =?UTF-8?q?=20icons=20still=20render.=20After=20that,=20the=20existing=20i?= =?UTF-8?q?con-name=20fallback=20chain=20still=20runs=20(custom=5Ffallback?= =?UTF-8?q?=5Ficon=20=E2=86=92=20stock=20mapping=20=E2=86=92=20stock=20nam?= =?UTF-8?q?e),=20so=20non-file-based=20fallback=20behavior=20is=20preserve?= =?UTF-8?q?d.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fe-gtk/menu.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 50d9ccab..923d57cf 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -2201,11 +2201,46 @@ create_icon_menu (char *labeltext, void *stock_name, int is_stock) custom_fallback_icon = "help-about"; } + if (!image && custom_icon) + { +#ifdef WIN32 + char *base_path = g_win32_get_package_installation_directory_of_module (NULL); + + if (base_path) + { + char *icons_menu_path = g_build_filename (base_path, "share", "icons", "menu", theme_variant, NULL); + char *filename = g_strconcat (custom_icon, ".svg", NULL); + char *icon_path = g_build_filename (icons_menu_path, filename, NULL); + + if (g_file_test (icon_path, G_FILE_TEST_EXISTS)) + image = gtk_image_new_from_file (icon_path); + + g_free (icon_path); + g_free (filename); + + if (!image) + { + filename = g_strconcat (custom_icon, ".png", NULL); + icon_path = g_build_filename (icons_menu_path, filename, NULL); + + if (g_file_test (icon_path, G_FILE_TEST_EXISTS)) + image = gtk_image_new_from_file (icon_path); + + g_free (icon_path); + g_free (filename); + } + + g_free (icons_menu_path); + g_free (base_path); + } +#endif + } + if (!image) { - icon_name = gtkutil_icon_name_from_stock (stock_name); - if (!icon_name && custom_fallback_icon) - icon_name = custom_fallback_icon; + icon_name = custom_fallback_icon ? custom_fallback_icon : gtkutil_icon_name_from_stock (stock_name); + if (!icon_name) + icon_name = gtkutil_icon_name_from_stock (stock_name); if (!icon_name) icon_name = stock_name; if (icon_name)