gi-gdk-4.0.5: Gdk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gdk.Objects.ContentProvider

Description

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

Exported types

newtype ContentProvider Source #

Memory-managed wrapper type.

Constructors

ContentProvider (ManagedPtr ContentProvider) 

Instances

Instances details
Eq ContentProvider Source # 
Instance details

Defined in GI.Gdk.Objects.ContentProvider

GObject ContentProvider Source # 
Instance details

Defined in GI.Gdk.Objects.ContentProvider

ManagedPtrNewtype ContentProvider Source # 
Instance details

Defined in GI.Gdk.Objects.ContentProvider

TypedObject ContentProvider Source # 
Instance details

Defined in GI.Gdk.Objects.ContentProvider

Methods

glibType :: IO GType

HasParentTypes ContentProvider Source # 
Instance details

Defined in GI.Gdk.Objects.ContentProvider

IsGValue (Maybe ContentProvider) Source #

Convert ContentProvider to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gdk.Objects.ContentProvider

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe ContentProvider -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe ContentProvider)

type ParentTypes ContentProvider Source # 
Instance details

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

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

contentChanged

contentProviderContentChanged Source #

Arguments

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

provider: a GdkContentProvider

-> m () 

Emits the contentChanged signal.

getValue

contentProviderGetValue Source #

Arguments

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

provider: a GdkContentProvider

-> m GValue

(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 GBytes with the data for mimeType

-> m ContentProvider

Returns: a new GdkContentProvider

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 GValue

-> m ContentProvider

Returns: a new GdkContentProvider

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 GdkContentProvider

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 #

Arguments

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

provider: a GdkContentProvider

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

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

-> Text

mimeType: the mime type to provide the data in

-> b

stream: the GOutputStream to write to

-> Int32

ioPriority: I/O priority of the request.

-> Maybe c

cancellable: optional GCancellable 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 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 #

Arguments

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

provider: a GdkContentProvider

-> b

result: a GAsyncResult

-> m ()

(Can throw GError)

Finishes an asynchronous write operation.

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