From 8d76d941317658c78a67cbb77ed8f628a9cc98f3 Mon Sep 17 00:00:00 2001 From: deepend Date: Fri, 23 Jan 2026 11:17:28 -0700 Subject: [PATCH] Added a GTK3-only helper to build button images from stock IDs via icon-name mapping, and refactored gtkutil_button to use it while keeping GTK2 stock handling intact. Verified gtkutil_button(...) callers with rg -n "gtkutil_button\\s*\\(" src/fe-gtk. --- src/fe-gtk/gtkutil.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c index e268a7a9..abcbfd6b 100644 --- a/src/fe-gtk/gtkutil.c +++ b/src/fe-gtk/gtkutil.c @@ -118,6 +118,14 @@ gtkutil_icon_name_from_stock (const char *stock_name) return stock_name; } + +static GtkWidget * +gtkutil_image_new_from_stock (const char *stock, GtkIconSize size) +{ + const char *icon_name = gtkutil_icon_name_from_stock (stock); + + return gtk_image_new_from_icon_name (icon_name, size); +} #endif static void @@ -584,11 +592,7 @@ gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback, img = NULL; #if HAVE_GTK3 if (stock) - { - const char *icon_name = gtkutil_icon_name_from_stock (stock); - - img = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); - } + img = gtkutil_image_new_from_stock (stock, GTK_ICON_SIZE_BUTTON); #endif #if !HAVE_GTK3 if (stock) @@ -609,11 +613,7 @@ gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback, img = NULL; #if HAVE_GTK3 if (stock) - { - const char *icon_name = gtkutil_icon_name_from_stock (stock); - - img = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); - } + img = gtkutil_image_new_from_stock (stock, GTK_ICON_SIZE_BUTTON); #endif #if !HAVE_GTK3 if (stock)