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 |
The GdkClipboard
object 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
Memory-managed wrapper type.
Instances
Eq Clipboard Source # | |
GObject Clipboard Source # | |
Defined in GI.Gdk.Objects.Clipboard | |
ManagedPtrNewtype Clipboard Source # | |
Defined in GI.Gdk.Objects.Clipboard | |
TypedObject Clipboard Source # | |
Defined in GI.Gdk.Objects.Clipboard | |
HasParentTypes Clipboard Source # | |
Defined in GI.Gdk.Objects.Clipboard | |
IsGValue (Maybe Clipboard) Source # | Convert |
Defined in GI.Gdk.Objects.Clipboard | |
type ParentTypes Clipboard Source # | |
Defined in GI.Gdk.Objects.Clipboard |
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
(GObject o, IsDescendantOf Clipboard o) => IsClipboard o Source # | |
Defined in GI.Gdk.Objects.Clipboard |
toClipboard :: (MonadIO m, IsClipboard o) => o -> m Clipboard Source #
Methods
Click to display all available methods, including inherited ones
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
getContent
:: (HasCallStack, MonadIO m, IsClipboard a) | |
=> a |
|
-> 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
:: (HasCallStack, MonadIO m, IsClipboard a) | |
=> a |
|
-> m Display | Returns: a |
Gets the GdkDisplay
that the clipboard was created for.
getFormats
:: (HasCallStack, MonadIO m, IsClipboard a) | |
=> a |
|
-> m ContentFormats | Returns: The formats of the clipboard |
Gets the formats that the clipboard can provide its current contents in.
isLocal
:: (HasCallStack, MonadIO m, IsClipboard a) | |
=> a |
|
-> m Bool | Returns: |
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
:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) | |
=> a |
|
-> [Text] |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously requests an input stream to read the clipboard
's
contents from.
When the operation is finished callback
will be called. You must then
call clipboardReadFinish
to get the result of the operation.
The clipboard will choose the most suitable mime type from the given list to fulfill the request, preferring the ones listed first.
readFinish
:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Maybe InputStream, Text) | Returns: a |
Finishes an asynchronous clipboard read.
See clipboardReadAsync
.
readTextAsync
clipboardReadTextAsync Source #
:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously request the clipboard
contents converted to a string.
When the operation is finished callback
will be called. You must then
call clipboardReadTextFinish
to get the result.
This is a simple wrapper around clipboardReadValueAsync
.
Use that function or clipboardReadAsync
directly if you
need more control over the operation.
readTextFinish
clipboardReadTextFinish Source #
:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Maybe Text) | Returns: a new string (Can throw |
Finishes an asynchronous clipboard read.
readTextureAsync
clipboardReadTextureAsync Source #
:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously request the clipboard
contents converted to a GdkPixbuf
.
When the operation is finished callback
will be called. You must then
call clipboardReadTextureFinish
to get the result.
This is a simple wrapper around clipboardReadValueAsync
.
Use that function or clipboardReadAsync
directly if you
need more control over the operation.
readTextureFinish
clipboardReadTextureFinish Source #
:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Maybe Texture) | Returns: a new |
Finishes an asynchronous clipboard read.
readValueAsync
clipboardReadValueAsync Source #
:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) | |
=> a |
|
-> GType |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously request the clipboard
contents converted to the given
type
.
When the operation is finished callback
will be called. You must then call
clipboardReadValueFinish
to get the resulting GValue
.
For local clipboard contents that are available in the given GType
,
the value will be copied directly. Otherwise, GDK will try to use
[funccontentDeserializeAsync
] to convert the clipboard's data.
readValueFinish
clipboardReadValueFinish Source #
:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m GValue | Returns: a |
Finishes an asynchronous clipboard read.
set
:: (HasCallStack, MonadIO m, IsClipboard a) | |
=> a |
|
-> GValue |
|
-> m () |
Sets the clipboard
to contain the given value
.
setContent
:: (HasCallStack, MonadIO m, IsClipboard a, IsContentProvider b) | |
=> a |
|
-> Maybe b |
|
-> m Bool | Returns: |
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
:: (HasCallStack, MonadIO m, IsClipboard a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Asynchronously instructs the clipboard
to store its contents remotely.
If the clipboard is not local, this function does nothing but report success.
The callback
must call clipboardStoreFinish
.
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 Gtk.Application
is
shut down, so you likely don't need to call it.
storeFinish
:: (HasCallStack, MonadIO m, IsClipboard a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m () | (Can throw |
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