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.Clipboard

Contents

- Exported types
- Methods
  - getContent
  - getDisplay
  - getFormats
  - isLocal
  - readAsync
  - readFinish
  - readTextAsync
  - readTextFinish
  - readTextureAsync
  - readTextureFinish
  - readValueAsync
  - readValueFinish
  - set
  - setContent
  - storeAsync
  - storeFinish
- Properties
  - content
  - display
  - formats
  - local
- Signals
  - changed

Description

Represents data shared between applications or inside an application.

To get a `GdkClipboard` object, use `displayGetClipboard` or `displayGetPrimaryClipboard`. You can find out about the data that is currently available in a clipboard using `clipboardGetFormats`.

To make text or image data available in a clipboard, use `Clipboard`.`set_text`() or `Clipboard`.`set_texture`(). For other data, you can use `clipboardSetContent`, which takes a `ContentProvider` object.

To read textual or image data from a clipboard, use `clipboardReadTextAsync` or `clipboardReadTextureAsync`. For other data, use `clipboardReadAsync`, which provides a `GInputStream` object.

Synopsis

- newtype Clipboard = Clipboard (ManagedPtr Clipboard)
- class (GObject o, IsDescendantOf Clipboard o) => IsClipboard o
- toClipboard :: (MonadIO m, IsClipboard o) => o -> m Clipboard
- clipboardGetContent :: (HasCallStack, MonadIO m, IsClipboard a) => a -> m (Maybe ContentProvider)
- clipboardGetDisplay :: (HasCallStack, MonadIO m, IsClipboard a) => a -> m Display
- clipboardGetFormats :: (HasCallStack, MonadIO m, IsClipboard a) => a -> m ContentFormats
- clipboardIsLocal :: (HasCallStack, MonadIO m, IsClipboard a) => a -> m Bool
- clipboardReadAsync :: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) => a -> [Text] -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- clipboardReadFinish :: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) => a -> b -> m (Maybe InputStream, Text)
- clipboardReadTextAsync :: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- clipboardReadTextFinish :: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) => a -> b -> m (Maybe Text)
- clipboardReadTextureAsync :: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- clipboardReadTextureFinish :: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) => a -> b -> m (Maybe Texture)
- clipboardReadValueAsync :: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) => a -> GType -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- clipboardReadValueFinish :: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) => a -> b -> m GValue
- clipboardSet :: (HasCallStack, MonadIO m, IsClipboard a) => a -> GValue -> m ()
- clipboardSetContent :: (HasCallStack, MonadIO m, IsClipboard a, IsContentProvider b) => a -> Maybe b -> m Bool
- clipboardStoreAsync :: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- clipboardStoreFinish :: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) => a -> b -> m ()
- getClipboardContent :: (MonadIO m, IsClipboard o) => o -> m (Maybe ContentProvider)
- constructClipboardDisplay :: (IsClipboard o, MonadIO m, IsDisplay a) => a -> m (GValueConstruct o)
- getClipboardDisplay :: (MonadIO m, IsClipboard o) => o -> m Display
- getClipboardFormats :: (MonadIO m, IsClipboard o) => o -> m ContentFormats
- getClipboardLocal :: (MonadIO m, IsClipboard o) => o -> m Bool
- type ClipboardChangedCallback = IO ()
- afterClipboardChanged :: (IsClipboard a, MonadIO m) => a -> ((?self :: a) => ClipboardChangedCallback) -> m SignalHandlerId
- onClipboardChanged :: (IsClipboard a, MonadIO m) => a -> ((?self :: a) => ClipboardChangedCallback) -> m SignalHandlerId

# Exported types

newtype Clipboard Source #

Memory-managed wrapper type.

Constructors

Clipboard (ManagedPtr Clipboard) |

#### Instances

Instances details

Eq Clipboard Source # |
Instance details Defined in GI.Gdk.Objects.Clipboard Methods (==) :: Clipboard -> Clipboard -> Bool Source # (/=) :: Clipboard -> Clipboard -> Bool Source #
GObject Clipboard Source # |
Instance details Defined in GI.Gdk.Objects.Clipboard
ManagedPtrNewtype Clipboard Source # |
Instance details Defined in GI.Gdk.Objects.Clipboard Methods toManagedPtr :: Clipboard -> ManagedPtr Clipboard Source #
TypedObject Clipboard Source # |
Instance details Defined in GI.Gdk.Objects.Clipboard Methods glibType :: IO GType Source #
HasParentTypes Clipboard Source # |
Instance details Defined in GI.Gdk.Objects.Clipboard
IsGValue (Maybe Clipboard) Source # | Convert `Clipboard` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gdk.Objects.Clipboard Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Clipboard -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Clipboard) Source #
type ParentTypes Clipboard Source # |
Instance details Defined in GI.Gdk.Objects.Clipboard type ParentTypes Clipboard = '[Object]

