Icon

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.Icons 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] 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.

Members

Functions

equal
bool equal(gio.icon.Icon icon2)

Checks if two icons are equal.

hash
uint hash()

Gets a hash for an icon.

serialize
glib.variant.VariantG 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 possible, it only makes sense to transfer the #GVariant between processes on the same machine, (as opposed to over the network), and within the same file system namespace.

toString_
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 to get icon back from the returned string.

Static functions

deserialize
gio.icon.Icon deserialize(glib.variant.VariantG value)

Deserializes a #GIcon previously serialized using gio.icon.Icon.serialize.

newForString
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.