set_from_file_async


Description:

public async void set_from_file_async (File file, int width, int height, bool preserve_aspect_ratio, Cancellable? cancellable = null) throws Error

Sets the image to display a GLib.File with requested width and height.

Note that this method is not a wrapper to the main Granite.AsyncImage.set_from_gicon_async method. Internally, it only creates a Gdk.Pixbuf with an GLib.InputStream, loads it asynchronously and sets the Gtk.Image's surface to the result.

This method will reset the Granite.AsyncImage.gicon_async and Granite.AsyncImage.size_async properties to their default values and will not make the Granite.AsyncImage update the image when the scale factor or icon theme changes.

For the time that the image is loaded, the size request of the AsyncImage will be set to width and height if auto_size_request is set to true

Parameters:

file

the GLib.File to display in the image

width

the width of the final image, -1 to not constrain the width

height

the height of the final image, -1 to not constrain the height

preserve_aspect_ratio

true to preserve the image's aspect ratio

cancellable

the cancellable to stop loading the image

Exceptions:

GLib.Error

when the the file was not found or failed to load




2022 vala-language.org