class (GObject o, IsDescendantOf Clipboard o) => IsClipboard o Source #

Type class for types which can be safely cast to `Clipboard`, for instance with `toClipboard`.

#### Instances

Instances details

(GObject o, IsDescendantOf Clipboard o) => IsClipboard o Source # |
Instance details Defined in GI.Gdk.Objects.Clipboard

toClipboard :: (MonadIO m, IsClipboard o) => o -> m Clipboard Source #

Cast to `Clipboard`, 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, forceFloating, freezeNotify, getv, isFloating, isLocal, notify, notifyByPspec, readAsync, readFinish, readTextAsync, readTextFinish, readTextureAsync, readTextureFinish, readValueAsync, readValueFinish, ref, refSink, runDispose, set, stealData, stealQdata, storeAsync, storeFinish, thawNotify, unref, watchClosure.

#### Getters

getContent, getData, getDisplay, getFormats, getProperty, getQdata.

#### Setters

setContent, setData, setDataFull, setProperty.

## getContent

clipboardGetContent Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a) |
=> a | `clipboard`: a `GdkClipboard`
-> m (Maybe ContentProvider) | Returns: The content of a clipboard if the clipboard does not maintain any content

Returns the `GdkContentProvider` currently set on `clipboard`.

If the `clipboard` is empty or its contents are not owned by the current process, `Nothing` will be returned.

## getDisplay

clipboardGetDisplay Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a) |
=> a | `clipboard`: a `GdkClipboard`
-> m Display | Returns: a `GdkDisplay`

Gets the `GdkDisplay` that the clipboard was created for.

## getFormats

clipboardGetFormats Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a) |
=> a | `clipboard`: a `GdkClipboard`
-> m ContentFormats | Returns: The formats of the clipboard

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

## isLocal

clipboardIsLocal Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a) |
=> a | `clipboard`: a `GdkClipboard`
-> m Bool | Returns: `True` if the clipboard is local

Returns if the clipboard is local.

A clipboard is considered local if it was last claimed by the running application.

Note that `clipboardGetContent` may return `Nothing` even on a local clipboard. In this case the clipboard is empty.

## readAsync

clipboardReadAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) |
=> a | `clipboard`: a `GdkClipboard`
-> [Text] | `mimeTypes`: a `Nothing`-terminated array of mime types to choose from
-> Int32 | `ioPriority`: the I/O priority of the request
-> Maybe b | `cancellable`: optional `GCancellable` object
-> Maybe AsyncReadyCallback | `callback`: callback to call when the request is satisfied
-> m () |

Asynchronously requests an input stream to read the `clipboard`'s contents from.

The clipboard will choose the most suitable mime type from the given list to fulfill the request, preferring the ones listed first.

## readFinish

clipboardReadFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) |
=> a | `clipboard`: a `GdkClipboard`
-> b | `result`: a `GAsyncResult`
-> m (Maybe InputStream, Text) | Returns: a `GInputStream` (Can throw `GError`)

Finishes an asynchronous clipboard read.

See `clipboardReadAsync`.

## readTextAsync

clipboardReadTextAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) |
=> a | `clipboard`: a `GdkClipboard`
-> Maybe b | `cancellable`: optional `GCancellable` object
-> Maybe AsyncReadyCallback | `callback`: callback to call when the request is satisfied
-> m () |

Asynchronously request the `clipboard` contents converted to a string.

This is a simple wrapper around `clipboardReadValueAsync`. Use that function or `clipboardReadAsync` directly if you need more control over the operation.

## readTextFinish

clipboardReadTextFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) |
=> a | `clipboard`: a `GdkClipboard`
-> b | `result`: a `GAsyncResult`
-> m (Maybe Text) | Returns: a new string (Can throw `GError`)

Finishes an asynchronous clipboard read.

See `clipboardReadTextAsync`.

## readTextureAsync

clipboardReadTextureAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) |
=> a | `clipboard`: a `GdkClipboard`
-> Maybe b | `cancellable`: optional `GCancellable` object, `Nothing` to ignore.
-> Maybe AsyncReadyCallback | `callback`: callback to call when the request is satisfied
-> m () |

Asynchronously request the `clipboard` contents converted to a `GdkPixbuf`.

This is a simple wrapper around `clipboardReadValueAsync`. Use that function or `clipboardReadAsync` directly if you need more control over the operation.

## readTextureFinish

clipboardReadTextureFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) |
=> a | `clipboard`: a `GdkClipboard`
-> b | `result`: a `GAsyncResult`
-> m (Maybe Texture) | Returns: a new `GdkTexture` (Can throw `GError`)

