From 5538e738a8071baf7e7f045c0771be40d24acaa1 Mon Sep 17 00:00:00 2001 From: deepend Date: Fri, 23 Jan 2026 16:00:02 -0700 Subject: [PATCH] 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 --- src/fe-gtk/chanlist.c | 17 +++-------------- src/fe-gtk/menu.c | 12 +++++++++++- src/fe-gtk/sexy-spell-entry.c | 20 ++++---------------- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c index b571cec7..6880e1d6 100644 --- a/src/fe-gtk/chanlist.c +++ b/src/fe-gtk/chanlist.c @@ -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; diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index f5b5ebf6..32b55fa3 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -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 diff --git a/src/fe-gtk/sexy-spell-entry.c b/src/fe-gtk/sexy-spell-entry.c index 63e5662c..3a74ff35 100644 --- a/src/fe-gtk/sexy-spell-entry.c +++ b/src/fe-gtk/sexy-spell-entry.c @@ -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;