
Gnome::Gdk4::N-ContentFormats
Description
The Gnome::Gdk4::N-ContentFormats structure is used to advertise and negotiate the format of content.
You will encounter Gnome::Gdk4::N-ContentFormats when interacting with objects controlling operations that pass data between different widgets, window or application, like Gnome::Gdk4::Drag, Gnome::Gdk4::Drop, Gnome::Gdk4::Clipboard or Gnome::Gdk4::ContentProvider.
GDK supports content in 2 forms: Gnome::GObject::ContentFormats 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, Gnome::Gdk4::ContentSerializer and Gnome::Gdk4::ContentDeserializer are used.
A Gnome::Gdk4::N-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 .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 .to-string()
exists. It will print a comma-separated list of formats from most important to least important.
Gnome::Gdk4::N-ContentFormats is an immutable struct. After creation, you cannot change the types it represents. Instead, new Gnome::Gdk4::N-ContentFormats have to be created. The Gnome::Gdk4::N-ContentFormatsBuilder structure is meant to help in this endeavor.
Class initialization
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
new-contentformats
Creates a new Gnome::Gdk4::N-ContentFormats 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 Gnome::Gdk4::N-ContentFormatsBuilder instead.
method new-contentformats ( Array[Str] $mime-types, UInt() $n-mime-types --> Gnome::Gdk4::ContentFormats \)
$mime-types; Pointer to an array of mime types.
$n-mime-types; number of entries in
$mime-types
..
new-for-gtype
Creates a new Gnome::Gdk4::N-ContentFormats for a given Gnome::GObject::ContentFormats.
method new-for-gtype ( GType $type --> Gnome::Gdk4::ContentFormats \)
$type; a Gnome::GObject::ContentFormats.
Methods
contain-gtype
Checks if a given Gnome::GObject::ContentFormats is part of the given $formats
.
method contain-gtype ( GType $type --> Bool )
$type; the Gnome::GObject::ContentFormats to search for.
Return value; True
if the Gnome::GObject::ContentFormats was found.
contain-mime-type
Checks if a given mime type is part of the given $formats
.
method contain-mime-type ( Str $mime-type --> Bool )
$mime-type; the mime type to search for.
Return value; True
if the mime_type was found.
get-gtypes This function is not yet available
Gets the Gnome::GObject::ContentFormatss included in $formats
.
Note that $formats
may not contain any Gnome::GObject::ContentFormatss, in particular when they are empty. In that case undefined will be returned.
method get-gtypes ( Array[gsize] $n-gtypes )
$n-gtypes; (transfer ownership: full) optional pointer to take the number of Gnome::GObject::ContentFormatss contained in the return value.
get-mime-types
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 undefined will be returned.
method get-mime-types ( Array[gsize] $n-mime-types --> Array[Str] )
$n-mime-types; (transfer ownership: full) optional pointer to take the number of mime types contained in the return value.
Return value; interned array strings of mime types included in $formats
.
match
Checks if $first
and $second
have any matching formats.
method match ( N-Object $second --> Bool )
$second; the Gnome::Gdk4::N-ContentFormats to intersect with
Return value; True
if a matching format was found..
match-gtype
Finds the first Gnome::GObject::ContentFormats from $first
that is also contained in $second
.
If no matching Gnome::GObject::ContentFormats is found, G_TYPE_INVALID
is returned.
method match-gtype ( N-Object $second --> GType )
$second; the Gnome::Gdk4::N-ContentFormats to intersect with
Return value; The first common Gnome::GObject::ContentFormats or G_TYPE_INVALID
if none..
match-mime-type
Finds the first mime type from $first
that is also contained in $second
.
If no matching mime type is found, undefined is returned.
method match-mime-type ( N-Object $second --> Str )
$second; the Gnome::Gdk4::N-ContentFormats to intersect with
Return value; The first common mime type or undefined if none.
Prints the given $formats
into a string for human consumption.
The result of this function can later be parsed with .ContentFormats.parse()
.
method print ( N-Object $string )
$string; a Gnome::Glib::N-String to print into
ref
Increases the reference count of a Gnome::Gdk4::N-ContentFormats by one.
method ref (--> N-Object )
Return value; the passed in Gnome::Gdk4::N-ContentFormats..
to-string
Prints the given $formats
into a human-readable string.
The resulting string can be parsed with .ContentFormats.parse()
.
This is a small wrapper around .print()
to help when debugging.
method to-string (--> Str )
Return value; a new string.
union
Append all missing types from $second
to $first
, in the order they had in $second
.
method union ( N-Object $second --> N-Object )
$second; the Gnome::Gdk4::N-ContentFormats to merge from
Return value; a new Gnome::Gdk4::N-ContentFormats.
union-deserialize-gtypes
Add GTypes for mime types in $formats
for which deserializers are registered.
method union-deserialize-gtypes (--> N-Object )
Return value; a new Gnome::Gdk4::N-ContentFormats.
union-deserialize-mime-types
Add mime types for GTypes in $formats
for which deserializers are registered.
method union-deserialize-mime-types (--> N-Object )
Return value; a new Gnome::Gdk4::N-ContentFormats.
union-serialize-gtypes
Add GTypes for the mime types in $formats
for which serializers are registered.
method union-serialize-gtypes (--> N-Object )
Return value; a new Gnome::Gdk4::N-ContentFormats.
union-serialize-mime-types
Add mime types for GTypes in $formats
for which serializers are registered.
method union-serialize-mime-types (--> N-Object )
Return value; a new Gnome::Gdk4::N-ContentFormats.
unref
Decreases the reference count of a Gnome::Gdk4::N-ContentFormats by one.
If the resulting reference count is zero, frees the formats.
method unref ( )
Functions
parse
Parses the given $string
into Gnome::Gdk4::N-ContentFormats and returns the formats.
Strings printed via .to-string()
can be read in again successfully using this function.
If $string
does not describe valid content formats, undefined is returned.
method parse ( Str $string --> N-Object )
$string; the string to parse.
Return value; the content formats if $string
is valid.