Class ContentFormats
- All Implemented Interfaces:
Proxy
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 Drag
, Drop
,
Clipboard
or 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,
ContentSerializer
and 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 union(org.gnome.gdk.ContentFormats)
, 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 toString()
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 Gdk.ContentFormatsBuilder
structure is meant to help in this
endeavor.
-
Constructor Summary
ConstructorDescriptionCallsContentFormats(java.lang.String[])
with mimeTypes =null
ContentFormats
(@Nullable String[] mimeTypes) Creates a newGdkContentFormats
from an array of mime types.ContentFormats
(MemorySegment address) Create a ContentFormats proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containGtype
(Type type) Checks if a givenGType
is part of the given this ContentFormats.boolean
containMimeType
(String mimeType) Checks if a given mime type is part of the given this ContentFormats.static ContentFormats
Creates a newGdkContentFormats
for a givenGType
.Type[]
Gets theGType
s included in this ContentFormats.String[]
Gets the mime types included in this ContentFormats.static Type
getType()
Get the GType of the ContentFormats classboolean
match
(ContentFormats second) Checks if this ContentFormats andsecond
have any matching formats.matchGtype
(ContentFormats second) Finds the firstGType
from this ContentFormats that is also contained insecond
.matchMimeType
(ContentFormats second) Finds the first mime type from this ContentFormats that is also contained insecond
.static ContentFormats
Parses the givenstring
intoGdkContentFormats
and returns the formats.void
Prints the given this ContentFormats into a string for human consumption.ref()
Increases the reference count of aGdkContentFormats
by one.toString()
Prints the given this ContentFormats into a human-readable string.union
(ContentFormats second) Append all missing types fromsecond
to this ContentFormats, in the order they had insecond
.Add GTypes for mime types in this ContentFormats for which deserializers are registered.Add mime types for GTypes in this ContentFormats for which deserializers are registered.Add GTypes for the mime types in this ContentFormats for which serializers are registered.Add mime types for GTypes in this ContentFormats for which serializers are registered.void
unref()
Decreases the reference count of aGdkContentFormats
by one.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
ContentFormats
Create a ContentFormats proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
ContentFormats
Creates a newGdkContentFormats
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
Gdk.ContentFormatsBuilder
instead.- Parameters:
mimeTypes
- Pointer to an array of mime types
-
ContentFormats
public ContentFormats()CallsContentFormats(java.lang.String[])
with mimeTypes =null
-
-
Method Details
-
getType
-
forGtype
Creates a newGdkContentFormats
for a givenGType
.- Parameters:
type
- aGType
- Returns:
- a new
GdkContentFormats
-
parse
Parses the givenstring
intoGdkContentFormats
and returns the formats.Strings printed via
toString()
can be read in again successfully using this function.If
string
does not describe valid content formats,null
is returned.- Parameters:
string
- the string to parse- Returns:
- the content formats if
string
is valid
-
containGtype
Checks if a givenGType
is part of the given this ContentFormats.- Parameters:
type
- theGType
to search for- Returns:
true
if theGType
was found
-
containMimeType
Checks if a given mime type is part of the given this ContentFormats.- Parameters:
mimeType
- the mime type to search for- Returns:
true
if the mime_type was found
-
getGtypes
Gets theGType
s included in this ContentFormats.Note that this ContentFormats may not contain any
GType
s, in particular when they are empty. In that casenull
will be returned.- Returns:
G_TYPE_INVALID
-terminated array of types included in this ContentFormats
-
getMimeTypes
Gets the mime types included in this ContentFormats.Note that this ContentFormats may not contain any mime types, in particular when they are empty. In that case
null
will be returned.- Returns:
null
-terminated array of interned strings of mime types included in this ContentFormats
-
match
Checks if this ContentFormats andsecond
have any matching formats.- Parameters:
second
- theGdkContentFormats
to intersect with- Returns:
true
if a matching format was found.
-
matchGtype
Finds the firstGType
from this ContentFormats that is also contained insecond
.If no matching
GType
is found,G_TYPE_INVALID
is returned.- Parameters:
second
- theGdkContentFormats
to intersect with- Returns:
- The first common
GType
orG_TYPE_INVALID
if none.
-
matchMimeType
Finds the first mime type from this ContentFormats that is also contained insecond
.If no matching mime type is found,
null
is returned.- Parameters:
second
- theGdkContentFormats
to intersect with- Returns:
- The first common mime type or
null
if none
-
print
Prints the given this ContentFormats into a string for human consumption.The result of this function can later be parsed with
parse(java.lang.String)
.- Parameters:
string
- aGString
to print into
-
ref
Increases the reference count of aGdkContentFormats
by one.- Returns:
- the passed in
GdkContentFormats
.
-
toString
Prints the given this ContentFormats into a human-readable string.The resulting string can be parsed with
parse(java.lang.String)
.This is a small wrapper around
print(org.gnome.glib.GString)
to help when debugging. -
union
Append all missing types fromsecond
to this ContentFormats, in the order they had insecond
.- Parameters:
second
- theGdkContentFormats
to merge from- Returns:
- a new
GdkContentFormats
-
unionDeserializeGtypes
Add GTypes for mime types in this ContentFormats for which deserializers are registered.- Returns:
- a new
GdkContentFormats
-
unionDeserializeMimeTypes
Add mime types for GTypes in this ContentFormats for which deserializers are registered.- Returns:
- a new
GdkContentFormats
-
unionSerializeGtypes
Add GTypes for the mime types in this ContentFormats for which serializers are registered.- Returns:
- a new
GdkContentFormats
-
unionSerializeMimeTypes
Add mime types for GTypes in this ContentFormats for which serializers are registered.- Returns:
- a new
GdkContentFormats
-
unref
public void unref()Decreases the reference count of aGdkContentFormats
by one.If the resulting reference count is zero, frees the formats.
-