<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
<GThemedIcon>), or the path to an icon (see
<GLoadableIcon>).
To obtain a hash of a <GIcon>, see icon:hash.
To check if two <GIcon>s are equal, see
icon:equal?.
For serializing a <GIcon>, use icon:serialize and 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: <GLoadableIcon>,
<GThemedIcon> and
<GEmblemedIcon>. 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
<GLoadableIcon>.
If your application or library provides one or more
<GIcon> implementations you need to ensure that your
new implementation also implements
<GLoadableIcon>. Additionally, you must
provide an implementation of icon:serialize
that gives a result that is understood by icon:deserialize, yielding one of the built-in icon
types.
Deserializes a <GIcon> previously serialized using
icon:serialize.
Passed: a <GVariant>.
a <GVariant> created with icon:serialize
Returned: a <GIcon>, or #f.
a <GIcon>, or #f when deserialization fails.
Checks if two icons are equal.
Gets a hash for an icon.
Passed: a <GIcon>.
gconstpointer to an icon object.
Returned: an unsigned 32-bit integer.
a guint containing a hash for the self, suitable for use in
a <GHashTable> or similar data structure.
Generate a <GIcon> instance from str. This
function can fail if str is not valid - see icon:to-string for discussion.
If your application or library provides one or more
<GIcon> implementations you need to ensure that each
GType is registered with the type system prior to calling
icon-new-for-string.
Passed: a string.
A string obtained via icon:to-string.
Returned: a <GIcon>.
An object implementing the <GIcon> interface or
#f if error is set.
Serializes a <GIcon> into a
<GVariant>. An equivalent
<GIcon> can be retrieved back by calling
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.
Passed: a <GIcon>.
a <GIcon>
Returned: a <GVariant>, or #f.
a <GVariant>, or #f when serialization
fails. The <GVariant> will not be floating.
Generates a textual representation of self that can be used for
serialization such as when passing self to a different process or
saving it to persistent storage. Use
icon-new-for-string to get self
back from the returned string.
The encoding of the returned string is proprietary to
<GIcon> except in the following two cases
<GFileIcon>, the returned
string is a native path (such as /path/to/my icon.png) without
escaping if the <GFile> for self is a native
file. If the file is not native, the returned string is the result of
file:get-uri (such as
sftp://path/to/my%20icon.png).
<GThemedIcon> with exactly
one name and no fallbacks, the encoding is simply the name (such as
network-server).
Passed: a <GIcon>.
a <GIcon>.
Returned: a string, or #f.
An allocated NUL-terminated UTF8 string or #f if self can’t
be serialized. Use byte-array:free to free.
Checks if two icons are equal.
To override it in a new class, give register-type #:vfuncs
`((equal . ,procedure)). The procedure is called as (procedure
self icon2) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GIcon>, or its GType number.
Passed: a <GIcon>.
pointer to the first <GIcon>.
Passed, or left out: a <GIcon>, or #f.
pointer to the second <GIcon>.
Returned: a boolean.
#t if self is equal to icon2. #f otherwise.
Gets a hash for an icon.
To override it in a new class, give register-type #:vfuncs
`((hash . ,procedure)). The procedure is called as (procedure
self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GIcon>, or its GType number.
Passed: a <GIcon>.
gconstpointer to an icon object.
Returned: an unsigned 32-bit integer.
a guint containing a hash for the self, suitable for use in
a <GHashTable> or similar data structure.
Serializes a <GIcon> into a
<GVariant>. An equivalent
<GIcon> can be retrieved back by calling
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 override it in a new class, give register-type #:vfuncs
`((serialize . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GIcon>, or its GType number.
Passed: a <GIcon>.
a <GIcon>
Returned: a <GVariant>, or #f.
a <GVariant>, or #f when serialization
fails. The <GVariant> will not be floating.
Serializes the self into string tokens. This is can be invoked
when icon-new-for-string is called.
To override it in a new class, give register-type #:vfuncs
`((to-tokens . ,procedure)). The procedure is called as
(procedure self tokens) ⇒ %return out-version.
Passed: the class whose implementation to call: a class that implements
<GIcon>, or its GType number.
Passed: a <GIcon>.
The <GIcon>
Passed: a list or vector, each a string. It is filled in, and returned: a vector, each a string.
The array to fill with tokens
Returned: a boolean.
#t if serialization took place, #f otherwise
Returned: a 32-bit integer.
version of serialized tokens