ContentProviderRef

public struct ContentProviderRef : ContentProviderProtocol, GWeakCapturing

The ContentProviderRef type acts as a lightweight Swift reference to an underlying GdkContentProvider instance. It exposes methods that can operate on this data type through ContentProviderProtocol conformance. Use ContentProviderRef only as an unowned reference to an existing GdkContentProvider instance.

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 [ctorGdk.ContentProvider.new_for_value] or [ctorGdk.ContentProvider.new_for_bytes].

GDK knows how to handle common text and image formats out-of-the-box. See [classGdk.ContentSerializer] and [classGdk.ContentDeserializer] if you want to add support for application-specific data formats.

  • ptr
    Untyped pointer to the underlying `GdkContentProvider` instance.
    

    For type-safe access, use the generated, typed pointer content_provider_ptr property instead.

    Declaration

    Swift

    public let ptr: UnsafeMutableRawPointer!

ContentProvider Class

  • Designated initialiser from the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafeMutablePointer<GdkContentProvider>)
  • Designated initialiser from a constant pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafePointer<GdkContentProvider>)
  • Conditional initialiser from an optional pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafeMutablePointer<GdkContentProvider>?)
  • Conditional initialiser from an optional, non-mutable pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafePointer<GdkContentProvider>?)
  • Conditional initialiser from an optional gpointer

    Declaration

    Swift

    @inlinable
    init!(gpointer g: gpointer?)
  • Conditional initialiser from an optional, non-mutable gconstpointer

    Declaration

    Swift

    @inlinable
    init!(gconstpointer g: gconstpointer?)
  • Reference intialiser for a related type that implements ContentProviderProtocol

    Declaration

    Swift

    @inlinable
    init<T>(_ other: T) where T : ContentProviderProtocol
  • This factory is syntactic sugar for setting weak pointers wrapped in GWeak<T>

    Declaration

    Swift

    @inlinable
    static func unowned<T>(_ other: T) -> ContentProviderRef where T : ContentProviderProtocol
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ContentProviderProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(cPointer: UnsafeMutablePointer<T>)
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ContentProviderProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(constPointer: UnsafePointer<T>)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ContentProviderProtocol.

    Declaration

    Swift

    @inlinable
    init(mutating raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ContentProviderProtocol.

    Declaration

    Swift

    @inlinable
    init(raw: UnsafeMutableRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ContentProviderProtocol.

    Declaration

    Swift

    @inlinable
    init(opaquePointer: OpaquePointer)
  • Create a content provider that provides the given `bytes` as data for
    

    the given mime_type.

    Declaration

    Swift

    @inlinable
    init<BytesT>(bytes mimeType: UnsafePointer<CChar>!, bytes: BytesT) where BytesT : BytesProtocol
  • Create a content provider that provides the given value.

    Declaration

    Swift

    @inlinable
    init<ValueT>(value: ValueT) where ValueT : ValueProtocol
  • Creates a content provider that represents all the given providers.

    Whenever data needs to be written, the union provider will try the given providers in 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 (G_TYPE_TEXTURE, texture)
                                    }, 2);
    

    Declaration

    Swift

    @inlinable
    init(union providers: UnsafeMutablePointer<UnsafeMutablePointer<GdkContentProvider>?>! = nil, nProviders: Int)
  • Create a content provider that provides the given bytes as data for the given mime_type.

    Declaration

    Swift

    @inlinable
    static func newFor<BytesT>(bytes mimeType: UnsafePointer<CChar>!, bytes: BytesT) -> ContentProviderRef! where BytesT : BytesProtocol
  • Create a content provider that provides the given value.

    Declaration

    Swift

    @inlinable
    static func newFor<ValueT>(value: ValueT) -> ContentProviderRef! where ValueT : ValueProtocol
  • Creates a content provider that represents all the given providers.

    Whenever data needs to be written, the union provider will try the given providers in 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 (G_TYPE_TEXTURE, texture)
                                    }, 2);
    

    Declaration

    Swift

    @inlinable
    static func new(union providers: UnsafeMutablePointer<UnsafeMutablePointer<GdkContentProvider>?>! = nil, nProviders: Int) -> ContentProviderRef!