Updated GTK3 menu item rendering so any zc-menu-* icon passed into menu_quick_item() is treated as a bundled ZoiteChat menu icon and loaded via menu_icon_image_from_data_icons(...) using the active light/dark variant, which makes dynamic/custom menu entries use the same icon source as the main menu icons.

Added GTK3 forward declarations for menu_icon_theme_variant() and menu_icon_image_from_data_icons() so menu_quick_item() can call those helpers before their later definitions in the file.

    Kept fallback behavior intact: if bundled icon loading fails, the code still falls back to icon-theme lookup by name.
This commit is contained in:
2026-02-17 23:35:32 -07:00
parent 7af8f069e7
commit 01e890eb3f

View File

@@ -273,6 +273,11 @@ menu_toggle_item (char *label, GtkWidget *menu, void *callback, void *userdata,
return item; return item;
} }
#if HAVE_GTK3
static const char *menu_icon_theme_variant (void);
static GtkWidget *menu_icon_image_from_data_icons (const char *icon_name, const char *theme_variant);
#endif
GtkWidget * GtkWidget *
menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags, menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
gpointer userdata, char *icon) gpointer userdata, char *icon)
@@ -281,6 +286,7 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
char *path; char *path;
#if HAVE_GTK3 #if HAVE_GTK3
const char *icon_name = NULL; const char *icon_name = NULL;
const char *custom_icon = NULL;
GtkWidget *box; GtkWidget *box;
GtkWidget *image = NULL; GtkWidget *image = NULL;
GtkWidget *label_widget; GtkWidget *label_widget;
@@ -310,6 +316,8 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
icon_name = gtkutil_icon_name_from_stock (icon); icon_name = gtkutil_icon_name_from_stock (icon);
if (!icon_name) if (!icon_name)
icon_name = icon; icon_name = icon;
if (g_str_has_prefix (icon_name, "zc-menu-"))
custom_icon = icon_name + strlen ("zc-menu-");
#endif #endif
#if !HAVE_GTK3 #if !HAVE_GTK3
img = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_MENU); img = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_MENU);
@@ -321,7 +329,9 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
#if HAVE_GTK3 #if HAVE_GTK3
item = gtk_menu_item_new (); item = gtk_menu_item_new ();
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
if (icon_name) if (custom_icon)
image = menu_icon_image_from_data_icons (custom_icon, menu_icon_theme_variant ());
if (!image && icon_name)
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
else if (img) else if (img)
image = img; image = img;