AsyncImage


Object Hierarchy:

Granite.AsyncImage Granite.AsyncImage Granite.AsyncImage Gtk.Image Gtk.Image Gtk.Image->Granite.AsyncImage Gtk.Misc Gtk.Misc Gtk.Misc->Gtk.Image Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Misc GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Atk.Implementor Atk.Implementor Atk.Implementor->Gtk.Image Atk.Implementor->Gtk.Misc Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.Image Gtk.Buildable->Gtk.Misc Gtk.Buildable->Gtk.Widget

Description:


public class AsyncImage : Image

AsyncImage is a Gtk.Image that provides a way to load icons and images asynchronously without blocking the main GTK thread.

AsyncImage can be used to improve your GTK interface's performance that has a lot of images to load and populate e.g: the applications menu and an icon chooser.

Primarily the Gtk.Image loads it's surface synchronously and blocks the main GTK thread which can cause significant slow downs and lagging. The AsyncImage is a wrapper for the Gtk.Image and provides with two main methods: Granite.AsyncImage.set_from_gicon_async and Granite.AsyncImage.set_from_file_async.

AsyncImage internally operates only on Gdk.Pixbuf and Cairo.Surface's which means that you cannot read valid properties from the main Gtk.Image like Gtk.Image.icon_name, Gtk.Image.gicon or Gtk.Image.file. The only property which will be set is the final surface: Gtk.Image.surface.

Even though AsyncImage sets only the Gtk.Image.surface, it automatically detects changes to the underlying Gtk.Widget.scale_factor and reloads the icon to a new scale factor when it changes. If you request to set an GLib.ThemedIcon and the icon or GTK theme changes the AsyncImage will also reload it to display the new icon with applied changes.

The Granite.AsyncImage.gicon_async and Granite.AsyncImage.size_async are properties which reflect the current icon and it's size which will or is currently displayed. Note that those two properties will return meaningful results only when you call Granite.AsyncImage.set_from_gicon_async and it's wrappers.

AsyncImage has also its own cache for already loaded icons. If you attempt to load the same icon at the same size AsyncImage will look it up and if it's available, will set it immediately.

If you want to detect when the image was actually loaded into the Cairo.Surface you can connect to the GLib.Object.notify signal for Gtk.Image.surface.


Namespace: Granite
Package: granite

Content:

Properties:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class Gtk.Misc
All known members inherited from class Gtk.Widget
All known members inherited from interface Atk.Implementor