Package ch.bailu.gtk.gdk
Class Clipboard
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gdk.Clipboard
- All Implemented Interfaces:
PointerInterface
The `GdkClipboard` object represents data shared between applications or
inside an application.
To get a `GdkClipboard` object, use [method@Gdk.Display.get_clipboard] or
[method@Gdk.Display.get_primary_clipboard]. You can find out about the data
that is currently available in a clipboard using
[method@Gdk.Clipboard.get_formats].
To make text or image data available in a clipboard, use
[method@Gdk.Clipboard.set_text] or [method@Gdk.Clipboard.set_texture].
For other data, you can use [method@Gdk.Clipboard.set_content], which
takes a [class@Gdk.ContentProvider] object.
To read textual or image data from a clipboard, use
[method@Gdk.Clipboard.read_text_async] or
[method@Gdk.Clipboard.read_texture_async]. For other data, use
[method@Gdk.Clipboard.read_async], which provides a `GInputStream` object.
inside an application.
To get a `GdkClipboard` object, use [method@Gdk.Display.get_clipboard] or
[method@Gdk.Display.get_primary_clipboard]. You can find out about the data
that is currently available in a clipboard using
[method@Gdk.Clipboard.get_formats].
To make text or image data available in a clipboard, use
[method@Gdk.Clipboard.set_text] or [method@Gdk.Clipboard.set_texture].
For other data, you can use [method@Gdk.Clipboard.set_content], which
takes a [class@Gdk.ContentProvider] object.
To read textual or image data from a clipboard, use
[method@Gdk.Clipboard.read_text_async] or
[method@Gdk.Clipboard.read_texture_async]. For other data, use
[method@Gdk.Clipboard.read_async], which provides a `GInputStream` object.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClassHandler
Returns the `GdkContentProvider` currently set on @clipboard.Gets the `GdkDisplay` that the clipboard was created for.Gets the formats that the clipboard can provide its current contents in.static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
boolean
isLocal()
Returns if the clipboard is local.onChanged
(Clipboard.OnChanged signal) Connect to signal "changed".void
readAsync
(Strs mime_types, int io_priority, Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously requests an input stream to read the @clipboard's
contents from.readFinish
(AsyncResult result, Strs out_mime_type) Finishes an asynchronous clipboard read.void
readTextAsync
(Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously request the @clipboard contents converted to a string.readTextFinish
(AsyncResult result) Finishes an asynchronous clipboard read.void
readTextureAsync
(Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously request the @clipboard contents converted to a `GdkPixbuf`.readTextureFinish
(AsyncResult result) Finishes an asynchronous clipboard read.void
readValueAsync
(long type, int io_priority, Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously request the @clipboard contents converted to the given
@type.readValueFinish
(AsyncResult result) Finishes an asynchronous clipboard read.void
Sets the clipboard to contain the value collected from the given varargs.boolean
setContent
(ContentProvider provider) Sets a new content provider on @clipboard.void
Puts the given @text into the clipboard.void
Puts the given @text into the clipboard.void
setTexture
(Texture texture) Puts the given @texture into the clipboard.void
Sets the @clipboard to contain the given @value.void
storeAsync
(int io_priority, Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously instructs the @clipboard to store its contents remotely.boolean
storeFinish
(AsyncResult result) Finishes an asynchronous clipboard store.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_CHANGED
- See Also:
-
-
Constructor Details
-
Clipboard
-
-
Method Details
-
getClassHandler
-
getContent
Returns the `GdkContentProvider` currently set on @clipboard.
If the @clipboard is empty or its contents are not owned by the
current process, %NULL will be returned.- Returns:
- The content of a clipboard if the clipboard does not maintain any content
-
getDisplay
Gets the `GdkDisplay` that the clipboard was created for.- Returns:
- a `GdkDisplay`
-
getFormats
Gets the formats that the clipboard can provide its current contents in.- Returns:
- The formats of the clipboard
-
isLocal
public boolean isLocal()Returns if the clipboard is local.
A clipboard is considered local if it was last claimed
by the running application.
Note that [method@Gdk.Clipboard.get_content] may return %NULL
even on a local clipboard. In this case the clipboard is empty.- Returns:
- %TRUE if the clipboard is local
-
readAsync
public void readAsync(@Nonnull Strs mime_types, int io_priority, @Nullable Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, @Nullable Pointer user_data) 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 [method@Gdk.Clipboard.read_finish] 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.- Parameters:
mime_types
- a %NULL-terminated array of mime types to choose fromio_priority
- the I/O priority of the requestcancellable
- optional `GCancellable` objectcallback
- callback to call when the request is satisfieduser_data
- the data to pass to callback function
-
readFinish
public InputStream readFinish(@Nonnull AsyncResult result, @Nullable Strs out_mime_type) throws AllocationError Finishes an asynchronous clipboard read.
See [method@Gdk.Clipboard.read_async].- Parameters:
result
- a `GAsyncResult`out_mime_type
- location to store the chosen mime type- Returns:
- a `GInputStream`
- Throws:
AllocationError
-
readTextAsync
public void readTextAsync(@Nullable Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously request the @clipboard contents converted to a string.
When the operation is finished @callback will be called. You must then
call [method@Gdk.Clipboard.read_text_finish] to get the result.
This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
Use that function or [method@Gdk.Clipboard.read_async] directly if you
need more control over the operation.- Parameters:
cancellable
- optional `GCancellable` objectcallback
- callback to call when the request is satisfieduser_data
- the data to pass to callback function
-
readTextFinish
Finishes an asynchronous clipboard read.
See [method@Gdk.Clipboard.read_text_async].- Parameters:
result
- a `GAsyncResult`- Returns:
- a new string
- Throws:
AllocationError
-
readTextureAsync
public void readTextureAsync(@Nullable Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously request the @clipboard contents converted to a `GdkPixbuf`.
When the operation is finished @callback will be called. You must then
call [method@Gdk.Clipboard.read_texture_finish] to get the result.
This is a simple wrapper around [method@Gdk.Clipboard.read_value_async].
Use that function or [method@Gdk.Clipboard.read_async] directly if you
need more control over the operation.- Parameters:
cancellable
- optional `GCancellable` object, %NULL to ignore.callback
- callback to call when the request is satisfieduser_data
- the data to pass to callback function
-
readTextureFinish
Finishes an asynchronous clipboard read.
See [method@Gdk.Clipboard.read_texture_async].- Parameters:
result
- a `GAsyncResult`- Returns:
- a new `GdkTexture`
- Throws:
AllocationError
-
readValueAsync
public void readValueAsync(long type, int io_priority, @Nullable Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously request the @clipboard contents converted to the given
@type.
When the operation is finished @callback will be called. You must then call
[method@Gdk.Clipboard.read_value_finish] 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
[func@content_deserialize_async] to convert the clipboard's data.- Parameters:
type
- a `GType` to readio_priority
- the I/O priority of the requestcancellable
- optional `GCancellable` objectcallback
- callback to call when the request is satisfieduser_data
- the data to pass to callback function
-
readValueFinish
Finishes an asynchronous clipboard read.
See [method@Gdk.Clipboard.read_value_async].- Parameters:
result
- a `GAsyncResult`- Returns:
- a `GValue` containing the result.
- Throws:
AllocationError
-
set
Sets the clipboard to contain the value collected from the given varargs.
Values should be passed the same way they are passed to other value
collecting APIs, such as [`method@GObject.Object.set`] or
[`func@GObject.signal_emit`].
```c
gdk_clipboard_set (clipboard, GTK_TYPE_STRING, "Hello World");
gdk_clipboard_set (clipboard, GDK_TYPE_TEXTURE, some_texture);
```- Parameters:
type
- type of value to set_elipse
- value contents conforming to @type
-
setContent
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.- Parameters:
provider
- the new contents of @clipboard or %NULL to clear the clipboard- Returns:
- %TRUE if setting the clipboard succeeded
-
setText
Puts the given @text into the clipboard.- Parameters:
text
- Text to put into the clipboard
-
setText
Puts the given @text into the clipboard.- Parameters:
text
- Text to put into the clipboard
-
setTexture
Puts the given @texture into the clipboard.- Parameters:
texture
- a `GdkTexture` to put into the clipboard
-
setValue
Sets the @clipboard to contain the given @value.- Parameters:
value
- a `GValue` to set
-
storeAsync
public void storeAsync(int io_priority, @Nullable Cancellable cancellable, Clipboard.OnAsyncReadyCallback callback, @Nullable Pointer user_data) 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 [method@Gdk.Clipboard.store_finish].
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 [class@Gtk.Application] is
shut down, so you likely don't need to call it.- Parameters:
io_priority
- the I/O priority of the requestcancellable
- optional `GCancellable` objectcallback
- callback to call when the request is satisfieduser_data
- the data to pass to callback function
-
storeFinish
Finishes an asynchronous clipboard store.
See [method@Gdk.Clipboard.store_async].- Parameters:
result
- a `GAsyncResult`- Returns:
- %TRUE if storing was successful.
- Throws:
AllocationError
-
onChanged
Connect to signal "changed".
SeeClipboard.OnChanged.onChanged()
for signal description.
FieldSIGNAL_ON_CHANGED
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-