Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
A GdkContentProvider
is used to provide content for the clipboard or
for drag-and-drop operations in a number of formats.
To create a GdkContentProvider
, use contentProviderNewForValue
or contentProviderNewForBytes
.
GDK knows how to handle common text and image formats out-of-the-box. See
ContentSerializer
and ContentDeserializer
if you want
to add support for application-specific data formats.
Synopsis
- newtype ContentProvider = ContentProvider (ManagedPtr ContentProvider)
- class (GObject o, IsDescendantOf ContentProvider o) => IsContentProvider o
- toContentProvider :: (MonadIO m, IsContentProvider o) => o -> m ContentProvider
- contentProviderContentChanged :: (HasCallStack, MonadIO m, IsContentProvider a) => a -> m ()
- contentProviderGetValue :: (HasCallStack, MonadIO m, IsContentProvider a) => a -> m GValue
- contentProviderNewForBytes :: (HasCallStack, MonadIO m) => Text -> Bytes -> m ContentProvider
- contentProviderNewForValue :: (HasCallStack, MonadIO m) => GValue -> m ContentProvider
- contentProviderNewUnion :: (HasCallStack, MonadIO m) => Maybe [ContentProvider] -> m ContentProvider
- contentProviderRefFormats :: (HasCallStack, MonadIO m, IsContentProvider a) => a -> m ContentFormats
- contentProviderRefStorableFormats :: (HasCallStack, MonadIO m, IsContentProvider a) => a -> m ContentFormats
- contentProviderWriteMimeTypeAsync :: (HasCallStack, MonadIO m, IsContentProvider a, IsOutputStream b, IsCancellable c) => a -> Text -> b -> Int32 -> Maybe c -> Maybe AsyncReadyCallback -> m ()
- contentProviderWriteMimeTypeFinish :: (HasCallStack, MonadIO m, IsContentProvider a, IsAsyncResult b) => a -> b -> m ()
- getContentProviderFormats :: (MonadIO m, IsContentProvider o) => o -> m (Maybe ContentFormats)
- getContentProviderStorableFormats :: (MonadIO m, IsContentProvider o) => o -> m (Maybe ContentFormats)
- type ContentProviderContentChangedCallback = IO ()
- afterContentProviderContentChanged :: (IsContentProvider a, MonadIO m) => a -> ((?self :: a) => ContentProviderContentChangedCallback) -> m SignalHandlerId
- onContentProviderContentChanged :: (IsContentProvider a, MonadIO m) => a -> ((?self :: a) => ContentProviderContentChangedCallback) -> m SignalHandlerId
Exported types
newtype ContentProvider Source #
Memory-managed wrapper type.
ContentProvider (ManagedPtr ContentProvider) |
Instances
Eq ContentProvider Source # | |
Defined in GI.Gdk.Objects.ContentProvider (==) :: ContentProvider -> ContentProvider -> Bool # (/=) :: ContentProvider -> ContentProvider -> Bool # | |
GObject ContentProvider Source # | |
Defined in GI.Gdk.Objects.ContentProvider | |
ManagedPtrNewtype ContentProvider Source # | |
Defined in GI.Gdk.Objects.ContentProvider toManagedPtr :: ContentProvider -> ManagedPtr ContentProvider | |
TypedObject ContentProvider Source # | |
Defined in GI.Gdk.Objects.ContentProvider | |
HasParentTypes ContentProvider Source # | |
Defined in GI.Gdk.Objects.ContentProvider | |
IsGValue (Maybe ContentProvider) Source # | Convert |
Defined in GI.Gdk.Objects.ContentProvider gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe ContentProvider -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe ContentProvider) | |
type ParentTypes ContentProvider Source # | |
Defined in GI.Gdk.Objects.ContentProvider type ParentTypes ContentProvider = '[Object] |
class (GObject o, IsDescendantOf ContentProvider o) => IsContentProvider o Source #
Type class for types which can be safely cast to ContentProvider
, for instance with toContentProvider
.
Instances
(GObject o, IsDescendantOf ContentProvider o) => IsContentProvider o Source # | |
Defined in GI.Gdk.Objects.ContentProvider |
toContentProvider :: (MonadIO m, IsContentProvider o) => o -> m ContentProvider Source #
Cast to ContentProvider
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, contentChanged, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refFormats, refSink, refStorableFormats, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure, writeMimeTypeAsync, writeMimeTypeFinish.
Getters
getData, getProperty, getQdata, getValue.
Setters
contentChanged
contentProviderContentChanged Source #
:: (HasCallStack, MonadIO m, IsContentProvider a) | |
=> a |
|
-> m () |
Emits the contentChanged signal.
getValue
contentProviderGetValue Source #
:: (HasCallStack, MonadIO m, IsContentProvider a) | |
=> a |
|
-> m GValue | (Can throw |
Gets the contents of provider
stored in value
.
The value
will have been initialized to the GType
the value should be
provided in. This given GType
does not need to be listed in the formats
returned by contentProviderRefFormats
. However, if the
given GType
is not supported, this operation can fail and
G_IO_ERROR_NOT_SUPPORTED
will be reported.
newForBytes
contentProviderNewForBytes Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Bytes |
|
-> m ContentProvider | Returns: a new |
Create a content provider that provides the given bytes
as data for
the given mimeType
.
newForValue
contentProviderNewForValue Source #
:: (HasCallStack, MonadIO m) | |
=> GValue |
|
-> m ContentProvider | Returns: a new |
Create a content provider that provides the given value
.
newUnion
contentProviderNewUnion Source #
:: (HasCallStack, MonadIO m) | |
=> Maybe [ContentProvider] |
|
-> m ContentProvider | Returns: a new |
Creates a content provider that represents all the given providers
.
Whenever data needs to be written, the union provider will try the given
providers
in the given order and the first one supporting a format will
be chosen to provide it.
This allows an easy way to support providing data in different formats. For example, an image may be provided by its file and by the image contents with a call such as
c code
gdk_content_provider_new_union ((GdkContentProvider *[2]) { gdk_content_provider_new_typed (G_TYPE_FILE, file), gdk_content_provider_new_typed (G_TYPE_TEXTURE, texture) }, 2);
refFormats
contentProviderRefFormats Source #
:: (HasCallStack, MonadIO m, IsContentProvider a) | |
=> a |
|
-> m ContentFormats | Returns: The formats of the provider |
Gets the formats that the provider can provide its current contents in.
refStorableFormats
contentProviderRefStorableFormats Source #
:: (HasCallStack, MonadIO m, IsContentProvider a) | |
=> a |
|
-> m ContentFormats | Returns: The storable formats of the provider |
Gets the formats that the provider suggests other applications to store the data in.
An example of such an application would be a clipboard manager.
This can be assumed to be a subset of contentProviderRefFormats
.
writeMimeTypeAsync
contentProviderWriteMimeTypeAsync Source #
:: (HasCallStack, MonadIO m, IsContentProvider a, IsOutputStream b, IsCancellable c) | |
=> a |
|
-> Text |
|
-> b |
|
-> Int32 |
|
-> Maybe c |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously writes the contents of provider
to stream
in the given
mimeType
.
When the operation is finished callback
will be called. You must then call
contentProviderWriteMimeTypeFinish
to get the result
of the operation.
The given mime type does not need to be listed in the formats returned by
contentProviderRefFormats
. However, if the given GType
is
not supported, G_IO_ERROR_NOT_SUPPORTED
will be reported.
The given stream
will not be closed.
writeMimeTypeFinish
contentProviderWriteMimeTypeFinish Source #
:: (HasCallStack, MonadIO m, IsContentProvider a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
Finishes an asynchronous write operation.
Properties
formats
The possible formats that the provider can provide its data in.
getContentProviderFormats :: (MonadIO m, IsContentProvider o) => o -> m (Maybe ContentFormats) Source #
Get the value of the “formats
” property.
When overloading is enabled, this is equivalent to
get
contentProvider #formats
storableFormats
The subset of formats that clipboard managers should store this provider's data in.
getContentProviderStorableFormats :: (MonadIO m, IsContentProvider o) => o -> m (Maybe ContentFormats) Source #
Get the value of the “storable-formats
” property.
When overloading is enabled, this is equivalent to
get
contentProvider #storableFormats
Signals
contentChanged
type ContentProviderContentChangedCallback = IO () Source #
Emitted whenever the content provided by this provider has changed.
afterContentProviderContentChanged :: (IsContentProvider a, MonadIO m) => a -> ((?self :: a) => ContentProviderContentChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the contentChanged signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
contentProvider #contentChanged callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onContentProviderContentChanged :: (IsContentProvider a, MonadIO m) => a -> ((?self :: a) => ContentProviderContentChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the contentChanged signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
contentProvider #contentChanged callback