3.2 <GdkContentFormats>

Structure: <GdkContentFormats>

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 <GdkDrag>, <GdkDrop>, <GdkClipboard> or <GdkContentProvider>.

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, <GdkContentSerializer> and <GdkContentDeserializer> 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 content-formats: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 content-formats: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 <GdkContentFormatsBuilder> structure is meant to help in this endeavor.

Procedures

Method: content-formats:contain-gtype? self type ⇒ %return
Method: contain-gtype? self type ⇒ %return

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

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

type

Passed: a class, or a GType number.

the GType to search for

%return

Returned: a boolean.

#t if the GType was found

Method: content-formats:contain-mime-type? self mime-type ⇒ %return
Method: contain-mime-type? self mime-type ⇒ %return

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

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

mime-type

Passed: a string.

the mime type to search for

%return

Returned: a boolean.

#t if the mime_type was found

Method: content-formats:get-gtypes self ⇒ %return
Method: get-gtypes self ⇒ %return

Gets the GTypes included in self.

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

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

%return

Returned: a vector, each a class, or a GType number, or #f.

G_TYPE_INVALID-terminated array of types included in self

n-gtypes

Not returned: it is the length of %return.

optional pointer to take the number of GTypes contained in the return value

Method: content-formats:get-mime-types self ⇒ %return
Method: get-mime-types self ⇒ %return

Gets the mime types included in self.

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

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

%return

Returned: a vector, each a string, or #f.

#f-terminated array of interned strings of mime types included in self

n-mime-types

Not returned: it is the length of %return.

optional pointer to take the number of mime types contained in the return value

Method: content-formats:is-empty? self ⇒ %return
Method: is-empty? self ⇒ %return

Returns whether the content formats contain any formats.

self

Passed: a <GdkContentFormats>.

content formats

%return

Returned: a boolean.

true if self contains no mime types and no GTypes

Method: content-formats:match-gtype self second ⇒ %return
Method: match-gtype self second ⇒ %return

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

If no matching GType is found, G_TYPE_INVALID is returned.

self

Passed: a <GdkContentFormats>.

the primary <GdkContentFormats> to intersect

second

Passed: a <GdkContentFormats>.

the <GdkContentFormats> to intersect with

%return

Returned: a class, or a GType number.

The first common GType or G_TYPE_INVALID if none.

Method: content-formats:match-mime-type self second ⇒ %return
Method: match-mime-type self second ⇒ %return

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

If no matching mime type is found, #f is returned.

self

Passed: a <GdkContentFormats>.

the primary <GdkContentFormats> to intersect

second

Passed: a <GdkContentFormats>.

the <GdkContentFormats> to intersect with

%return

Returned: a string, or #f.

The first common mime type or #f if none

Method: content-formats:match? self second ⇒ %return
Method: match? self second ⇒ %return

Checks if self and second have any matching formats.

self

Passed: a <GdkContentFormats>.

the primary <GdkContentFormats> to intersect

second

Passed: a <GdkContentFormats>.

the <GdkContentFormats> to intersect with

%return

Returned: a boolean.

#t if a matching format was found.

Procedure: content-formats:new mime-types ⇒ %return

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

mime-types

Passed: a list or vector, each a string, or #f.

Pointer to an array of mime types

%return

Returned: a <GdkContentFormats>.

the new <GdkContentFormats>.

n-mime-types

Not passed: guile-gi gives the length of mime-types.

number of entries in mime-types.

Procedure: content-formats:new-for-gtype type ⇒ %return

Creates a new <GdkContentFormats> for a given GType.

type

Passed: a class, or a GType number.

a GType

%return

Returned: a <GdkContentFormats>.

a new <GdkContentFormats>

Procedure: content-formats:parse string ⇒ %return

Parses the given string into <GdkContentFormats> and returns the formats.

Strings printed via content-formats:to-string can be read in again successfully using this function.

If string does not describe valid content formats, #f is returned.

string

Passed: a string.

the string to parse

%return

Returned: a <GdkContentFormats>, or #f.

the content formats if string is valid

Method: content-formats:print self string
Method: print self string

Prints the given self into a string for human consumption.

The result of this function can later be parsed with content-formats:parse.

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

string

Passed: a <GString>.

a <GString> to print into

Method: content-formats:ref self ⇒ %return
Method: ref self ⇒ %return

Increases the reference count of a <GdkContentFormats> by one.

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

%return

Returned: a <GdkContentFormats>.

the passed in <GdkContentFormats>.

Method: content-formats:to-string self ⇒ %return
Method: to-string self ⇒ %return

Prints the given self into a human-readable string.

The resulting string can be parsed with content-formats:parse.

This is a small wrapper around content-formats:print to help when debugging.

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

%return

Returned: a string.

a new string

Method: content-formats:union self second ⇒ %return
Method: union self second ⇒ %return

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

self

Passed: a <GdkContentFormats>.

the <GdkContentFormats> to merge into

second

Passed: a <GdkContentFormats>.

the <GdkContentFormats> to merge from

%return

Returned: a <GdkContentFormats>.

a new <GdkContentFormats>

Method: content-formats:union-deserialize-gtypes self ⇒ %return
Method: union-deserialize-gtypes self ⇒ %return

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

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

%return

Returned: a <GdkContentFormats>.

a new <GdkContentFormats>

Method: content-formats:union-deserialize-mime-types self ⇒ %return
Method: union-deserialize-mime-types self ⇒ %return

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

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

%return

Returned: a <GdkContentFormats>.

a new <GdkContentFormats>

Method: content-formats:union-serialize-gtypes self ⇒ %return
Method: union-serialize-gtypes self ⇒ %return

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

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

%return

Returned: a <GdkContentFormats>.

a new <GdkContentFormats>

Method: content-formats:union-serialize-mime-types self ⇒ %return
Method: union-serialize-mime-types self ⇒ %return

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

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>

%return

Returned: a <GdkContentFormats>.

a new <GdkContentFormats>

Method: content-formats:unref self
Method: unref self

Decreases the reference count of a <GdkContentFormats> by one.

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

self

Passed: a <GdkContentFormats>.

a <GdkContentFormats>