ContentFormats
- class ContentFormats(**kwargs)
- Constructors:
new(mime_types:list=None) -> Gdk.ContentFormats
new_for_gtype(type:GType) -> Gdk.ContentFormats
Constructors
- class ContentFormats
- classmethod new(mime_types: Sequence[str] | None = None) ContentFormats
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
ContentFormatsBuilder
instead.- Parameters:
mime_types – Pointer to an array of mime types
- classmethod new_for_gtype(type: type) ContentFormats
Creates a new
GdkContentFormats
for a givenGType
.- Parameters:
type – a
GType
Methods
- class ContentFormats
- contain_gtype(type: type) bool
Checks if a given
GType
is part of the givenformats
.- Parameters:
type – the
GType
to search for
- contain_mime_type(mime_type: str) bool
Checks if a given mime type is part of the given
formats
.- Parameters:
mime_type – the mime type to search for
- get_gtypes() list[type] | None
Gets the
GType
’s included informats
.Note that
formats
may not contain anyGType
’s, in particular when they are empty. In that caseNone
will be returned.
- get_mime_types() list[str] | None
Gets the mime types included in
formats
.Note that
formats
may not contain any mime types, in particular when they are empty. In that caseNone
will be returned.
- match(second: ContentFormats) bool
Checks if
first
andsecond
have any matching formats.- Parameters:
second – the
GdkContentFormats
to intersect with
- match_gtype(second: ContentFormats) type
Finds the first
GType
fromfirst
that is also contained insecond
.If no matching
GType
is found,Invalid
is returned.- Parameters:
second – the
GdkContentFormats
to intersect with
- match_mime_type(second: ContentFormats) str | None
Finds the first mime type from
first
that is also contained insecond
.If no matching mime type is found,
None
is returned.- Parameters:
second – the
GdkContentFormats
to intersect with
- parse(string: str) ContentFormats | None
Parses the given
string
intoGdkContentFormats
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,None
is returned.Added in version 4.4.
- Parameters:
string – the string to parse
- to_string() str
Prints the given
formats
into a human-readable string.The resulting string can be parsed with
parse
.This is a small wrapper around
print
to help when debugging.
- union(second: ContentFormats) ContentFormats
Append all missing types from
second
tofirst
, in the order they had insecond
.- Parameters:
second – the
GdkContentFormats
to merge from
- union_deserialize_gtypes() ContentFormats
Add GTypes for mime types in
formats
for which deserializers are registered.
- union_deserialize_mime_types() ContentFormats
Add mime types for GTypes in
formats
for which deserializers are registered.
- union_serialize_gtypes() ContentFormats
Add GTypes for the mime types in
formats
for which serializers are registered.
- union_serialize_mime_types() ContentFormats
Add mime types for GTypes in
formats
for which serializers are registered.