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
GdkClipboard
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
clipboard_ptr
Default implementationTyped pointer to the underlying
GdkClipboard
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GdkClipboard
instance.Declaration
Swift
var clipboard_ptr: UnsafeMutablePointer<GdkClipboard>! { get }
-
Required Initialiser for types conforming to
ClipboardProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ClipboardPropertyName
source 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 : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a Clipboard property
Declaration
Swift
@inlinable func get(property: ClipboardPropertyName) -> GLibObject.Value
Parameters
property
the 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
property
the 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
ClipboardSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ClipboardSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The 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
ClipboardSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ClipboardSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The 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 underlyingchanged
signalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
changed
signal is emitted -
changedSignal
Extension methodTyped
changed
signal 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 innotify
being 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::content
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyContent(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyContent
signal is emitted -
notifyContentSignal
Extension methodTyped
notify::content
signal 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 innotify
being 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::display
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyDisplay(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyDisplay
signal is emitted -
notifyDisplaySignal
Extension methodTyped
notify::display
signal 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 innotify
being 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::formats
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyFormats(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyFormats
signal is emitted -
notifyFormatsSignal
Extension methodTyped
notify::formats
signal 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 innotify
being 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::local
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyLocal(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ClipboardRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyLocal
signal is emitted -
notifyLocalSignal
Extension methodTyped
notify::local
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyLocalSignal: ClipboardSignalName { get }
-
getContent()
Extension methodReturns the
GdkContentProvider
currently set onclipboard
.If the
clipboard
is empty or its contents are not owned by the current process,nil
will be returned.Declaration
Swift
@inlinable func getContent() -> ContentProviderRef!
-
getDisplay()
Extension methodGets the
GdkDisplay
that 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
callback
will 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
callback
will 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
clipboard
contents converted to a string.When the operation is finished
callback
will 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
clipboard
contents converted to a string.When the operation is finished
callback
will 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
clipboard
contents converted to aGdkPixbuf
.When the operation is finished
callback
will 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
clipboard
contents converted to aGdkPixbuf
.When the operation is finished
callback
will 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
clipboard
contents converted to the giventype
.When the operation is finished
callback
will 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
clipboard
contents converted to the giventype
.When the operation is finished
callback
will 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,clipboard
will 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,clipboard
will 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
text
into the clipboard.Declaration
Swift
@inlinable func set(text: UnsafePointer<CChar>!)
-
set(texture:
Extension method) Puts the given
texture
into 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
clipboard
to contain the givenvalue
.Declaration
Swift
@inlinable func set<ValueT>(value: ValueT) where ValueT : ValueProtocol
-
storeAsync(ioPriority:
Extension methodcancellable: callback: userData: ) 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 [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
clipboard
to store its contents remotely.If the clipboard is not local, this function does nothing but report success.
The
callback
must 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
-
content
Extension methodThe
GdkContentProvider
ornil
if the clipboard is empty or contents are provided otherwise.Declaration
Swift
@inlinable var content: ContentProviderRef! { get nonmutating set }
-
display
Extension methodThe
GdkDisplay
that the clipboard belongs to.Declaration
Swift
@inlinable var display: DisplayRef! { get }
-
formats
Extension methodThe possible formats that the clipboard can provide its data in.
Declaration
Swift
@inlinable var formats: ContentFormatsRef! { get }
-
isLocal
Extension 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 returnnil
even on a local clipboard. In this case the clipboard is empty.Declaration
Swift
@inlinable var isLocal: Bool { get }