Gjsify LogoGjsify Logo

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.

record

Hierarchy

  • ContentFormats

Index

Constructors

  • Creates a new GdkContentFormats from an array of mime types.

    The mime types must be valid and different from each other or the behavior of the return value is undefined. If you cannot guarantee this, use [structGdk.ContentFormatsBuilder] instead.

    Parameters

    • mimeTypes: string[]

      Pointer to an array of mime types

    Returns ContentFormats

Properties

name: string

Methods

  • containGtype(type: GType<unknown>): boolean
  • Checks if a given GType is part of the given formats.

    Parameters

    • type: GType<unknown>

      the GType to search for

    Returns boolean

  • containMimeType(mimeType: string): boolean
  • Checks if a given mime type is part of the given formats.

    Parameters

    • mimeType: string

      the mime type to search for

    Returns boolean

  • getGtypes(): GType<unknown>[]
  • Gets the GTypes included in formats.

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

    Returns GType<unknown>[]

  • getMimeTypes(): string[]
  • 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[]

  • Checks if first and second have any matching formats.

    Parameters

    Returns boolean

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

    If no matching GType is found, %G_TYPE_INVALID is returned.

    Parameters

    Returns GType<unknown>

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

    If no matching mime type is found, %NULL is returned.

    Parameters

    Returns string

  • Prints the given formats into a string for human consumption.

    The result of this function can later be parsed with [funcGdk.ContentFormats.parse].

    Parameters

    Returns void

  • toString(): string
  • Prints the given formats into a human-readable string.

    The resulting string can be parsed with [funcGdk.ContentFormats.parse].

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

    Returns string

  • unref(): void
  • Decreases the reference count of a GdkContentFormats by one.

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

    Returns void

  • Creates a new GdkContentFormats from an array of mime types.

    The mime types must be valid and different from each other or the behavior of the return value is undefined. If you cannot guarantee this, use [structGdk.ContentFormatsBuilder] instead.

    Parameters

    • mimeTypes: string[]

      Pointer to an array of mime types

    Returns ContentFormats

  • Parses the given string into GdkContentFormats and returns the formats.

    Strings printed via [methodGdk.ContentFormats.to_string] can be read in again successfully using this function.

    If string does not describe valid content formats, %NULL is returned.

    Parameters

    • string: string

      the string to parse

    Returns ContentFormats

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method