Finishes an asynchronous clipboard read.

See `clipboardReadTextureAsync`.

## readValueAsync

clipboardReadValueAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) |
=> a | `clipboard`: a `GdkClipboard`
-> GType | `type`: a `GType` to read
-> Int32 | `ioPriority`: the I/O priority of the request
-> Maybe b | `cancellable`: optional `GCancellable` object
-> Maybe AsyncReadyCallback | `callback`: callback to call when the request is satisfied
-> m () |

Asynchronously request the `clipboard` contents converted to the given `type`.

For local clipboard contents that are available in the given `GType`, the value will be copied directly. Otherwise, GDK will try to use [func`contentDeserializeAsync`] to convert the clipboard's data.

## readValueFinish

clipboardReadValueFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) |
=> a | `clipboard`: a `GdkClipboard`
-> b | `result`: a `GAsyncResult`
-> m GValue | Returns: a `GValue` containing the result. (Can throw `GError`)

Finishes an asynchronous clipboard read.

See `clipboardReadValueAsync`.

## set

clipboardSet Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a) |
=> a | `clipboard`: a `GdkClipboard`
-> GValue | `value`: a `GValue` to set
-> m () |

Sets the `clipboard` to contain the given `value`.

## setContent

clipboardSetContent Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsContentProvider b) |
=> a | `clipboard`: a `GdkClipboard`
-> Maybe b | `provider`: the new contents of `clipboard` or `Nothing` to clear the clipboard
-> m Bool | Returns: `True` if setting the clipboard succeeded

Sets a new content provider on `clipboard`.

The clipboard will claim the `GdkDisplay`'s resources and advertise these new contents to other applications.

In the rare case of a failure, this function will return `False`. The clipboard will then continue reporting its old contents and ignore `provider`.

If the contents are read by either an external application or the `clipboard`'s read functions, `clipboard` will select the best format to transfer the contents and then request that format from `provider`.

## storeAsync

clipboardStoreAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) |
=> a | `clipboard`: a `GdkClipboard`
-> Int32 | `ioPriority`: the I/O priority of the request
-> Maybe b | `cancellable`: optional `GCancellable` object
-> Maybe AsyncReadyCallback | `callback`: callback to call when the request is satisfied
-> m () |

Asynchronously instructs the `clipboard` to store its contents remotely.

If the clipboard is not local, this function does nothing but report success.

The purpose of this call is to preserve clipboard contents beyond the lifetime of an application, so this function is typically called on exit. Depending on the platform, the functionality may not be available unless a "clipboard manager" is running.

This function is called automatically when a GtkApplication is shut down, so you likely don't need to call it.

## storeFinish

clipboardStoreFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) |
=> a | `clipboard`: a `GdkClipboard`
-> b | `result`: a `GAsyncResult`
-> m () | (Can throw `GError`)

Finishes an asynchronous clipboard store.

See `clipboardStoreAsync`.

# Properties

## content

The `GdkContentProvider` or `Nothing` if the clipboard is empty or contents are provided otherwise.

getClipboardContent :: (MonadIO m, IsClipboard o) => o -> m (Maybe ContentProvider) Source #

Get the value of the “`content`” property. When overloading is enabled, this is equivalent to

    get clipboard #content

## display

The `GdkDisplay` that the clipboard belongs to.

constructClipboardDisplay :: (IsClipboard o, MonadIO m, IsDisplay a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`display`” property. This is rarely needed directly, but it is used by `new`.

getClipboardDisplay :: (MonadIO m, IsClipboard o) => o -> m Display Source #

Get the value of the “`display`” property. When overloading is enabled, this is equivalent to

    get clipboard #display

## formats

The possible formats that the clipboard can provide its data in.

getClipboardFormats :: (MonadIO m, IsClipboard o) => o -> m ContentFormats Source #

Get the value of the “`formats`” property. When overloading is enabled, this is equivalent to

    get clipboard #formats

## local

`True` if the contents of the clipboard are owned by this process.

getClipboardLocal :: (MonadIO m, IsClipboard o) => o -> m Bool Source #

Get the value of the “`local`” property. When overloading is enabled, this is equivalent to

    get clipboard #local

# Signals

## changed

type ClipboardChangedCallback = IO () Source #

Emitted when the clipboard changes ownership.

afterClipboardChanged :: (IsClipboard a, MonadIO m) => a -> ((?self :: a) => ClipboardChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the changed signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after clipboard #changed 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.

onClipboardChanged :: (IsClipboard a, MonadIO m) => a -> ((?self :: a) => ClipboardChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the changed signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on clipboard #changed callback