mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-18 03:30:18 +00:00
Added a helper to create button images from stock names using GTK3 icon mapping, and used it in gtkutil_button for consistent GTK2/GTK3 handling.
This commit is contained in:
@@ -120,6 +120,19 @@ gtkutil_icon_name_from_stock (const char *stock_name)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
gtkutil_image_new_from_stock_name (const char *stock_name)
|
||||||
|
{
|
||||||
|
#if HAVE_GTK3
|
||||||
|
const char *icon_name = gtkutil_icon_name_from_stock (stock_name);
|
||||||
|
|
||||||
|
return gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
||||||
|
#endif
|
||||||
|
#if !HAVE_GTK3
|
||||||
|
return gtk_image_new_from_stock (stock_name, GTK_ICON_SIZE_MENU);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtkutil_file_req_destroy (GtkWidget * wid, struct file_req *freq)
|
gtkutil_file_req_destroy (GtkWidget * wid, struct file_req *freq)
|
||||||
{
|
{
|
||||||
@@ -575,22 +588,13 @@ gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback,
|
|||||||
void *userdata, char *labeltext)
|
void *userdata, char *labeltext)
|
||||||
{
|
{
|
||||||
GtkWidget *wid, *img, *bbox;
|
GtkWidget *wid, *img, *bbox;
|
||||||
#if HAVE_GTK3
|
|
||||||
const char *icon_name;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wid = gtk_button_new ();
|
wid = gtk_button_new ();
|
||||||
|
|
||||||
if (labeltext)
|
if (labeltext)
|
||||||
{
|
{
|
||||||
gtk_button_set_label (GTK_BUTTON (wid), labeltext);
|
gtk_button_set_label (GTK_BUTTON (wid), labeltext);
|
||||||
#if HAVE_GTK3
|
img = gtkutil_image_new_from_stock_name (stock);
|
||||||
icon_name = gtkutil_icon_name_from_stock (stock);
|
|
||||||
img = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
|
||||||
#endif
|
|
||||||
#if !HAVE_GTK3
|
|
||||||
img = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_MENU);
|
|
||||||
#endif
|
|
||||||
gtk_button_set_image (GTK_BUTTON (wid), img);
|
gtk_button_set_image (GTK_BUTTON (wid), img);
|
||||||
gtk_button_set_use_underline (GTK_BUTTON (wid), TRUE);
|
gtk_button_set_use_underline (GTK_BUTTON (wid), TRUE);
|
||||||
if (box)
|
if (box)
|
||||||
@@ -602,13 +606,7 @@ gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback,
|
|||||||
gtk_container_add (GTK_CONTAINER (wid), bbox);
|
gtk_container_add (GTK_CONTAINER (wid), bbox);
|
||||||
gtk_widget_show (bbox);
|
gtk_widget_show (bbox);
|
||||||
|
|
||||||
#if HAVE_GTK3
|
img = gtkutil_image_new_from_stock_name (stock);
|
||||||
icon_name = gtkutil_icon_name_from_stock (stock);
|
|
||||||
img = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
|
|
||||||
#endif
|
|
||||||
#if !HAVE_GTK3
|
|
||||||
img = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_MENU);
|
|
||||||
#endif
|
|
||||||
gtk_container_add (GTK_CONTAINER (bbox), img);
|
gtk_container_add (GTK_CONTAINER (bbox), img);
|
||||||
gtk_widget_show (img);
|
gtk_widget_show (img);
|
||||||
gtk_box_pack_start (GTK_BOX (box), wid, 0, 0, 0);
|
gtk_box_pack_start (GTK_BOX (box), wid, 0, 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user