Gio.Icon¶
| Implementations: | |
|---|---|
Gio.BytesIcon, Gio.Emblem, Gio.EmblemedIcon, Gio.FileIcon, Gio.ThemedIcon |
|
Methods¶
| class | deserialize (value) |
| class | hash (icon) |
| class | new_for_string (str) |
equal (icon2) |
|
serialize () |
|
to_string () |
Virtual Methods¶
do_equal (icon2) |
|
do_hash () |
|
do_serialize () |
Properties¶
None
Signals¶
None
Fields¶
None
Class Details¶
-
class
Gio.Icon¶ Bases: GObject.GInterfaceStructure: Gio.IconIfaceGio.Iconis 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.Icondoes not provide the actual pixmap for the icon as this is out of GIO’s scope, however implementations ofGio.Iconmay contain the name of an icon (seeGio.ThemedIcon), or the path to an icon (seeGio.LoadableIcon).To obtain a hash of a
Gio.Icon, seeGio.Icon.hash().To check if two
Gio.Iconsare equal, seeGio.Icon.equal().For serializing a
Gio.Icon, useGio.Icon.serialize() andGio.Icon.deserialize().If you want to consume
Gio.Icon(for example, in a toolkit) you must be prepared to handle at least the three following cases:Gio.LoadableIcon,Gio.ThemedIconandGio.EmblemedIcon. It may also make sense to have fast-paths for other cases (like handling #GdkPixbuf directly, for example) but all compliantGio.Iconimplementations outside of GIO must implementGio.LoadableIcon.If your application or library provides one or more
Gio.Iconimplementations you need to ensure that your new implementation also implementsGio.LoadableIcon. Additionally, you must provide an implementation ofGio.Icon.serialize() that gives a result that is understood byGio.Icon.deserialize(), yielding one of the built-in icon types.-
classmethod
deserialize(value)[source]¶ Parameters: value ( GLib.Variant) – aGLib.Variantcreated withGio.Icon.serialize()Returns: a Gio.Icon, orNonewhen deserialization fails.Return type: Gio.IconDeserializes a
Gio.Iconpreviously serialized usingGio.Icon.serialize().New in version 2.38.
-
classmethod
hash(icon)[source]¶ Parameters: icon ( object) – #gconstpointer to an icon object.Returns: a intcontaining a hash for the icon, suitable for use in aGLib.HashTableor similar data structure.Return type: intGets a hash for an icon.
-
classmethod
new_for_string(str)[source]¶ Parameters: str ( str) – A string obtained viaGio.Icon.to_string().Raises: GLib.ErrorReturns: An object implementing the Gio.Iconinterface orNoneif error is set.Return type: Gio.IconGenerate a
Gio.Iconinstance 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.Iconimplementations you need to ensure that eachGObject.GTypeis registered with the type system prior to callingGio.Icon.new_for_string().New in version 2.20.
-
equal(icon2)[source]¶ Parameters: icon2 ( Gio.IconorNone) – pointer to the secondGio.Icon.Returns: Trueif self is equal to icon2.Falseotherwise.Return type: boolChecks if two icons are equal.
-
serialize()[source]¶ Returns: a GLib.Variant, orNonewhen serialization fails. TheGLib.Variantwill not be floating.Return type: GLib.VariantSerializes a
Gio.Iconinto aGLib.Variant. An equivalentGio.Iconcan 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.Variantbetween 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 Noneif self can’t be serialized. UseGLib.free() to free.Return type: strorNoneGenerates 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.Iconexcept in the following two cases- If self is a
Gio.FileIcon, the returned string is a native path (such as/path/to/my icon.png) without escaping if theGio.Filefor 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.ThemedIconwith exactly one name and no fallbacks, the encoding is simply the name (such asnetwork-server).
New in version 2.20.
- If self is a
-
do_equal(icon2) virtual¶ Parameters: icon2 ( Gio.IconorNone) – pointer to the secondGio.Icon.Returns: Trueif icon1 is equal to icon2.Falseotherwise.Return type: boolChecks if two icons are equal.
-
do_hash() virtual¶ Returns: a intcontaining a hash for the icon, suitable for use in aGLib.HashTableor similar data structure.Return type: intGets a hash for an icon.
-
do_serialize() virtual¶ Returns: a GLib.Variant, orNonewhen serialization fails. TheGLib.Variantwill not be floating.Return type: GLib.VariantSerializes a
Gio.Iconinto aGLib.Variant. An equivalentGio.Iconcan 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.Variantbetween processes on the same machine, (as opposed to over the network), and within the same file system namespace.New in version 2.38.
-
classmethod