Comment obtenir un GdkPixbuf à partir d'un GtkStockItem
Comment obtenir un GdkPixbuf à partir d'un GtkStockItem
Il n'est pas possible de passer par GtkImage car selon les cas, l'image peut être stockée sous forme d'un GdkPixbuf ou d'un GdkPixmap.
Voici la solution en utilisant un widget invisible :
Code:
1 2 3 4 5 6 7 8
| public static Gdk.Pixbuf get_pixbuf_for_stock (string stock_id, Gtk.IconSize size)
{
Gdk.Pixbuf pixbuf;
Gtk.Invisible w = new Gtk.Invisible ();
pixbuf = w.render_icon (stock_id, size, "vala");
return pixbuf;
} |