mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
Added gtkutil helpers to create stock-based images and buttons while keeping GTK3 icon-name mapping centralized in gtkutil.c.
Exposed the new gtkutil stock helper APIs in the header for reuse. Swapped setup dialog stock button creation to the new gtkutil_button_new_from_stock helper (including the sound play button fallback).
This commit is contained in:
@@ -119,15 +119,46 @@ gtkutil_icon_name_from_stock (const char *stock_name)
|
||||
|
||||
return stock_name;
|
||||
}
|
||||
#endif
|
||||
|
||||
static GtkWidget *
|
||||
GtkWidget *
|
||||
gtkutil_image_new_from_stock (const char *stock, GtkIconSize size)
|
||||
{
|
||||
#if HAVE_GTK3
|
||||
const char *icon_name = gtkutil_icon_name_from_stock (stock);
|
||||
|
||||
return gtk_image_new_from_icon_name (icon_name, size);
|
||||
}
|
||||
#else
|
||||
return gtk_image_new_from_stock (stock, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtkutil_button_new_from_stock (const char *stock, const char *label)
|
||||
{
|
||||
#if HAVE_GTK3
|
||||
GtkWidget *button = label ? gtk_button_new_with_mnemonic (label) : gtk_button_new ();
|
||||
|
||||
if (stock)
|
||||
{
|
||||
GtkWidget *image = gtkutil_image_new_from_stock (stock, GTK_ICON_SIZE_BUTTON);
|
||||
|
||||
if (image)
|
||||
{
|
||||
gtk_button_set_image (GTK_BUTTON (button), image);
|
||||
gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return button;
|
||||
#else
|
||||
if (stock)
|
||||
return gtk_button_new_from_stock (stock);
|
||||
if (label)
|
||||
return gtk_button_new_with_mnemonic (label);
|
||||
return gtk_button_new ();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAVE_GTK3
|
||||
void
|
||||
|
||||
@@ -31,6 +31,8 @@ void gtkutil_destroy (GtkWidget * igad, GtkWidget * dgad);
|
||||
void gtkutil_destroy_on_esc (GtkWidget *win);
|
||||
GtkWidget *gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback,
|
||||
void *userdata, char *labeltext);
|
||||
GtkWidget *gtkutil_image_new_from_stock (const char *stock, GtkIconSize size);
|
||||
GtkWidget *gtkutil_button_new_from_stock (const char *stock, const char *label);
|
||||
#if HAVE_GTK3
|
||||
const char *gtkutil_icon_name_from_stock (const char *stock_name);
|
||||
#endif
|
||||
|
||||
@@ -2415,9 +2415,9 @@ setup_create_sound_page (void)
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
#ifdef GTK_STOCK_MEDIA_PLAY
|
||||
sound_play = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY);
|
||||
sound_play = gtkutil_button_new_from_stock (GTK_STOCK_MEDIA_PLAY, _("_Play"));
|
||||
#else
|
||||
sound_play = gtk_button_new_with_mnemonic (_("_Play"));
|
||||
sound_play = gtkutil_button_new_from_stock (NULL, _("_Play"));
|
||||
#endif
|
||||
g_signal_connect (G_OBJECT (sound_play), "clicked",
|
||||
G_CALLBACK (setup_snd_play_cb), sndfile_entry);
|
||||
@@ -3023,12 +3023,12 @@ setup_window_open (void)
|
||||
gtk_box_set_spacing (GTK_BOX (hbbox), 4);
|
||||
gtk_box_pack_end (GTK_BOX (vbox), hbbox, FALSE, FALSE, 0);
|
||||
|
||||
cancel_button = wid = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
||||
cancel_button = wid = gtkutil_button_new_from_stock (GTK_STOCK_CANCEL, _("_Cancel"));
|
||||
g_signal_connect (G_OBJECT (wid), "clicked",
|
||||
G_CALLBACK (gtkutil_destroy), win);
|
||||
gtk_box_pack_start (GTK_BOX (hbbox), wid, FALSE, FALSE, 0);
|
||||
|
||||
wid = gtk_button_new_from_stock (GTK_STOCK_OK);
|
||||
wid = gtkutil_button_new_from_stock (GTK_STOCK_OK, _("_OK"));
|
||||
g_signal_connect (G_OBJECT (wid), "clicked",
|
||||
G_CALLBACK (setup_ok_cb), win);
|
||||
gtk_box_pack_start (GTK_BOX (hbbox), wid, FALSE, FALSE, 0);
|
||||
|
||||
Reference in New Issue
Block a user