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
Contents
Description
tIcon
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.
tIcon
does not provide the actual pixmap for the icon as this is out
of GIO's scope, however implementations of tIcon
may contain the name
of an icon (see tThemedIcon
), or the path to an icon (see tLoadableIcon
).
To obtain a hash of a tIcon
, see iconHash
.
To check if two GIcons
are equal, see iconEqual
.
For serializing a tIcon
, use iconSerialize
and
iconDeserialize
.
If you want to consume tIcon
(for example, in a toolkit) you must
be prepared to handle at least the three following cases:
tLoadableIcon
, tThemedIcon
and tEmblemedIcon
. It may also make
sense to have fast-paths for other cases (like handling GdkPixbuf
directly, for example) but all compliant tIcon
implementations
outside of GIO must implement tLoadableIcon
.
If your application or library provides one or more tIcon
implementations you need to ensure that your new implementation also
implements tLoadableIcon
. 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.
Instances
Eq Icon Source # | |
GObject Icon Source # | |
Defined in GI.Gio.Interfaces.Icon Methods gobjectType :: IO GType | |
IsGValue Icon Source # | Convert |
Defined in GI.Gio.Interfaces.Icon | |
HasParentTypes Icon Source # | |
Defined in GI.Gio.Interfaces.Icon | |
type ParentTypes Icon Source # | |
Defined in GI.Gio.Interfaces.Icon type ParentTypes Icon = Object ': ([] :: [Type]) |
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 | Returns: a t |
Deserializes a tIcon
previously serialized using iconSerialize
.
Since: 2.38
equal
Arguments
:: (HasCallStack, MonadIO m, IsIcon a, IsIcon b) | |
=> a |
|
-> Maybe b |
|
-> m Bool | Returns: |
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 t |
Generate a tIcon
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 tIcon
implementations you need to ensure that each tGType
is registered
with the type system prior to calling iconNewForString
.
Since: 2.20
serialize
Arguments
:: (HasCallStack, MonadIO m, IsIcon a) | |
=> a |
|
-> m GVariant | Returns: a t |
Serializes a tIcon
into a tGVariant
. An equivalent tIcon
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 tGVariant
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 tIcon
except
in the following two cases
- If
icon
is a tFileIcon
, the returned string is a native path (such as/path/to/my icon.png
) without escaping if the tFile
foricon
is a native file. If the file is not native, the returned string is the result offileGetUri
(such assftp://path/to/my%20icon.png
). - If
icon
is a tThemedIcon
with exactly one name and no fallbacks, the encoding is simply the name (such asnetwork-server
).
Since: 2.20