Gdk.ContentFormats¶
Fields¶
None
Methods¶
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Gdk.ContentFormats¶
Used to advertise and negotiate the format of content.
You will encounter
GdkContentFormatswhen interacting with objects controlling operations that pass data between different widgets, window or application, like [class`Gdk`.Drag], [class`Gdk`.Drop], [class`Gdk`.Clipboard] or [class`Gdk`.ContentProvider].GDK supports content in 2 forms:
GTypeand mime type. UsingGTypesis 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, [class`Gdk`.ContentSerializer] and [class`Gdk`.ContentDeserializer] are used.A
GdkContentFormatsdescribes a set of possible formats content can be exchanged in. It is assumed that this set is ordered.GTypesare more important than mime types. Order between differentGTypesor mime types is the order they were added in, most important first. Functions that care about order, such as [method`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 [method`Gdk`.ContentFormats.to_string] exists. It will print a comma-separated list of formats from most important to least important.
GdkContentFormatsis an immutable struct. After creation, you cannot change the types it represents. Instead, newGdkContentFormatshave to be created. The [struct`Gdk`.ContentFormatsBuilder] structure is meant to help in this endeavor.- classmethod new(mime_types)[source]¶
- Parameters:
mime_types ([
str] orNone) – Pointer to an array of mime types- Returns:
the new
GdkContentFormats.- Return type:
Creates a new
GdkContentFormatsfrom 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 [struct`Gdk`.ContentFormatsBuilder] instead.
- classmethod new_for_gtype(type)[source]¶
- Parameters:
type (
GObject.GType) – aGType- Returns:
a new
GdkContentFormats- Return type:
Creates a new
GdkContentFormatsfor a givenGType.
- classmethod parse(string)[source]¶
- Parameters:
string (
str) – the string to parse- Returns:
the content formats if string is valid
- Return type:
Parses the given string into
GdkContentFormatsand returns the formats.Strings printed via [method`Gdk`.ContentFormats.to_string] can be read in again successfully using this function.
If string does not describe valid content formats,
Noneis returned.New in version 4.4.
- contain_gtype(type)[source]¶
- Parameters:
type (
GObject.GType) – theGTypeto search for- Returns:
Trueif theGTypewas found- Return type:
Checks if a given
GTypeis part of the given self.
- contain_mime_type(mime_type)[source]¶
- Parameters:
mime_type (
str) – the mime type to search for- Returns:
Trueif the mime_type was found- Return type:
Checks if a given mime type is part of the given self.
- get_gtypes()[source]¶
- Returns:
GObject.TYPE_INVALID-terminated array of types included in self- Return type:
[
GObject.GType] orNone
Gets the ``GType``s included in self.
Note that self may not contain any ``GType``s, in particular when they are empty. In that case
Nonewill be returned.
- get_mime_types()[source]¶
- Returns:
None-terminated array of interned strings of mime types included in self- Return type:
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
Nonewill be returned.
- is_empty()[source]¶
- Returns:
true if self contains no mime types and no GTypes
- Return type:
Returns whether the content formats contain any formats.
New in version 4.18.
- match(second)[source]¶
- Parameters:
second (
Gdk.ContentFormats) – theGdkContentFormatsto intersect with- Returns:
Trueif a matching format was found.- Return type:
Checks if self and second have any matching formats.
- match_gtype(second)[source]¶
- Parameters:
second (
Gdk.ContentFormats) – theGdkContentFormatsto intersect with- Returns:
The first common
GTypeorGObject.TYPE_INVALIDif none.- Return type:
Finds the first
GTypefrom self that is also contained in second.If no matching
GTypeis found,GObject.TYPE_INVALIDis returned.
- match_mime_type(second)[source]¶
- Parameters:
second (
Gdk.ContentFormats) – theGdkContentFormatsto intersect with- Returns:
The first common mime type or
Noneif none- Return type:
Finds the first mime type from self that is also contained in second.
If no matching mime type is found,
Noneis returned.
- print_(string)[source]¶
- Parameters:
string (
GLib.String) – aGStringto print into
Prints the given self into a string for human consumption.
The result of this function can later be parsed with [func`Gdk`.ContentFormats.parse].
- ref()[source]¶
- Returns:
the passed in
GdkContentFormats.- Return type:
Increases the reference count of a
GdkContentFormatsby one.
- to_string()[source]¶
- Returns:
a new string
- Return type:
Prints the given self into a human-readable string.
The resulting string can be parsed with [func`Gdk`.ContentFormats.parse].
This is a small wrapper around [method`Gdk`.ContentFormats.print] to help when debugging.
- union(second)[source]¶
- Parameters:
second (
Gdk.ContentFormats) – theGdkContentFormatsto merge from- Returns:
a new
GdkContentFormats- Return type:
Append all missing types from second to self, in the order they had in second.
- union_deserialize_gtypes()[source]¶
- Returns:
a new
GdkContentFormats- Return type:
Add GTypes for mime types in self for which deserializers are registered.
- union_deserialize_mime_types()[source]¶
- Returns:
a new
GdkContentFormats- Return type:
Add mime types for GTypes in self for which deserializers are registered.
- union_serialize_gtypes()[source]¶
- Returns:
a new
GdkContentFormats- Return type:
Add GTypes for the mime types in self for which serializers are registered.