From a05d2e8a68e05934e00e42f795282cf5f5146ec0 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 26 Nov 2022 14:46:23 +0200 Subject: [PATCH 40/40] gtk4: Make icon_label_button to prefer label over icon See osdn #46116 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/gui_stuff.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/client/gui-gtk-4.0/gui_stuff.c b/client/gui-gtk-4.0/gui_stuff.c index d7734707f0..ca053544f6 100644 --- a/client/gui-gtk-4.0/gui_stuff.c +++ b/client/gui-gtk-4.0/gui_stuff.c @@ -55,17 +55,24 @@ void gtk_expose_now(GtkWidget *w) } /**********************************************************************//** - Create new icon button with label + Create new icon button with label. + + Current implementation sets either icon or label, preferring label, + never both. Caller should not rely on that, though. **************************************************************************/ GtkWidget *icon_label_button_new(const gchar *icon_name, const gchar *label_text) { GtkWidget *button; - button = gtk_button_new_with_mnemonic(label_text); + fc_assert(icon_name != NULL || label_text != NULL); - if (icon_name != NULL) { - gtk_button_set_icon_name(GTK_BUTTON(button), icon_name); + if (label_text != NULL) { + button = gtk_button_new_with_mnemonic(label_text); + } else if (icon_name != NULL) { + button = gtk_button_new_from_icon_name(icon_name); + } else { + button = NULL; } return button; -- 2.35.1