| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| Language | Haskell2010 |
GI.Gio.Interfaces.Icon
Description
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.
Icon does not provide the actual pixmap for the icon as this is out
of GIO's scope, however implementations of Icon may contain the name
of an icon (see ThemedIcon), or the path to an icon (see LoadableIcon).
To obtain a hash of a Icon, see iconHash.
To check if two GIcons are equal, see iconEqual.
For serializing a Icon, use iconSerialize and
iconDeserialize.
If you want to consume Icon (for example, in a toolkit) you must
be prepared to handle at least the three following cases:
LoadableIcon, ThemedIcon and EmblemedIcon. It may also make
sense to have fast-paths for other cases (like handling GdkPixbuf
directly, for example) but all compliant Icon implementations
outside of GIO must implement LoadableIcon.
If your application or library provides one or more Icon
implementations you need to ensure that your new implementation also
implements LoadableIcon. Additionally, you must provide an
implementation of iconSerialize that gives a result that is
understood by iconDeserialize, yielding one of the built-in icon
types.
Synopsis
- newtype Icon = Icon (ManagedPtr Icon)
- noIcon :: Maybe Icon
- class (GObject o, IsDescendantOf Icon o) => IsIcon o
- toIcon :: (MonadIO m, IsIcon o) => o -> m Icon
- iconDeserialize :: (HasCallStack, MonadIO m) => GVariant -> m Icon
- iconEqual :: (HasCallStack, MonadIO m, IsIcon a, IsIcon b) => a -> Maybe b -> m Bool
- iconHash :: (HasCallStack, MonadIO m) => Ptr () -> m Word32
- iconNewForString :: (HasCallStack, MonadIO m) => Text -> m Icon
- iconSerialize :: (HasCallStack, MonadIO m, IsIcon a) => a -> m GVariant
- iconToString :: (HasCallStack, MonadIO m, IsIcon a) => a -> m (Maybe Text)
Exported types
Memory-managed wrapper type.
Constructors
| Icon (ManagedPtr Icon) |
Instances
| Eq Icon Source # | |
| GObject Icon Source # | |
Defined in GI.Gio.Interfaces.Icon Methods gobjectType :: IO GType # | |
| IsGValue Icon Source # | Convert |
| HasParentTypes Icon Source # | |
Defined in GI.Gio.Interfaces.Icon | |
| type ParentTypes Icon Source # | |
Defined in GI.Gio.Interfaces.Icon | |
class (GObject o, IsDescendantOf Icon o) => IsIcon o Source #
Instances
| (GObject o, IsDescendantOf Icon o) => IsIcon o Source # | |
Defined in GI.Gio.Interfaces.Icon | |
Methods
Overloaded methods
deserialize
Arguments
| :: (HasCallStack, MonadIO m) | |
| => GVariant |
|
| -> m Icon |
Deserializes a Icon previously serialized using iconSerialize.
Since: 2.38
equal
Arguments
| :: (HasCallStack, MonadIO m, IsIcon a, IsIcon b) | |
| => a |
|
| -> Maybe b |
|
| -> m Bool |
Checks if two icons are equal.
hash
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Ptr () |
|
| -> m Word32 | Returns: a |
Gets a hash for an icon.
newForString
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Text |
|
| -> m Icon | Returns: An object implementing the |
Generate a Icon instance from str. This function can fail if
str is not valid - see iconToString for discussion.
If your application or library provides one or more Icon
implementations you need to ensure that each GType is registered
with the type system prior to calling iconNewForString.
Since: 2.20
serialize
Arguments
| :: (HasCallStack, MonadIO m, IsIcon a) | |
| => a |
|
| -> m GVariant |
Serializes a Icon into a GVariant. An equivalent Icon can be retrieved
back by calling iconDeserialize 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.
Since: 2.38
toString
Arguments
| :: (HasCallStack, MonadIO m, IsIcon a) | |
| => a |
|
| -> m (Maybe Text) | Returns: An allocated NUL-terminated UTF8 string or
|
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 iconNewForString to
get icon back from the returned string.
The encoding of the returned string is proprietary to Icon except
in the following two cases
- If
iconis aFileIcon, the returned string is a native path (such as/path/to/my icon.png) without escaping if theFileforiconis a native file. If the file is not native, the returned string is the result offileGetUri(such assftp://path/to/my%20icon.png). - If
iconis aThemedIconwith exactly one name and no fallbacks, the encoding is simply the name (such asnetwork-server).
Since: 2.20