Gio.Icon¶
- Implementations:
Gio.BytesIcon
,Gio.Emblem
,Gio.EmblemedIcon
,Gio.FileIcon
,Gio.ThemedIcon
Methods¶
class |
|
class |
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
|
|
Properties¶
None
Signals¶
None
Fields¶
None
Class Details¶
- class Gio.Icon¶
- Bases:
- Structure:
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 ofGIcon
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 compliantGIcon
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.- classmethod deserialize(value)[source]¶
- Parameters:
value (
GLib.Variant
) – aGLib.Variant
created withGio.Icon.serialize
()- Returns:
- Return type:
Deserializes a
Gio.Icon
previously serialized usingGio.Icon.serialize
().New in version 2.38.
- classmethod new_for_string(str)[source]¶
- Parameters:
str (
str
) – A string obtained viaGio.Icon.to_string
().- Raises:
- Returns:
An object implementing the
Gio.Icon
interface orNone
if error is set.- Return type:
Generate a
Gio.Icon
instance from str. This function can fail if str is not valid - seeGio.Icon.to_string
() for discussion.If your application or library provides one or more
Gio.Icon
implementations you need to ensure that eachGObject.GType
is registered with the type system prior to callingGio.Icon.new_for_string
().New in version 2.20.
- hash()[source]¶
- Returns:
a
int
containing a hash for the self, suitable for use in aGLib.HashTable
or similar data structure.- Return type:
Gets a hash for an icon.
- serialize()[source]¶
- Returns:
a
GLib.Variant
, orNone
when serialization fails. TheGLib.Variant
will not be floating.- Return type:
GLib.Variant
orNone
Serializes a
Gio.Icon
into aGLib.Variant
. An equivalentGio.Icon
can be retrieved back by callingGio.Icon.deserialize
() on the returned value. As serialization will avoid using raw icon data when possible, it only makes sense to transfer theGLib.Variant
between processes on the same machine, (as opposed to over the network), and within the same file system namespace.New in version 2.38.
- to_string()[source]¶
- Returns:
An allocated NUL-terminated UTF8 string or
None
if self can’t be serialized. UseGLib.free
() to free.- Return type:
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
Gio.Icon.new_for_string
() to get self back from the returned string.The encoding of the returned string is proprietary to
Gio.Icon
except in the following two casesIf self is a
Gio.FileIcon
, the returned string is a native path (such as/path/to/my icon.png
) without escaping if theGio.File
for self is a native file. If the file is not native, the returned string is the result ofGio.File.get_uri
() (such assftp://path/to/my%20icon.png
).If self is a
Gio.ThemedIcon
with exactly one name and no fallbacks, the encoding is simply the name (such asnetwork-server
).
New in version 2.20.
- do_equal(icon2) virtual¶
- Parameters:
- Returns:
- Return type:
Checks if two icons are equal.
- do_hash() virtual¶
- Returns:
a
int
containing a hash for the icon, suitable for use in aGLib.HashTable
or similar data structure.- Return type:
Gets a hash for an icon.
- do_serialize() virtual¶
- Returns:
a
GLib.Variant
, orNone
when serialization fails. TheGLib.Variant
will not be floating.- Return type:
GLib.Variant
orNone
Serializes a
Gio.Icon
into aGLib.Variant
. An equivalentGio.Icon
can be retrieved back by callingGio.Icon.deserialize
() on the returned value. As serialization will avoid using raw icon data when possible, it only makes sense to transfer theGLib.Variant
between processes on the same machine, (as opposed to over the network), and within the same file system namespace.New in version 2.38.
- do_to_tokens() virtual¶
- Returns:
True
if serialization took place,False
otherwise- tokens:
The array to fill with tokens
- out_version:
version of serialized tokens
- Return type:
Serializes the icon into string tokens. This is can be invoked when
Gio.Icon.new_for_string
() is called.New in version 2.20.