Updated create_icon_menu to build GTK3 icon menu items by packing an image and mnemonic label into a box while keeping GTK2 GtkImageMenuItem handling intact.

Expanded channel list icon menu items to handle GTK3 box-based layout and GTK2 image menu items in one helper, and used that helper for the context menu entries.
Unified sexy spell entry icon menu item creation across GTK versions, using stock IDs for both and centralizing the GTK3 box-based layout with GTK2 image menu items preserved.
This commit is contained in:
2026-01-23 13:58:53 -07:00
parent 905cc2f22e
commit 853c16a9bc
3 changed files with 37 additions and 84 deletions

View File

@@ -353,27 +353,6 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
return item;
}
#if HAVE_GTK3
static GtkWidget *
menu_icon_name_item_new (const char *label, const char *icon_name)
{
GtkWidget *item;
GtkWidget *box;
GtkWidget *image;
GtkWidget *label_widget;
item = gtk_menu_item_new ();
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
label_widget = gtk_label_new_with_mnemonic (label);
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (item), box);
return item;
}
#endif
static void
menu_quick_item_with_callback (void *callback, char *label, GtkWidget * menu,
void *arg)
@@ -2026,13 +2005,17 @@ GtkWidget *
create_icon_menu (char *labeltext, void *stock_name, int is_stock)
{
GtkWidget *item, *img;
#if HAVE_GTK3
GtkWidget *box;
GtkWidget *label_widget;
const char *icon_name;
#endif
if (is_stock)
{
#if HAVE_GTK3
const char *icon_name = gtkutil_icon_name_from_stock (stock_name);
item = menu_icon_name_item_new (labeltext, icon_name);
icon_name = gtkutil_icon_name_from_stock (stock_name);
img = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
#endif
#if !HAVE_GTK3
img = gtk_image_new_from_stock (stock_name, GTK_ICON_SIZE_MENU);
@@ -2041,16 +2024,13 @@ create_icon_menu (char *labeltext, void *stock_name, int is_stock)
else
img = gtk_image_new_from_pixbuf (*((GdkPixbuf **)stock_name));
#if HAVE_GTK3
if (!is_stock)
{
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
GtkWidget *label_widget = gtk_label_new_with_mnemonic (labeltext);
item = gtk_menu_item_new ();
item = gtk_menu_item_new ();
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label_widget = gtk_label_new_with_mnemonic (labeltext);
if (img)
gtk_box_pack_start (GTK_BOX (box), img, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (item), box);
}
gtk_box_pack_start (GTK_BOX (box), label_widget, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (item), box);
#endif
#if !HAVE_GTK3
item = gtk_image_menu_item_new_with_mnemonic (labeltext);