Basics
Guides
API Reference
Basics
Guides
API Reference
[32:7] extends: 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 GIcons 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.
Icon (Handle = null)
Creates a new
Iconby wrapping a native handle or another wrapper.
Handle is the native handle or another wrapper whose handle to adopt.toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.equal (object icon2)
Checks if two icons are equal.
icon2 is pointer to the second #GIcon..hash ()
Gets a hash for an icon.
serialize ()
Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved back by calling g_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.
to_string ()
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 g_icon_new_for_string() to get @icon back from the returned string. The encoding of the returned string is proprietary to #GIcon except in the following two cases - If @icon is a #GFileIcon, the returned string is a native path (such as
/path/to/my icon.png) without escaping if the #GFile for @icon is a native file. If the file is not native, the returned string is the result of g_file_get_uri() (such assftp://path/to/my%20icon.png). - If @icon is a #GThemedIcon with exactly one name and no fallbacks, the encoding is simply the name (such asnetwork-server).

Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.