static void _gtk_image_set_from_file_scaled(GtkWidget * img, ImgData * data) { if (data->pixbuf != NULL) { g_object_unref(data->pixbuf); data->pixbuf = NULL; } /* if there is a cached hilighted version of this pixbuf, free it */ if (data->hilight != NULL) { g_object_unref(data->hilight); data->hilight = NULL; } if (G_LIKELY(G_IS_THEMED_ICON(data->icon))) data->pixbuf = fm_pixbuf_from_icon_with_fallback(data->icon, data->size, "application-x-executable"); else { char *file = g_icon_to_string(fm_icon_get_gicon(data->icon)); data->pixbuf = gdk_pixbuf_new_from_file_at_scale(file, -1, data->size, TRUE, NULL); g_free(file); } if (data->pixbuf != NULL) { /* Set the pixbuf into the image widget. */ gtk_image_set_from_pixbuf((GtkImage *)img, data->pixbuf); } else { /* No pixbuf available. Set the "missing image" icon. */ gtk_image_set_from_stock(GTK_IMAGE(img), GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_BUTTON); } }
/** * fm_pixbuf_from_icon * @icon: icon descriptor * @size: size in pixels * * Creates a #GdkPixbuf and draws icon there. * * Before 1.0.0 this call had name fm_icon_get_pixbuf. * * Returns: (transfer full): an image. * * Since: 0.1.0 */ GdkPixbuf* fm_pixbuf_from_icon(FmIcon* icon, int size) { return fm_pixbuf_from_icon_with_fallback(icon, size, NULL); }