gi-gdk4-4.0.10: Gdk bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gdk.Objects.ContentProvider

Contents

- Exported types
- Methods
  - contentChanged
  - getValue
  - newForBytes
  - newForValue
  - newUnion
  - refFormats
  - refStorableFormats
  - writeMimeTypeAsync
  - writeMimeTypeFinish
- Properties
  - formats
  - storableFormats
- Signals
  - contentChanged

Description

Provides 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 -> GValue -> m ()
- 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.

Constructors

ContentProvider (ManagedPtr ContentProvider) |

#### Instances

Instances details

Eq ContentProvider Source # |
Instance details Defined in GI.Gdk.Objects.ContentProvider Methods (==) :: ContentProvider -> ContentProvider -> Bool Source # (/=) :: ContentProvider -> ContentProvider -> Bool Source #
GObject ContentProvider Source # |
Instance details Defined in GI.Gdk.Objects.ContentProvider
ManagedPtrNewtype ContentProvider Source # |
Instance details Defined in GI.Gdk.Objects.ContentProvider Methods toManagedPtr :: ContentProvider -> ManagedPtr ContentProvider Source #
TypedObject ContentProvider Source # |
Instance details Defined in GI.Gdk.Objects.ContentProvider Methods glibType :: IO GType Source #
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 Source # gvalueSet_ :: Ptr GValue -> Maybe ContentProvider -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe ContentProvider) Source #
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

### Click to display all available methods, including inherited ones

Expand

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

setData, setDataFull, setProperty.

## 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`
-> GValue | `value`: the `GValue` 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 `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 `GdkContentProvider`s 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 (GDK_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`.

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