
Gnome::Gio::Icon
Interface for icons
Description
Gnome::Gio::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.
Gnome::Gio::Icon does not provide the actual pixmap for the icon as this is out of GIO's scope, however implementations of Gnome::Gio::Icon may contain the name of an icon (see Gnome::Gio::ThemedIcon), or the path to an icon (see Gnome::Gio::LoadableIcon).
To check if two Gnome::Gio::Icons are equal, see equal()
.
Synopsis
Declaration
unit role Gnome::Gio::Icon;
Uml Diagram
class N-GIconIface
GIconIface is used to implement GIcon types for various different systems. See Gnome::Gio::ThemedIcon and Gnome::Gio::LoadableIcon for examples of how to implement this interface.
$.g-iface: The parent interface.
A hash for a given Gnome::Gio::Icon.
Checks if two Gnome::Gio::Icons are equal.
Serializes a Gnome::Gio::Icon into tokens. The tokens must not contain any whitespace. Don't implement if the Gnome::Gio::Icon can't be serialized (Since 2.20).
Constructs a Gnome::Gio::Icon from tokens. Set the Gnome::Gio::Error if the tokens are malformed. Don't implement if the Gnome::Gio::Icon can't be serialized (Since 2.20).
Serializes a Gnome::Gio::Icon into a Gnome::Gio::Variant. Since: 2.38
Methods
deserialize
Deserializes a Gnome::Gio::Icon previously serialized using serialize()
.
Returns: a Gnome::Gio::Icon, or undefined
when deserialization fails.
method deserialize ( N-GObject $value --> N-GObject )
$value; a Gnome::Glib::Variant created with
serialize()
equal
Checks if two icons are equal.
Returns: True
if the icon is equal to $icon. False
otherwise.
method equal ( N-GObject $icon --> Bool )
$icon; pointer to the other Gnome::Gio::Icon.
hash
Gets a hash for an icon.
Virtual: hash
Returns: a guint containing a hash for the icon, suitable for use in a Gnome::Gio::HashTable or similar data structure.
method hash ( Pointer $icon --> UInt )
$icon; gconstpointer to an icon object.
serialize
Serializes a Gnome::Gio::Icon into a Gnome::Glib::Variant. An equivalent Gnome::Gio::Icon can be retrieved back by calling deserialize()
on the returned value. As serialization will avoid using raw icon data when possible, it only makes sense to transfer the Gnome::Glib::Variant between processes on the same machine, (as opposed to over the network), and within the same file system namespace.
Returns: a Gnome::Glib::Variant, or undefined
when serialization fails.
method serialize ( --> N-GObject )
to-string
Generates a textual representation of this icon that can be used for serialization such as when passing an icon to a different process or saving it to persistent storage. Use Some-Icon-Child.new(:string)
to get this icon back from the returned string.
The encoding of the returned string is proprietary to Gnome::Gio::Icon except in the following two cases
If the icon is a Gnome::Gio::FileIcon, the returned string is a native path (such as `/path/to/my icon.png`) without escaping if the Gnome::Gio::File for this icon is a native file. If the file is not native, the returned string is the result of
.get-uri()
(such as `sftp://path/to/my20icon
.png`).If icon is a Gnome::Gio::ThemedIcon with exactly one name and no fallbacks, the encoding is simply the name (such as `network-server`).
Returns: A UTF8 string or undefined
if icon can't be serialized.
method to-string ( --> Str )
Example
my Gnome::Gio::File $file .= new(:path<LICENSE>); my Gnome::Gio::FileIcon $fi .= new(:$file); my Str $fstring = $fi.to-string; … my Gnome::Gio::FileIcon $fi2 .= new(:string($fstring));
_g_icon_new_for_string
Generate a Gnome::Gio::Icon instance from str. This function can fail if str is not valid - see to-string()
for discussion.
If your application or library provides one or more Gnome::Gio::Icon implementations you need to ensure that each Gnome::Glib::Type is registered with the type system prior to calling g-icon-new-for-string()
.
Returns: An object implementing the Gnome::Gio::Icon interface or undefined
if error is set.
method _g_icon_new_for_string ( Str $str, N-GError $error --> N-GObject )
$str; A string obtained via
to-string()
.$error; Return location for error.