ContentFormatsProtocol

public protocol ContentFormatsProtocol

The ContentFormatsProtocol protocol exposes the methods and properties of an underlying GdkContentFormats 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 ContentFormats. Alternatively, use ContentFormatsRef as a lighweight, unowned reference if you already have an instance you just want to use.

The GdkContentFormats structure is used to advertise and negotiate the format of content.

You will encounter GdkContentFormats when interacting with objects controlling operations that pass data between different widgets, window or application, like [classGdk.Drag], [classGdk.Drop], [classGdk.Clipboard] or [classGdk.ContentProvider].

GDK supports content in 2 forms: GType and mime type. Using GTypes is meant only for in-process content transfers. Mime types are meant to be used for data passing both in-process and out-of-process. The details of how data is passed is described in the documentation of the actual implementations. To transform between the two forms, [classGdk.ContentSerializer] and [classGdk.ContentDeserializer] are used.

A GdkContentFormats describes a set of possible formats content can be exchanged in. It is assumed that this set is ordered. GTypes are more important than mime types. Order between different GTypes or mime types is the order they were added in, most important first. Functions that care about order, such as [methodGdk.ContentFormats.union], will describe in their documentation how they interpret that order, though in general the order of the first argument is considered the primary order of the result, followed by the order of further arguments.

For debugging purposes, the function [methodGdk.ContentFormats.to_string] exists. It will print a comma-separated list of formats from most important to least important.

GdkContentFormats is an immutable struct. After creation, you cannot change the types it represents. Instead, new GdkContentFormats have to be created. The [structGdk.ContentFormatsBuilder]` structure is meant to help in this endeavor.

  • ptr

    Untyped pointer to the underlying GdkContentFormats instance.

    Declaration

    Swift

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

    Typed pointer to the underlying GdkContentFormats instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GdkContentFormats instance.

    Declaration

    Swift

    var content_formats_ptr: UnsafeMutablePointer<GdkContentFormats>! { get }
  • Required Initialiser for types conforming to ContentFormatsProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

ContentFormats Record: ContentFormatsProtocol extension (methods and fields)

  • containGtype(type:) Extension method

    Checks if a given GType is part of the given formats.

    Declaration

    Swift

    @inlinable
    func containGtype(type: GType) -> Bool
  • contain(mimeType:) Extension method

    Checks if a given mime type is part of the given formats.

    Declaration

    Swift

    @inlinable
    func contain(mimeType: UnsafePointer<CChar>!) -> Bool
  • getGtypes(nGtypes:) Extension method

    Gets the GTypes included in formats.

    Note that formats may not contain any GTypes, in particular when they are empty. In that case nil will be returned.

    Declaration

    Swift

    @inlinable
    func getGtypes(nGtypes: UnsafeMutablePointer<gsize>! = nil) -> UnsafePointer<GType>!
  • getMimeTypes(nMimeTypes:) Extension method

    Gets the mime types included in formats.

    Note that formats may not contain any mime types, in particular when they are empty. In that case nil will be returned.

    Declaration

    Swift

    @inlinable
    func getMimeTypes(nMimeTypes: UnsafeMutablePointer<gsize>! = nil) -> UnsafePointer<UnsafePointer<CChar>?>!
  • match(second:) Extension method

    Checks if first and second have any matching formats.

    Declaration

    Swift

    @inlinable
    func match<ContentFormatsT>(second: ContentFormatsT) -> Bool where ContentFormatsT : ContentFormatsProtocol
  • matchGtype(second:) Extension method

    Finds the first GType from first that is also contained in second.

    If no matching GType is found, G_TYPE_INVALID is returned.

    Declaration

    Swift

    @inlinable
    func matchGtype<ContentFormatsT>(second: ContentFormatsT) -> GType where ContentFormatsT : ContentFormatsProtocol
  • matchMimeType(second:) Extension method

    Finds the first mime type from first that is also contained in second.

    If no matching mime type is found, nil is returned.

    Declaration

    Swift

    @inlinable
    func matchMimeType<ContentFormatsT>(second: ContentFormatsT) -> String! where ContentFormatsT : ContentFormatsProtocol
  • print(string:) Extension method

    Prints the given formats into a string for human consumption.

    This is meant for debugging and logging.

    The form of the representation may change at any time and is not guaranteed to stay identical.

    Declaration

    Swift

    @inlinable
    func print<StringTypeT>(string: StringTypeT) where StringTypeT : StringProtocol
  • ref() Extension method

    Increases the reference count of a GdkContentFormats by one.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func ref() -> ContentFormatsRef!
  • toString() Extension method

    Prints the given formats into a human-readable string.

    This is a small wrapper around [methodGdk.ContentFormats.print] to help when debugging.

    Declaration

    Swift

    @inlinable
    func toString() -> String!
  • union(second:) Extension method

    Append all missing types from second to first, in the order they had in second.

    Declaration

    Swift

    @inlinable
    func union<ContentFormatsT>(second: ContentFormatsT) -> ContentFormatsRef! where ContentFormatsT : ContentFormatsProtocol
  • unionDeserializeGtypes() Extension method

    Add GTypes for mime types in formats for which deserializers are registered.

    Declaration

    Swift

    @inlinable
    func unionDeserializeGtypes() -> ContentFormatsRef!
  • unionDeserializeMimeTypes() Extension method

    Add mime types for GTypes in formats for which deserializers are registered.

    Declaration

    Swift

    @inlinable
    func unionDeserializeMimeTypes() -> ContentFormatsRef!
  • unionSerializeGtypes() Extension method

    Add GTypes for the mime types in formats for which serializers are registered.

    Declaration

    Swift

    @inlinable
    func unionSerializeGtypes() -> ContentFormatsRef!
  • unionSerializeMimeTypes() Extension method

    Add mime types for GTypes in formats for which serializers are registered.

    Declaration

    Swift

    @inlinable
    func unionSerializeMimeTypes() -> ContentFormatsRef!
  • unref() Extension method

    Decreases the reference count of a GdkContentFormats by one.

    If the resulting reference count is zero, frees the formats.

    Declaration

    Swift

    @inlinable
    func unref()