Expanded GTK3 icon-menu construction in menu.c to build menu items with a GtkBox, GtkImage, and mnemonic label when using icon names.

Updated channel list icon menu items to build GTK3 menu items with GtkBox/GtkImage/GtkLabel while preserving GTK2 GtkImageMenuItem paths.
Updated sexy spell entry icon menu items to build GTK3 menu items with GtkBox/GtkImage/GtkLabel while preserving GTK2 GtkImageMenuItem paths
This commit is contained in:
2026-01-23 16:00:02 -07:00
parent b0a9f34dc4
commit 5538e738a8
3 changed files with 18 additions and 31 deletions

View File

@@ -124,11 +124,12 @@ chanlist_icon_button (const char *label, const char *icon_name,
return button;
}
#if HAVE_GTK3
static GtkWidget *
chanlist_menu_item_new_with_icon (const char *label, const char *icon_name)
chanlist_icon_menu_item (const char *label, const char *icon_name,
GCallback callback, gpointer userdata)
{
GtkWidget *item;
#if HAVE_GTK3
GtkWidget *box;
GtkWidget *image = NULL;
GtkWidget *label_widget;
@@ -142,18 +143,6 @@ chanlist_menu_item_new_with_icon (const char *label, const char *icon_name)
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 GtkWidget *
chanlist_icon_menu_item (const char *label, const char *icon_name,
GCallback callback, gpointer userdata)
{
GtkWidget *item;
#if HAVE_GTK3
item = chanlist_menu_item_new_with_icon (label, icon_name);
#endif
#if !HAVE_GTK3
GtkWidget *image;

View File

@@ -283,12 +283,22 @@ menu_item_new_with_image_and_label (GtkWidget *image, const char *label)
static GtkWidget *
menu_item_new_with_icon_name_and_label (const char *icon_name, const char *label)
{
GtkWidget *item;
GtkWidget *box;
GtkWidget *image = NULL;
GtkWidget *label_widget;
item = gtk_menu_item_new ();
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
if (icon_name)
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
label_widget = gtk_label_new_with_mnemonic (label);
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);
return menu_item_new_with_image_and_label (image, label);
return item;
}
#endif

View File

@@ -629,15 +629,17 @@ build_suggestion_menu(SexySpellEntry *entry, GtkWidget *menu, struct EnchantDict
enchant_dict_free_suggestions(dict, suggestions);
}
#if HAVE_GTK3
static GtkWidget *
sexy_spell_entry_menu_item_new_with_icon (const char *label, const char *icon_name)
sexy_spell_entry_icon_menu_item (const char *label, const char *stock_name)
{
GtkWidget *item;
#if HAVE_GTK3
const char *icon_name;
GtkWidget *box;
GtkWidget *image = NULL;
GtkWidget *label_widget;
icon_name = gtkutil_icon_name_from_stock (stock_name);
item = gtk_menu_item_new ();
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
if (icon_name)
@@ -647,20 +649,6 @@ sexy_spell_entry_menu_item_new_with_icon (const char *label, const char *icon_na
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 GtkWidget *
sexy_spell_entry_icon_menu_item (const char *label, const char *stock_name)
{
GtkWidget *item;
#if HAVE_GTK3
const char *icon_name;
icon_name = gtkutil_icon_name_from_stock (stock_name);
item = sexy_spell_entry_menu_item_new_with_icon (label, icon_name);
#endif
#if !HAVE_GTK3
GtkWidget *image;