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.

  • ptr

    Untyped pointer to the underlying GdkClipboard instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • clipboard_ptr Default implementation

    Typed 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)

Clipboard Class

  • 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 transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return 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:value:) Extension method

    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

Clipboard signals

  • Connect a Swift signal handler to the given, typed ClipboardSignalName signal

    Declaration

    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 by userData

    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 a C signal handler to the given, typed ClipboardSignalName signal

    Declaration

    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 by userData

    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:handler:) Extension method

    Emitted when the clipboard changes ownership.

    Note

    This represents the underlying changed signal

    Declaration

    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 method

    Typed changed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var changedSignal: ClipboardSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::content signal

    Declaration

    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 method

    Typed notify::content signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyContentSignal: ClipboardSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::display signal

    Declaration

    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 method

    Typed notify::display signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyDisplaySignal: ClipboardSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::formats signal

    Declaration

    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 method

    Typed notify::formats signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyFormatsSignal: ClipboardSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::local signal

    Declaration

    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 method

    Typed notify::local signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyLocalSignal: ClipboardSignalName { get }

Clipboard Class: ClipboardProtocol extension (methods and fields)

  • getContent() Extension method

    Returns the GdkContentProvider currently set on clipboard.

    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 method

    Gets the GdkDisplay that the clipboard was created for.

    Declaration

    Swift

    @inlinable
    func getDisplay() -> DisplayRef!
  • getFormats() Extension method

    Gets the formats that the clipboard can provide its current contents in.

    Declaration

    Swift

    @inlinable
    func getFormats() -> ContentFormatsRef!
  • 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)
  • 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
  • Finishes an asynchronous clipboard read.

    See [methodGdk.Clipboard.read_async].

    Declaration

    Swift

    @inlinable
    func readFinish<AsyncResultT>(result: AsyncResultT, outMimeType: UnsafeMutablePointer<UnsafePointer<CChar>?>! = nil) throws -> GIO.InputStreamRef! where AsyncResultT : AsyncResultProtocol
  • 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 [methodGdk.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)
  • 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 [methodGdk.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 [methodGdk.Clipboard.read_text_async].

    Declaration

    Swift

    @inlinable
    func readTextFinish<AsyncResultT>(result: AsyncResultT) throws -> String! where AsyncResultT : AsyncResultProtocol
  • Asynchronously request the clipboard contents converted to a GdkPixbuf.

    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 [methodGdk.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)
  • Asynchronously request the clipboard contents converted to a GdkPixbuf.

    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 [methodGdk.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 [methodGdk.Clipboard.read_texture_async].

    Declaration

    Swift

    @inlinable
    func readTextureFinish<AsyncResultT>(result: AsyncResultT) throws -> TextureRef! where AsyncResultT : AsyncResultProtocol
  • Asynchronously request the clipboard contents converted to the given type.

    When the operation is finished callback will be called. You must then call [methodGdk.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 [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)
  • Asynchronously request the clipboard contents converted to the given type.

    When the operation is finished callback will be called. You must then call [methodGdk.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 [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 [methodGdk.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 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.

    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 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.

    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:args:) Extension method

    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 given value.

    Declaration

    Swift

    @inlinable
    func set<ValueT>(value: ValueT) where ValueT : ValueProtocol
  • 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 [classGtk.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)
  • 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 [classGtk.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 [methodGdk.Clipboard.store_async].

    Declaration

    Swift

    @inlinable
    func storeFinish<AsyncResultT>(result: AsyncResultT) throws -> Bool where AsyncResultT : AsyncResultProtocol
  • content Extension method

    The GdkContentProvider or nil if the clipboard is empty or contents are provided otherwise.

    Declaration

    Swift

    @inlinable
    var content: ContentProviderRef! { get nonmutating set }
  • display Extension method

    The GdkDisplay that the clipboard belongs to.

    Declaration

    Swift

    @inlinable
    var display: DisplayRef! { get }
  • formats Extension method

    The possible formats that the clipboard can provide its data in.

    Declaration

    Swift

    @inlinable
    var formats: ContentFormatsRef! { get }
  • isLocal Extension method

    Returns if the clipboard is local.

    A clipboard is considered local if it was last claimed by the running application.

    Note that [methodGdk.Clipboard.get_content] may return nil even on a local clipboard. In this case the clipboard is empty.

    Declaration

    Swift

    @inlinable
    var isLocal: Bool { get }