From e214c76bdf3919b93d31f0e45f1e2c0cfa6181e8 Mon Sep 17 00:00:00 2001 From: deepend Date: Wed, 18 Feb 2026 00:52:49 -0700 Subject: [PATCH] Unified GTK3 menu icon resolution so menu-sized icons now consistently map to the bundled zc-menu-* icon set (from data/icons/menu) even when callers pass freedesktop icon names (like edit-copy, go-next) instead of legacy stock IDs. This removes the mixed behavior where some items came from system themes while others came from bundled resources. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a new icon-name→zc-menu-* mapping helper and wired it into gtkutil_image_new_from_stock() as a fallback path for GTK_ICON_SIZE_MENU, after the existing stock-name mapping. --- src/fe-gtk/gtkutil.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c index 5033d873..8c772908 100644 --- a/src/fe-gtk/gtkutil.c +++ b/src/fe-gtk/gtkutil.c @@ -110,6 +110,54 @@ gtkutil_menu_custom_icon_from_stock (const char *stock_name) return NULL; } + +static const char * +gtkutil_menu_custom_icon_from_icon_name (const char *icon_name) +{ + static const struct + { + const char *icon; + const char *custom_icon; + } icon_map[] = { + { "document-new", "zc-menu-new" }, + { "view-list", "zc-menu-network-list" }, + { "document-open", "zc-menu-load-plugin" }, + { "edit-redo", "zc-menu-detach" }, + { "window-close", "zc-menu-close" }, + { "application-exit", "zc-menu-quit" }, + { "network-disconnect", "zc-menu-disconnect" }, + { "network-connect", "zc-menu-connect" }, + { "go-jump", "zc-menu-join" }, + { "preferences-system", "zc-menu-preferences" }, + { "edit-clear", "zc-menu-clear" }, + { "edit-copy", "zc-menu-copy" }, + { "edit-delete", "zc-menu-delete" }, + { "list-add", "zc-menu-add" }, + { "list-remove", "zc-menu-remove" }, + { "tools-check-spelling", "zc-menu-spell-check" }, + { "document-save", "zc-menu-save" }, + { "document-save-as", "zc-menu-save-as" }, + { "view-refresh", "zc-menu-refresh" }, + { "edit-find", "zc-menu-find" }, + { "go-previous", "zc-menu-previous" }, + { "go-next", "zc-menu-next" }, + { "help-browser", "zc-menu-help" }, + { "help-about", "zc-menu-about" }, + { "network-workgroup", "zc-menu-chanlist" }, + }; + size_t i; + + if (!icon_name) + return NULL; + + for (i = 0; i < G_N_ELEMENTS (icon_map); i++) + { + if (strcmp (icon_name, icon_map[i].icon) == 0) + return icon_map[i].custom_icon; + } + + return NULL; +} #endif #if !HAVE_GTK3 @@ -323,6 +371,9 @@ gtkutil_image_new_from_stock (const char *stock, GtkIconSize size) { const char *menu_icon_name = gtkutil_menu_custom_icon_from_stock (stock); + if (!menu_icon_name) + menu_icon_name = gtkutil_menu_custom_icon_from_icon_name (icon_name); + if (menu_icon_name) icon_name = menu_icon_name; }