diff options
author | Yosef Or Boczko <yoseforb@gmail.com> | 2013-08-14 10:41:42 +0300 |
---|---|---|
committer | Yosef Or Boczko <yoseforb@gmail.com> | 2013-08-14 10:41:42 +0300 |
commit | 2f77a61e61d6eb1d99f74b262c63059726a2ec08 (patch) | |
tree | 8c4d6b60f9724e4c4cd6b2f506fbe2c00d2080ae /gtk/gtkbutton.c | |
parent | 6ea4c1a1f4bd42eac4b0384c390be6732a02763f (diff) | |
download | gtk+-2f77a61e61d6eb1d99f74b262c63059726a2ec08.tar.gz |
Add gtk_button_new_from_icon_name
This function is a convenience wrapper around
gtk_button_new() and gtk_button_set_image().
https://bugzilla.gnome.org/show_bug.cgi?id=705918
Signed-off-by: Yosef Or Boczko <yoseforb@gmail.com>
Diffstat (limited to 'gtk/gtkbutton.c')
-rw-r--r-- | gtk/gtkbutton.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 7396cb8add..3074e7e1eb 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -1298,6 +1298,42 @@ gtk_button_new_with_label (const gchar *label) } /** + * gtk_button_new_from_icon_name: + * @icon_name: an icon name + * @size: (type int): an icon size + * + * Creates a new #GtkButton containing an icon from the current icon theme. + * + * If the icon name isn't known, a "broken image" icon will be + * displayed instead. If the current icon theme is changed, the icon + * will be updated appropriately. + * + * This function is a convenience wrapper around gtk_button_new() and + * gtk_button_set_image(). + * + * Returns: a new #GtkButton displaying the themed icon + * + * Since: 3.10 + **/ +GtkWidget* +gtk_button_new_from_icon_name (const gchar *icon_name, + GtkIconSize size) +{ + GtkStyleContext *context; + GtkWidget *button; + GtkWidget *image; + + image = gtk_image_new_from_icon_name (icon_name, size); + button = g_object_new (GTK_TYPE_BUTTON, + "image", image, + NULL); + context = gtk_widget_get_style_context (button); + gtk_style_context_add_class (context, "image-button")); + + return button; +} + +/** * gtk_button_new_from_stock: * @stock_id: the name of the stock item * |