gi-gdk-4.0.2: Gdk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gdk.Objects.ContentProvider

Description

A GdkContentProvider is used to provide content for the clipboard 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

Exported types

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

Instances details
(GObject o, IsDescendantOf ContentProvider o) => IsContentProvider o Source # 
Instance details

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

Overloaded methods

contentChanged

contentProviderContentChanged Source #

Arguments

:: (HasCallStack, MonadIO m, IsContentProvider a) 
=> a

provider: a ContentProvider

-> m () 

Emits the contentChanged signal.

getValue

contentProviderGetValue Source #

Arguments

:: (HasCallStack, MonadIO m, IsContentProvider a) 
=> a

provider: a ContentProvider

-> GValue

value: the Value to fill

-> m ()

(Can throw GError)

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 #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

mimeType: the mime type

-> Bytes

bytes: a Bytes with the data for mimeType

-> m ContentProvider

Returns: a new ContentProvider

Create a content provider that provides the given bytes as data for the given mimeType.

newForValue

contentProviderNewForValue Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> GValue

value: a Value

-> m ContentProvider

Returns: a new ContentProvider

Create a content provider that provides the given value.

newUnion

contentProviderNewUnion Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Maybe [ContentProvider]

providers: The GdkContentProviders to present the union of

-> m ContentProvider

Returns: a new ContentProvider

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 iamge 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 #

Arguments

:: (HasCallStack, MonadIO m, IsContentProvider a) 
=> a

provider: a ContentProvider

-> m ContentFormats

Returns: The formats of the provider

Gets the formats that the provider can provide its current contents in.

refStorableFormats

contentProviderRefStorableFormats Source #

Arguments

:: (HasCallStack, MonadIO m, IsContentProvider a) 
=> a

provider: a ContentProvider

-> 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 #

Arguments

:: (HasCallStack, MonadIO m, IsContentProvider a, IsOutputStream b, IsCancellable c) 
=> a

provider: a ContentProvider

-> Text

mimeType: the mime type to provide the data in

-> b

stream: the OutputStream to write to

-> Int32

ioPriority: the [I/O priority][io-priority] of the request.

-> Maybe c

cancellable: optional Cancellable object, Nothing to ignore.

-> Maybe AsyncReadyCallback

callback: callback to call when the request is satisfied

-> m () 

Asynchronously writes the contents of provider to stream in the given mimeType. When the operation is finished callback will be called. You can 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 #

Arguments

:: (HasCallStack, MonadIO m, IsContentProvider a, IsAsyncResult b) 
=> a

provider: a ContentProvider

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes an asynchronous write operation started with contentProviderWriteMimeTypeAsync.

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 C_ContentProviderContentChangedCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type ContentProviderContentChangedCallback = IO () Source #

Emitted whenever the content provided by this provider has changed.

afterContentProviderContentChanged :: (IsContentProvider a, MonadIO m) => 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

onContentProviderContentChanged :: (IsContentProvider a, MonadIO m) => 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