Class ContentProvider
- All Implemented Interfaces:
Proxy
To create a GdkContentProvider, use forValue(org.gnome.gobject.Value)
or forBytes(java.lang.String, byte[]).
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContentProvider.Builder<B extends ContentProvider.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theContentChangedCallbackcallback.static classClass structure forGdkContentProvider.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ContentProvider.ContentProvider(MemorySegment address) Create a ContentProvider proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected ContentProviderasParent()Returns this instance as if it were its parent type.protected voidattachClipboard(Clipboard clipboard) static ContentProvider.Builder<? extends ContentProvider.Builder> builder()AContentProvider.Builderobject constructs aContentProviderwith the specified properties.voidEmits the ::content-changed signal.protected voiddetachClipboard(Clipboard clipboard) voidEmits the "content-changed" signal.static ContentProviderCreate a content provider that provides the givenbytesas data for the givenmimeType.static ContentProviderCreate a content provider that provides the givenvalue.static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the ContentProvider classbooleanGets the contents of this ContentProvider stored invalue.Emitted whenever the content provided by this provider has 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.static ContentProviderCreate a content provider that provides the value of the giventype.static ContentProviderunion(@Nullable ContentProvider @Nullable [] providers) Creates a content provider that represents all the givenproviders.voidwriteMimeTypeAsync(String mimeType, OutputStream stream, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously writes the contents of this ContentProvider tostreamin the givenmimeType.booleanwriteMimeTypeFinish(AsyncResult result) Finishes an asynchronous write operation.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
ContentProvider
Create a ContentProvider proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
ContentProvider
public ContentProvider()Creates a new ContentProvider.
-
-
Method Details
-
getType
Get the GType of the ContentProvider class- Returns:
- the GType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
forBytes
Create a content provider that provides the givenbytesas data for the givenmimeType.- Parameters:
mimeType- the mime typebytes- aGByteswith the data formimeType- Returns:
- a new
GdkContentProvider
-
forValue
Create a content provider that provides the givenvalue.- Parameters:
value- aGValue- Returns:
- a new
GdkContentProvider
-
typed
Create a content provider that provides the value of the giventype.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 followvarargs- value- Returns:
- a new
GdkContentProvider
-
union
Creates a content provider that represents all the givenproviders.Whenever data needs to be written, the union provider will try the given
providersin 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
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);- Parameters:
providers- TheGdkContentProviders to present the union of- Returns:
- a new
GdkContentProvider
-
contentChanged
public void contentChanged()Emits the ::content-changed signal. -
getValue
Gets the contents of this ContentProvider stored invalue.The
valuewill have been initialized to theGTypethe value should be provided in. This givenGTypedoes not need to be listed in the formats returned byrefFormats(). However, if the givenGTypeis not supported, this operation can fail andG_IO_ERROR_NOT_SUPPORTEDwill be reported.- Parameters:
value- theGValueto fill- Returns:
trueif the value was set successfully. Otherwiseerrorwill be set to describe the failure.- Throws:
GErrorException- seeGError
-
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
refFormats().- Returns:
- The storable formats of the provider
-
writeMimeTypeAsync
public void writeMimeTypeAsync(String mimeType, OutputStream stream, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously writes the contents of this ContentProvider tostreamin the givenmimeType.The given mime type does not need to be listed in the formats returned by
refFormats(). However, if the givenGTypeis not supported,G_IO_ERROR_NOT_SUPPORTEDwill be reported.The given
streamwill not be closed.- Parameters:
mimeType- the mime type to provide the data instream- theGOutputStreamto write toioPriority- I/O priority of the request.cancellable- optionalGCancellableobject,nullto ignore.callback- callback to call when the request is satisfied
-
writeMimeTypeFinish
Finishes an asynchronous write operation.- Parameters:
result- aGAsyncResult- Returns:
trueif the operation was completed successfully. Otherwiseerrorwill be set to describe the failure.- Throws:
GErrorException- seeGError
-
attachClipboard
-
detachClipboard
-
onContentChanged
public SignalConnection<ContentProvider.ContentChangedCallback> onContentChanged(ContentProvider.ContentChangedCallback handler) Emitted whenever the content provided by this provider has changed.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitContentChanged
public void emitContentChanged()Emits the "content-changed" signal. SeeonContentChanged(org.gnome.gdk.ContentProvider.ContentChangedCallback). -
builder
AContentProvider.Builderobject constructs aContentProviderwith the specified properties. Use the variousset...()methods to set properties, and finish construction withContentProvider.Builder.build().- Returns:
- the builder object
-