Package ch.bailu.gtk.gdk
Class ContentProvider
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gdk.ContentProvider
- All Implemented Interfaces:
PointerInterface
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 [ctor@Gdk.ContentProvider.new_for_value]
or [ctor@Gdk.ContentProvider.new_for_bytes].
GDK knows how to handle common text and image formats out-of-the-box. See
[class@Gdk.ContentSerializer] and [class@Gdk.ContentDeserializer] if you want
to add support for application-specific data formats.
for drag-and-drop operations in a number of formats.
To create a `GdkContentProvider`, use [ctor@Gdk.ContentProvider.new_for_value]
or [ctor@Gdk.ContentProvider.new_for_bytes].
GDK knows how to handle common text and image formats out-of-the-box. See
[class@Gdk.ContentSerializer] and [class@Gdk.ContentDeserializer] if you want
to add support for application-specific data formats.
-
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 TypeMethodDescriptionvoid
Emits the ::content-changed signal.static ClassHandler
static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
boolean
Gets the contents of @provider stored in @value.static ContentProvider
newForBytesContentProvider
(Str mime_type, Bytes bytes) Create a content provider that provides the given @bytes as data for
the given @mime_type.static ContentProvider
newForBytesContentProvider
(String mime_type, Bytes bytes) Create a content provider that provides the given @bytes as data for
the given @mime_type.static ContentProvider
newForValueContentProvider
(Value value) Create a content provider that provides the given @value.static ContentProvider
newTypedContentProvider
(long type, Object... _elipse) Create a content provider that provides the value of the given
@type.Connect to signal "content-changed".Gets the formats that the provider can provide its current contents in.Gets the formats that the provider suggests other applications to store
the data in.void
writeMimeTypeAsync
(Str mime_type, OutputStream stream, int io_priority, Cancellable cancellable, ContentProvider.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously writes the contents of @provider to @stream in the given
@mime_type.void
writeMimeTypeAsync
(String mime_type, OutputStream stream, int io_priority, Cancellable cancellable, ContentProvider.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously writes the contents of @provider to @stream in the given
@mime_type.boolean
writeMimeTypeFinish
(AsyncResult result) Finishes an asynchronous write operation.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_CONTENT_CHANGED
- See Also:
-
-
Constructor Details
-
ContentProvider
-
-
Method Details
-
getClassHandler
-
newForBytesContentProvider
public static ContentProvider newForBytesContentProvider(@Nonnull Str mime_type, @Nonnull Bytes bytes) Create a content provider that provides the given @bytes as data for
the given @mime_type.- Parameters:
mime_type
- the mime typebytes
- a `GBytes` with the data for @mime_type- Returns:
- a new `GdkContentProvider`
-
newForBytesContentProvider
Create a content provider that provides the given @bytes as data for
the given @mime_type.- Parameters:
mime_type
- the mime typebytes
- a `GBytes` with the data for @mime_type- Returns:
- a new `GdkContentProvider`
-
newForValueContentProvider
Create a content provider that provides the given @value.- Parameters:
value
- a `GValue`- Returns:
- a new `GdkContentProvider`
-
newTypedContentProvider
Create a content provider that provides the value of the given
@type.
The value is provided using G_VALUE_COLLECT(), so the same rules
apply as when calling g_object_new() or g_object_set().- Parameters:
type
- Type of value to follow_elipse
- value- Returns:
- a new `GdkContentProvider`
-
contentChanged
public void contentChanged()Emits the ::content-changed signal. -
getValue
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 [method@Gdk.ContentProvider.ref_formats]. However, if the
given `GType` is not supported, this operation can fail and
`G_IO_ERROR_NOT_SUPPORTED` will be reported.- Parameters:
value
- the `GValue` to fill- Returns:
- %TRUE if the value was set successfully. Otherwise @error will be set to describe the failure.
- Throws:
AllocationError
-
refFormats
Gets the formats that the provider can provide its current contents in.- Returns:
- The formats of the provider
-
refStorableFormats
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 [method@Gdk.ContentProvider.ref_formats].- Returns:
- The storable formats of the provider
-
writeMimeTypeAsync
public void writeMimeTypeAsync(@Nonnull Str mime_type, @Nonnull OutputStream stream, int io_priority, @Nullable Cancellable cancellable, ContentProvider.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously writes the contents of @provider to @stream in the given
@mime_type.
When the operation is finished @callback will be called. You must then call
[method@Gdk.ContentProvider.write_mime_type_finish] to get the result
of the operation.
The given mime type does not need to be listed in the formats returned by
[method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.
The given @stream will not be closed.- Parameters:
mime_type
- the mime type to provide the data instream
- the `GOutputStream` to write toio_priority
- I/O priority of the request.cancellable
- optional `GCancellable` object, %NULL to ignore.callback
- callback to call when the request is satisfieduser_data
- the data to pass to callback function
-
writeMimeTypeAsync
public void writeMimeTypeAsync(String mime_type, @Nonnull OutputStream stream, int io_priority, @Nullable Cancellable cancellable, ContentProvider.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously writes the contents of @provider to @stream in the given
@mime_type.
When the operation is finished @callback will be called. You must then call
[method@Gdk.ContentProvider.write_mime_type_finish] to get the result
of the operation.
The given mime type does not need to be listed in the formats returned by
[method@Gdk.ContentProvider.ref_formats]. However, if the given `GType` is
not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported.
The given @stream will not be closed.- Parameters:
mime_type
- the mime type to provide the data instream
- the `GOutputStream` to write toio_priority
- I/O priority of the request.cancellable
- optional `GCancellable` object, %NULL to ignore.callback
- callback to call when the request is satisfieduser_data
- the data to pass to callback function
-
writeMimeTypeFinish
Finishes an asynchronous write operation.
See [method@Gdk.ContentProvider.write_mime_type_async].- Parameters:
result
- a `GAsyncResult`- Returns:
- %TRUE if the operation was completed successfully. Otherwise @error will be set to describe the failure.
- Throws:
AllocationError
-
onContentChanged
Connect to signal "content-changed".
SeeContentProvider.OnContentChanged.onContentChanged()
for signal description.
FieldSIGNAL_ON_CONTENT_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()
-