ClipboardProtocol
public protocol ClipboardProtocol : ObjectProtocol
The ClipboardProtocol protocol exposes the methods and properties of an underlying GdkClipboard instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Clipboard.
Alternatively, use ClipboardRef as a lighweight, unowned reference if you already have an instance you just want to use.
The GdkClipboard object represents data shared between applications or
inside an application.
To get a GdkClipboard object, use [methodGdk.Display.get_clipboard] or
[methodGdk.Display.get_primary_clipboard]. You can find out about the data
that is currently available in a clipboard using
[methodGdk.Clipboard.get_formats].
To make text or image data available in a clipboard, use
[methodGdk.Clipboard.set_text] or [methodGdk.Clipboard.set_texture].
For other data, you can use [methodGdk.Clipboard.set_content], which
takes a [classGdk.ContentProvider] object.
To read textual or image data from a clipboard, use
[methodGdk.Clipboard.read_text_async] or
[methodGdk.Clipboard.read_texture_async]. For other data, use
[methodGdk.Clipboard.read_async], which provides a GInputStream object.
-
Untyped pointer to the underlying
GdkClipboardinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
clipboard_ptrDefault implementationTyped pointer to the underlying
GdkClipboardinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GdkClipboardinstance.Declaration
Swift
var clipboard_ptr: UnsafeMutablePointer<GdkClipboard>! { get } -
Required Initialiser for types conforming to
ClipboardProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ClipboardPropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: ClipboardPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a Clipboard property
Declaration
Swift
@inlinable func get(property: ClipboardPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a Clipboard property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: ClipboardPropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
ClipboardSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ClipboardSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
ClipboardSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ClipboardSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onChanged(flags:Extension methodhandler: ) Emitted when the clipboard changes ownership.
Note
This represents the underlyingchangedsignalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
changedsignal is emitted -
changedSignalExtension methodTyped
changedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var changedSignal: ClipboardSignalName { get } -
onNotifyContent(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this: (C Language Example):g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::contentsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyContent(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyContentsignal is emitted -
notifyContentSignalExtension methodTyped
notify::contentsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyContentSignal: ClipboardSignalName { get } -
onNotifyDisplay(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this: (C Language Example):g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::displaysignalDeclaration
Swift
@discardableResult @inlinable func onNotifyDisplay(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyDisplaysignal is emitted -
notifyDisplaySignalExtension methodTyped
notify::displaysignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyDisplaySignal: ClipboardSignalName { get } -
onNotifyFormats(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this: (C Language Example):g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::formatssignalDeclaration
Swift
@discardableResult @inlinable func onNotifyFormats(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyFormatssignal is emitted -
notifyFormatsSignalExtension methodTyped
notify::formatssignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyFormatsSignal: ClipboardSignalName { get } -
onNotifyLocal(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this: (C Language Example):g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::localsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyLocal(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyLocalsignal is emitted -
notifyLocalSignalExtension methodTyped
notify::localsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyLocalSignal: ClipboardSignalName { get }
-
getContent()Extension methodReturns the
GdkContentProvidercurrently set onclipboard.If the
clipboardis empty or its contents are not owned by the current process,nilwill be returned.Declaration
Swift
@inlinable func getContent() -> ContentProviderRef! -
getDisplay()Extension methodGets the
GdkDisplaythat the clipboard was created for.Declaration
Swift
@inlinable func getDisplay() -> DisplayRef! -
getFormats()Extension methodGets the formats that the clipboard can provide its current contents in.
Declaration
Swift
@inlinable func getFormats() -> ContentFormatsRef! -
readAsync(mimeTypes:Extension methodioPriority: cancellable: callback: userData: ) Asynchronously requests an input stream to read the
clipboard‘s contents from.When the operation is finished
callbackwill be called. You must then call [methodGdk.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.
Declaration
Swift
@inlinable func readAsync(mimeTypes: UnsafeMutablePointer<UnsafePointer<CChar>?>!, ioPriority: Int, cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) -
readAsync(mimeTypes:Extension methodioPriority: cancellable: callback: userData: ) Asynchronously requests an input stream to read the
clipboard‘s contents from.When the operation is finished
callbackwill be called. You must then call [methodGdk.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.
Declaration
Swift
@inlinable func readAsync<CancellableT>(mimeTypes: UnsafeMutablePointer<UnsafePointer<CChar>?>!, ioPriority: Int, cancellable: CancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where CancellableT : CancellableProtocol -
readFinish(result:Extension methodoutMimeType: ) Finishes an asynchronous clipboard read.
See [method
Gdk.Clipboard.read_async].Declaration
Swift
@inlinable func readFinish<AsyncResultT>(result: AsyncResultT, outMimeType: UnsafeMutablePointer<UnsafePointer<CChar>?>! = nil) throws -> GIO.InputStreamRef! where AsyncResultT : AsyncResultProtocol -
readTextAsync(cancellable:Extension methodcallback: userData: ) Asynchronously request the
clipboardcontents converted to a string.When the operation is finished
callbackwill be called. You must then call [methodGdk.Clipboard.read_text_finish] to get the result.This is a simple wrapper around [method
Gdk.Clipboard.read_value_async]. Use that function or [methodGdk.Clipboard.read_async] directly if you need more control over the operation.Declaration
Swift
@inlinable func readTextAsync(cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) -
readTextAsync(cancellable:Extension methodcallback: userData: ) Asynchronously request the
clipboardcontents converted to a string.When the operation is finished
callbackwill be called. You must then call [methodGdk.Clipboard.read_text_finish] to get the result.This is a simple wrapper around [method
Gdk.Clipboard.read_value_async]. Use that function or [methodGdk.Clipboard.read_async] directly if you need more control over the operation.Declaration
Swift
@inlinable func readTextAsync<CancellableT>(cancellable: CancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where CancellableT : CancellableProtocol -
readTextFinish(result:Extension method) Finishes an asynchronous clipboard read.
See [method
Gdk.Clipboard.read_text_async].Declaration
Swift
@inlinable func readTextFinish<AsyncResultT>(result: AsyncResultT) throws -> String! where AsyncResultT : AsyncResultProtocol -
readTextureAsync(cancellable:Extension methodcallback: userData: ) Asynchronously request the
clipboardcontents converted to aGdkPixbuf.When the operation is finished
callbackwill be called. You must then call [methodGdk.Clipboard.read_texture_finish] to get the result.This is a simple wrapper around [method
Gdk.Clipboard.read_value_async]. Use that function or [methosGdk.Clipboard.read_async] directly if you need more control over the operation.Declaration
Swift
@inlinable func readTextureAsync(cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) -
readTextureAsync(cancellable:Extension methodcallback: userData: ) Asynchronously request the
clipboardcontents converted to aGdkPixbuf.When the operation is finished
callbackwill be called. You must then call [methodGdk.Clipboard.read_texture_finish] to get the result.This is a simple wrapper around [method
Gdk.Clipboard.read_value_async]. Use that function or [methosGdk.Clipboard.read_async] directly if you need more control over the operation.Declaration
Swift
@inlinable func readTextureAsync<CancellableT>(cancellable: CancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where CancellableT : CancellableProtocol -
readTextureFinish(result:Extension method) Finishes an asynchronous clipboard read.
See [method
Gdk.Clipboard.read_texture_async].Declaration
Swift
@inlinable func readTextureFinish<AsyncResultT>(result: AsyncResultT) throws -> TextureRef! where AsyncResultT : AsyncResultProtocol -
readValueAsync(type:Extension methodioPriority: cancellable: callback: userData: ) Asynchronously request the
clipboardcontents converted to the giventype.When the operation is finished
callbackwill be called. You must then call [methodGdk.Clipboard.read_value_finish] to get the resultingGValue.For local clipboard contents that are available in the given
GType, the value will be copied directly. Otherwise, GDK will try to use [funccontent_deserialize_async] to convert the clipboard’s data.Declaration
Swift
@inlinable func readValueAsync(type: GType, ioPriority: Int, cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) -
readValueAsync(type:Extension methodioPriority: cancellable: callback: userData: ) Asynchronously request the
clipboardcontents converted to the giventype.When the operation is finished
callbackwill be called. You must then call [methodGdk.Clipboard.read_value_finish] to get the resultingGValue.For local clipboard contents that are available in the given
GType, the value will be copied directly. Otherwise, GDK will try to use [funccontent_deserialize_async] to convert the clipboard’s data.Declaration
Swift
@inlinable func readValueAsync<CancellableT>(type: GType, ioPriority: Int, cancellable: CancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where CancellableT : CancellableProtocol -
readValueFinish(result:Extension method) Finishes an asynchronous clipboard read.
See [method
Gdk.Clipboard.read_value_async].Declaration
Swift
@inlinable func readValueFinish<AsyncResultT>(result: AsyncResultT) throws -> GLibObject.ValueRef! where AsyncResultT : AsyncResultProtocol -
setContent(provider:Extension method) 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 ignoreprovider.If the contents are read by either an external application or the
clipboard’s read functions,clipboardwill select the best format to transfer the contents and then request that format fromprovider.Declaration
Swift
@inlinable func setContent(provider: ContentProviderRef? = nil) -> Bool -
setContent(provider:Extension method) 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 ignoreprovider.If the contents are read by either an external application or the
clipboard’s read functions,clipboardwill select the best format to transfer the contents and then request that format fromprovider.Declaration
Swift
@inlinable func setContent<ContentProviderT>(provider: ContentProviderT?) -> Bool where ContentProviderT : ContentProviderProtocol -
set(text:Extension method) Puts the given
textinto the clipboard.Declaration
Swift
@inlinable func set(text: UnsafePointer<CChar>!) -
set(texture:Extension method) Puts the given
textureinto the clipboard.Declaration
Swift
@inlinable func set<TextureT>(texture: TextureT) where TextureT : TextureProtocol -
setValist(type:Extension methodargs: ) Sets the clipboard to contain the value collected from the given
args.Declaration
Swift
@inlinable func setValist(type: GType, args: CVaListPointer) -
set(value:Extension method) Sets the
clipboardto contain the givenvalue.Declaration
Swift
@inlinable func set<ValueT>(value: ValueT) where ValueT : ValueProtocol -
storeAsync(ioPriority:Extension methodcancellable: callback: userData: ) Asynchronously instructs the
clipboardto store its contents remotely.If the clipboard is not local, this function does nothing but report success.
The
callbackmust call [methodGdk.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.Declaration
Swift
@inlinable func storeAsync(ioPriority: Int, cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) -
storeAsync(ioPriority:Extension methodcancellable: callback: userData: ) Asynchronously instructs the
clipboardto store its contents remotely.If the clipboard is not local, this function does nothing but report success.
The
callbackmust call [methodGdk.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.Declaration
Swift
@inlinable func storeAsync<CancellableT>(ioPriority: Int, cancellable: CancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer! = nil) where CancellableT : CancellableProtocol -
storeFinish(result:Extension method) Finishes an asynchronous clipboard store.
See [method
Gdk.Clipboard.store_async].Declaration
Swift
@inlinable func storeFinish<AsyncResultT>(result: AsyncResultT) throws -> Bool where AsyncResultT : AsyncResultProtocol -
contentExtension methodThe
GdkContentProviderornilif the clipboard is empty or contents are provided otherwise.Declaration
Swift
@inlinable var content: ContentProviderRef! { get nonmutating set } -
displayExtension methodThe
GdkDisplaythat the clipboard belongs to.Declaration
Swift
@inlinable var display: DisplayRef! { get } -
formatsExtension methodThe possible formats that the clipboard can provide its data in.
Declaration
Swift
@inlinable var formats: ContentFormatsRef! { get } -
isLocalExtension methodReturns 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 returnnileven on a local clipboard. In this case the clipboard is empty.Declaration
Swift
@inlinable var isLocal: Bool { get }
View on GitHub
Install in Dash
ClipboardProtocol Protocol Reference