pub struct ContentFormats { /* private fields */ }
Expand description
The ContentFormats
structure is used to advertise and negotiate the
format of content.
You will encounter ContentFormats
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 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_str()
exists. It will print a comma-separated list of formats from most important
to least important.
ContentFormats
is an immutable struct. After creation, you cannot change
the types it represents. Instead, new ContentFormats
have to be created.
The ContentFormatsBuilder
structure is meant to help in this
endeavor.
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
Source§impl ContentFormats
impl ContentFormats
Sourcepub fn as_ptr(&self) -> *mut GdkContentFormats
pub fn as_ptr(&self) -> *mut GdkContentFormats
Return the inner pointer to the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut GdkContentFormats) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GdkContentFormats) -> &Self
Borrows the underlying C value.
Source§impl ContentFormats
impl ContentFormats
Sourcepub fn new(mime_types: &[&str]) -> ContentFormats
pub fn new(mime_types: &[&str]) -> ContentFormats
Creates a new 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 ContentFormatsBuilder
instead.
§mime_types
Pointer to an array of mime types
§Returns
the new ContentFormats
.
Sourcepub fn for_type(type_: Type) -> ContentFormats
pub fn for_type(type_: Type) -> ContentFormats
Sourcepub fn contains_type(&self, type_: Type) -> bool
pub fn contains_type(&self, type_: Type) -> bool
Sourcepub fn contain_mime_type(&self, mime_type: &str) -> bool
pub fn contain_mime_type(&self, mime_type: &str) -> bool
Sourcepub fn mime_types(&self) -> Vec<GString>
pub fn mime_types(&self) -> Vec<GString>
Sourcepub fn match_(&self, second: &ContentFormats) -> bool
pub fn match_(&self, second: &ContentFormats) -> bool
Checks if @self and @second have any matching formats.
§second
the ContentFormats
to intersect with
§Returns
true
if a matching format was found.
Sourcepub fn match_type(&self, second: &ContentFormats) -> Type
pub fn match_type(&self, second: &ContentFormats) -> Type
Finds the first GType
from @self that is also contained
in @second.
If no matching GType
is found, G_TYPE_INVALID
is returned.
§second
the ContentFormats
to intersect with
§Returns
The first common GType
or G_TYPE_INVALID
if none.
Sourcepub fn match_mime_type(&self, second: &ContentFormats) -> Option<GString>
pub fn match_mime_type(&self, second: &ContentFormats) -> Option<GString>
Finds the first mime type from @self that is also contained in @second.
If no matching mime type is found, None
is returned.
§second
the ContentFormats
to intersect with
§Returns
The first common mime type or None
if none
Sourcepub fn union(self, second: &ContentFormats) -> ContentFormats
pub fn union(self, second: &ContentFormats) -> ContentFormats
Append all missing types from @second to @self, in the order they had in @second.
§second
the ContentFormats
to merge from
§Returns
a new ContentFormats
Sourcepub fn union_deserialize_types(self) -> ContentFormats
pub fn union_deserialize_types(self) -> ContentFormats
Add GTypes for mime types in @self for which deserializers are registered.
§Returns
a new ContentFormats
Sourcepub fn union_deserialize_mime_types(self) -> ContentFormats
pub fn union_deserialize_mime_types(self) -> ContentFormats
Add mime types for GTypes in @self for which deserializers are registered.
§Returns
a new ContentFormats
Sourcepub fn union_serialize_types(self) -> ContentFormats
pub fn union_serialize_types(self) -> ContentFormats
Add GTypes for the mime types in @self for which serializers are registered.
§Returns
a new ContentFormats
Sourcepub fn union_serialize_mime_types(self) -> ContentFormats
pub fn union_serialize_mime_types(self) -> ContentFormats
Add mime types for GTypes in @self for which serializers are registered.
§Returns
a new ContentFormats
Sourcepub fn parse(string: &str) -> Result<ContentFormats, BoolError>
Available on crate feature v4_4
only.
pub fn parse(string: &str) -> Result<ContentFormats, BoolError>
v4_4
only.Parses the given @string into ContentFormats
and
returns the formats.
Strings printed via to_str()
can be read in again successfully using this function.
If @string does not describe valid content formats, None
is returned.
§string
the string to parse
§Returns
the content formats if @string is valid
Source§impl ContentFormats
impl ContentFormats
Sourcepub fn builder() -> ContentFormatsBuilder
pub fn builder() -> ContentFormatsBuilder
Creates a new builder-pattern struct instance to construct
ContentFormats
objects.
This method returns an instance of
ContentFormatsBuilder
which
can be used to create ContentFormats
objects.
Trait Implementations§
Source§impl Clone for ContentFormats
impl Clone for ContentFormats
Source§impl Debug for ContentFormats
impl Debug for ContentFormats
Source§impl Display for ContentFormats
impl Display for ContentFormats
Source§impl From<ContentFormats> for Value
impl From<ContentFormats> for Value
Source§fn from(s: ContentFormats) -> Self
fn from(s: ContentFormats) -> Self
Source§impl FromStr for ContentFormats
Available on crate feature v4_4
only.
impl FromStr for ContentFormats
v4_4
only.Source§impl HasParamSpec for ContentFormats
impl HasParamSpec for ContentFormats
type ParamSpec = ParamSpecBoxed
Source§type SetValue = ContentFormats
type SetValue = ContentFormats
type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, ContentFormats>
fn param_spec_builder() -> Self::BuilderFn
Source§impl Hash for ContentFormats
impl Hash for ContentFormats
Source§impl Ord for ContentFormats
impl Ord for ContentFormats
Source§fn cmp(&self, other: &ContentFormats) -> Ordering
fn cmp(&self, other: &ContentFormats) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ContentFormats
impl PartialEq for ContentFormats
Source§impl PartialOrd for ContentFormats
impl PartialOrd for ContentFormats
Source§impl StaticType for ContentFormats
impl StaticType for ContentFormats
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.