Class (GI Struct)

Gdk-4.0GdkContentFormats

Used to advertise and negotiate the format of content.

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

GDK supports content in 2 forms: GObject.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, Gdk.ContentSerializer and Gdk.ContentDeserializer are used.

A Gdk.ContentFormats 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 Gdk.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 Gdk.ContentFormats.to_string exists. It will print a comma-separated list of formats from most important to least important.

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

Index

Constructors

Properties

Methods

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

    Parameters

    • mime_type: string

      the mime type to search for

    Returns boolean

    true if the mime_type was found

  • Gets the GObject.GTypes included in formats.

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

    Returns GType<unknown>[]

    G_TYPE_INVALID-terminated array of types included in formats

  • 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 null will be returned.

    Returns string[]

    null-terminated array of interned strings of mime types included in formats

  • Returns whether the content formats contain any formats.

    Returns boolean

    true if formats contains no mime types and no GTypes