Icon


Object Hierarchy:

GLib.Icon GLib.Icon GLib.Icon GLib.Object GLib.Object GLib.Object->GLib.Icon

Description:

[ CCode ( type_id = "g_icon_get_type ()" ) ]
public interface Icon : Object

`GIcon` is a very minimal interface for icons.

It provides functions for checking the equality of two icons, hashing of icons and serializing an icon to and from strings.

`GIcon` does not provide the actual pixmap for the icon as this is out of GIO's scope, however implementations of `GIcon` may contain the name of an icon (see [class@Gio.ThemedIcon]), or the path to an icon (see [iface@Gio.LoadableIcon]).

To obtain a hash of a `GIcon`, see [method@Gio.Icon.hash].

To check if two `GIcon`s are equal, see [method@Gio.Icon.equal].

For serializing a `GIcon`, use [method@Gio.Icon.serialize] and [func@Gio.Icon.deserialize].

If you want to consume `GIcon` (for example, in a toolkit) you must be prepared to handle at least the three following cases: [ iface@Gio.LoadableIcon], [class@Gio.ThemedIcon] and [class@Gio.EmblemedIcon]. It may also make sense to have fast-paths for other cases (like handling `GdkPixbuf` directly, for example) but all compliant `GIcon` implementations outside of GIO must implement [iface@Gio.LoadableIcon].

If your application or library provides one or more `GIcon` implementations you need to ensure that your new implementation also implements [ iface@Gio.LoadableIcon]. Additionally, you must provide an implementation of [method@Gio.Icon.serialize] that gives a result that is understood by [func@Gio.Icon.deserialize], yielding one of the built-in icon types.

Example: FileInfo, async:

public static int main (string[] args) {
if (args.length != 2) {
print ("%s FILE\n", args[0]);
return 0;
}

MainLoop loop = new MainLoop ();

File file = File.new_for_commandline_arg (args[1]);
file.query_info_async.begin ("standard::icon", 0, Priority.DEFAULT, null, (obj, res) => {
try {
FileInfo info = file.query_info_async.end (res);
Icon icon = info.get_icon ();
print ("%s\n", icon.to_string ());
} catch (Error e) {
print ("Error: %s\n", e.message);
}

loop.quit ();
});

loop.run ();
return 0;
}

valac --pkg gio-2.0 GLib.File.query_info_async.vala

All known implementing classes:
All known sub-interfaces:

Namespace: GLib
Package: gio-2.0

Content:

Static methods:

Methods:

Inherited Members: