Restructured icon menu item creation in menu_quick_item to use explicit GTK3 GtkMenuItem + GtkBox + GtkImage/GtkLabel handling with a GTK2 GtkImageMenuItem fallback.

Added GTK3 image null checks and explicit GTK3/GTK2 branching for chanlist icon menu items.
Added GTK3 image null checks and explicit GTK3/GTK2 branching for sexy spell entry icon menu items.
This commit is contained in:
2026-01-23 14:09:50 -07:00
parent 853c16a9bc
commit 7694d4dd18
3 changed files with 9 additions and 13 deletions

View File

@@ -138,11 +138,11 @@ chanlist_icon_menu_item (const char *label, const char *icon_name,
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);
if (image)
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);
#endif
#if !HAVE_GTK3
#else
GtkWidget *image;
item = gtk_image_menu_item_new_with_mnemonic (label);

View File

@@ -284,9 +284,6 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
/*if (flags & XCMENU_MARKUP)
item = gtk_image_menu_item_new_with_markup (label);
else*/
#if !HAVE_GTK3
item = gtk_image_menu_item_new_with_mnemonic (label);
#endif
img = NULL;
if (access (icon, R_OK) == 0) /* try fullpath */
img = gtk_image_new_from_file (icon);
@@ -301,8 +298,7 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
#if HAVE_GTK3
icon_name = gtkutil_icon_name_from_stock (icon);
img = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
#endif
#if !HAVE_GTK3
#else
img = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_MENU);
#endif
}
@@ -317,9 +313,9 @@ menu_quick_item (char *cmd, char *label, GtkWidget * menu, int flags,
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);
#endif
#else
item = gtk_image_menu_item_new_with_mnemonic (label);
if (img)
#if !HAVE_GTK3
gtk_image_menu_item_set_image ((GtkImageMenuItem *)item, img);
#endif
}

View File

@@ -644,11 +644,11 @@ sexy_spell_entry_icon_menu_item (const char *label, const char *stock_name)
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);
if (image)
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);
#endif
#if !HAVE_GTK3
#else
GtkWidget *image;
item = gtk_image_menu_item_new_with_label (label);