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 |
This section describes the ContentFormats
structure that is used to
advertise and negotiate the format of content passed between different
widgets, windows or applications using for example the clipboard or
drag'n'drop.
GDK supports content in 2 forms: GType
and mime type.
Using GTypes
is meant only for in-process content transfers. Mime types
are meant to be used for data passing both in-process and out-of-process.
The details of how data is passed is described in the documentation of
the actual implementations.
A ContentFormats
describes a set of possible formats content can be
exchanged in. It is assumed that this set is ordered. GTypes
are more
important than mime types. Order between different GTypes
or mime types
is the order they were added in, most important first. Functions that
care about order, such as contentFormatsUnion
will describe in
their documentation how they interpret that order, though in general the
order of the first argument is considered the primary order of the result,
followed by the order of further arguments.
For debugging purposes, the function contentFormatsToString
exists.
It will print a comma-seperated formats of formats from most important to least
important.
ContentFormats
is an immutable struct. After creation, you cannot change
the types it represents. Instead, new ContentFormats
have to be created.
The ContentFormatsBuilder
structure is meant to help in this endeavor.
Synopsis
- newtype ContentFormats = ContentFormats (ManagedPtr ContentFormats)
- contentFormatsContainGtype :: (HasCallStack, MonadIO m) => ContentFormats -> GType -> m Bool
- contentFormatsContainMimeType :: (HasCallStack, MonadIO m) => ContentFormats -> Text -> m Bool
- contentFormatsGetGtypes :: (HasCallStack, MonadIO m) => ContentFormats -> m (Maybe [GType])
- contentFormatsGetMimeTypes :: (HasCallStack, MonadIO m) => ContentFormats -> m (Maybe [Text], Word64)
- contentFormatsMatch :: (HasCallStack, MonadIO m) => ContentFormats -> ContentFormats -> m Bool
- contentFormatsMatchGtype :: (HasCallStack, MonadIO m) => ContentFormats -> ContentFormats -> m GType
- contentFormatsMatchMimeType :: (HasCallStack, MonadIO m) => ContentFormats -> ContentFormats -> m Text
- contentFormatsNew :: (HasCallStack, MonadIO m) => Maybe [Text] -> m ContentFormats
- contentFormatsNewForGtype :: (HasCallStack, MonadIO m) => GType -> m ContentFormats
- contentFormatsPrint :: (HasCallStack, MonadIO m) => ContentFormats -> String -> m ()
- contentFormatsRef :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsToString :: (HasCallStack, MonadIO m) => ContentFormats -> m Text
- contentFormatsUnion :: (HasCallStack, MonadIO m) => ContentFormats -> ContentFormats -> m ContentFormats
- contentFormatsUnionDeserializeGtypes :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsUnionDeserializeMimeTypes :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsUnionSerializeGtypes :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsUnionSerializeMimeTypes :: (HasCallStack, MonadIO m) => ContentFormats -> m ContentFormats
- contentFormatsUnref :: (HasCallStack, MonadIO m) => ContentFormats -> m ()
Exported types
newtype ContentFormats Source #
Memory-managed wrapper type.
Instances
Eq ContentFormats Source # | |
Defined in GI.Gdk.Structs.ContentFormats (==) :: ContentFormats -> ContentFormats -> Bool # (/=) :: ContentFormats -> ContentFormats -> Bool # | |
IsGValue ContentFormats Source # | Convert |
Defined in GI.Gdk.Structs.ContentFormats toGValue :: ContentFormats -> IO GValue # fromGValue :: GValue -> IO ContentFormats # | |
ManagedPtrNewtype ContentFormats Source # | |
Defined in GI.Gdk.Structs.ContentFormats | |
TypedObject ContentFormats Source # | |
Defined in GI.Gdk.Structs.ContentFormats | |
GBoxed ContentFormats Source # | |
Defined in GI.Gdk.Structs.ContentFormats | |
HasParentTypes ContentFormats Source # | |
Defined in GI.Gdk.Structs.ContentFormats | |
type ParentTypes ContentFormats Source # | |
Defined in GI.Gdk.Structs.ContentFormats |
Methods
Overloaded methods
containGtype
contentFormatsContainGtype Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> GType |
|
-> m Bool | Returns: |
Checks if a given GType
is part of the given formats
.
containMimeType
contentFormatsContainMimeType Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> Text |
|
-> m Bool | Returns: |
Checks if a given mime type is part of the given formats
.
getGtypes
contentFormatsGetGtypes Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> m (Maybe [GType]) | Returns:
|
Gets the GTypes
included in formats
. Note that formats
may not
contain any GTypes
, in particular when they are empty. In that
case Nothing
will be returned.
getMimeTypes
contentFormatsGetMimeTypes Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> m (Maybe [Text], Word64) | Returns: |
Gets the mime types included in formats
. Note that formats
may not
contain any mime types, in particular when they are empty. In that
case Nothing
will be returned.
match
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> ContentFormats |
|
-> m Bool | Returns: |
Checks if first
and second
have any matching formats.
matchGtype
contentFormatsMatchGtype Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> ContentFormats |
|
-> m GType | Returns: The first common |
matchMimeType
contentFormatsMatchMimeType Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> ContentFormats |
|
-> m Text | Returns: The first common mime type or |
Finds the first mime type from first
that is also contained
in second
. If no matching mime type is found, Nothing
is
returned.
new
:: (HasCallStack, MonadIO m) | |
=> Maybe [Text] |
|
-> m ContentFormats | Returns: the new |
Creates a new ContentFormats
from an array of mime types.
The mime types must be valid and different from each other or the
behavior of the return value is undefined. If you cannot guarantee
this, use ContentFormatsBuilder
instead.
newForGtype
contentFormatsNewForGtype Source #
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> m ContentFormats | Returns: a new |
Creates a new ContentFormats
for a given GType
.
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> String |
|
-> m () |
Prints the given formats
into a string for human consumption.
This is meant for debugging and logging.
The form of the representation may change at any time and is not guaranteed to stay identical.
ref
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> m ContentFormats | Returns: the passed in |
Increases the reference count of a ContentFormats
by one.
toString
contentFormatsToString Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> m Text | Returns: a new string |
Prints the given formats
into a human-readable string.
This is a small wrapper around contentFormatsPrint
to help
when debugging.
union
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> ContentFormats |
|
-> m ContentFormats | Returns: a new |
Append all missing types from second
to first
, in the order
they had in second
.
unionDeserializeGtypes
contentFormatsUnionDeserializeGtypes Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> m ContentFormats | Returns: a new |
Add GTypes for mime types in formats
for which deserializers are
registered.
unionDeserializeMimeTypes
contentFormatsUnionDeserializeMimeTypes Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> m ContentFormats | Returns: a new |
Add mime types for GTypes in formats
for which deserializers are
registered.
unionSerializeGtypes
contentFormatsUnionSerializeGtypes Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> m ContentFormats | Returns: a new |
Add GTypes for the mime types in formats
for which serializers are
registered.
unionSerializeMimeTypes
contentFormatsUnionSerializeMimeTypes Source #
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> m ContentFormats | Returns: a new |
Add mime types for GTypes in formats
for which serializers are
registered.
unref
:: (HasCallStack, MonadIO m) | |
=> ContentFormats |
|
-> m () |
Decreases the reference count of a ContentFormats
by one.
If the resulting reference count is zero, frees the formats.