GdkPixbuf object from stock icons



Hi!
  I was looking for a non-hackish way of creating a GdkPixbuf object
out of stock icon. The first thing that comes to mind is:

------------------CODE SNIPPET BEGIN----------------------

image = gtk_image_new_from_stock (stock_id, size);
pixbuf = gtk_image_get_pixbuf (image);

------------------CODE SNIPPET END-------------------------

 However that doesn't work since the created image if of storage type
GTK_IMAGE_STOCK and gtk_image_get_pixbuf() doesn't like that.
Following is the only way i could come up with:

------------------CODE SNIPPET BEGIN----------------------

image = gtk_image_new ();
pixbuf = gtk_widget_render_icon (image, stock_id, size, NULL);

------------------CODE SNIPPET END-------------------------

   This one works quite fine but is obviously hackish, Does anyone
know of any better way of doing the same?

-- 
Regards,

Zeeshan Ali
FSF member#5124



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]