gio.icon

Module for [Icon] interface

Types 2

interfaceIcon

[gio.icon.Icon] 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.

[gio.icon.Icon] does not provide the actual pixmap for the icon as this is out of GIO's scope, however implementations of [gio.icon.Icon] may contain the name of an icon (see [gio.themed_icon.ThemedIcon]), or the path to an icon (see [gio.loadable_icon.LoadableIcon]).

To obtain a hash of a [gio.icon.Icon], see [gio.icon.Icon.hash].

To check if two [gio.icon.Icon]s are equal, see [gio.icon.Icon.equal].

For serializing a [gio.icon.Icon], use [gio.icon.Icon.serialize] and [gio.icon.Icon.deserialize].

If you want to consume [gio.icon.Icon] (for example, in a toolkit) you must be prepared to handle at least the three following cases: [gio.loadable_icon.LoadableIcon], [gio.themed_icon.ThemedIcon] and [gio.emblemed_icon.EmblemedIcon]. It may also make sense to have fast-paths for other cases (like handling [[gdkpixbuf.pixbuf.Pixbuf]](https://docs.gtk.org/gdk-pixbuf/class.Pixbuf.html) directly, for example) but all compliant [gio.icon.Icon] implementations outside of GIO must implement [gio.loadable_icon.LoadableIcon].

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

Methods
gio.icon.Icon deserialize(glib.variant.Variant value)Deserializes a #GIcon previously serialized using [gio.icon.Icon.serialize].
gio.icon.Icon newForString(string str)Generate a #GIcon instance from str. This function can fail if str is not valid - see [gio.icon.Icon.toString_] for discussion.
bool equal(gio.icon.Icon icon2 = null)Checks if two icons are equal.
uint hash()Gets a hash for an icon. Returns: a #guint containing a hash for the icon, suitable for use in a #GHashTable or similar data structure.
glib.variant.Variant serialize()Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved back by calling [gio.icon.Icon.deserialize] on the returned value. As serialization will avoid using raw icon data when p...
string toString_()Generates a textual representation of icon that can be used for serialization such as when passing icon to a different process or saving it to persistent storage. Use [gio.icon.Icon.newForString] t...
interfaceIconGidBuilderImpl(T)