gtkmm 4.7.1

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gdk::ContentFormats Class Referencefinal

Advertising and negotiating of content exchange formats. More...

`#include <gdkmm/contentformats.h>`

## Public Member Functions
void | reference () const
| Increment the reference count for this object. More...
void | unreference () const
| Decrement the reference count for this object. More...
GdkContentFormats * | gobj ()
| Provides access to the underlying C instance. More...
const GdkContentFormats * | gobj () const
| Provides access to the underlying C instance. More...
GdkContentFormats * | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
| ContentFormats ()=delete
| ContentFormats (const ContentFormats &)=delete
ContentFormats & | operator= (const ContentFormats &)=delete
Glib::ustring | to_string () const
| Prints the given ContentFormats into a string for human consumption. More...
std::vector< GType > | get_gtypes () const
| Gets the Types included in the ContentFormats. More...
std::vector< Glib::ustring > | get_mime_types () const
| Gets the mime types included in the ContentFormats. More...
bool | contain_gtype (GType type) const
| Checks if a given `GType` is part of the given formats. More...
bool | contain_mime_type (const Glib::ustring & mime_type) const
| Checks if a given mime type is part of the given formats. More...
Glib::RefPtr< ContentFormats > | join (const Glib::RefPtr< const ContentFormats > & second) const
| Append all missing types from second to `*this`, in the order they had in second. More...
bool | match (const Glib::RefPtr< const ContentFormats > & second) const
| Checks if first and second have any matching formats. More...
GType | match_gtype (const Glib::RefPtr< const ContentFormats > & second) const
| Finds the first `GType` from first that is also contained in second. More...
Glib::ustring | match_mime_type (const Glib::RefPtr< const ContentFormats > & second) const
| Finds the first mime type from `*this` that is also contained in second. More...

## Static Public Member Functions
static Glib::RefPtr< ContentFormats > | create (const std::vector< Glib::ustring > & mime_types={})
| Creates a new Gdk::ContentFormats from an array of mime types. More...
static Glib::RefPtr< ContentFormats > | create (const Glib::ustring & mime_type)
| Creates a new Gdk::ContentFormats from a mime type. More...
static Glib::RefPtr< ContentFormats > | create (GType type)
| Creates a new Gdk::ContentFormats from a GType. More...
static Glib::RefPtr< ContentFormats > | parse (const Glib::ustring &string)
| Parses the given string into `Gdk::ContentFormats` and returns the formats. More...

## Protected Member Functions
void | operator delete (void *, std::size_t)

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gdk::ContentFormats > | wrap (GdkContentFormats * object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

Advertising and negotiating of content exchange formats.

Gdk::ContentFormats is used to advertise and negotiate the format of content passed between different widgets, windows or applications using for example the clipboard or drag'n'drop.

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.

A Gdk::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 join(), 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.

Gdk::ContentFormats is an immutable object. After creation, you cannot change the types it represents. Instead, new Gdk::ContentFormats have to be created. Gdk::ContentFormatsBuilder is meant to help in this endeavor.

See also
  Gdk::Drag, Gdk::Drop, Gdk::Clipboard

Since gtkmm 3.94:

## Constructor & Destructor Documentation

## ◆ ContentFormats() [1/2]

Gdk::ContentFormats::ContentFormats | ( |  | ) |
| delete

## ◆ ContentFormats() [2/2]

Gdk::ContentFormats::ContentFormats | ( | const ContentFormats & |  | ) |
| delete

## Member Function Documentation

## ◆ contain_gtype()

bool Gdk::ContentFormats::contain_gtype | ( | GType | type | ) | const

Checks if a given `GType` is part of the given formats.

Parameters

  type | The `GType` to search for.

Returns
  `true` if the `GType` was found.

## ◆ contain_mime_type()

bool Gdk::ContentFormats::contain_mime_type | ( | const Glib::ustring & | mime_type | ) | const

Checks if a given mime type is part of the given formats.

Parameters

  mime_type | The mime type to search for.

Returns
  `true` if the mime_type was found.

## ◆ create() [1/3]

static Glib::RefPtr<ContentFormats> Gdk::ContentFormats::create | ( | const Glib::ustring & | mime_type | ) |
| static

Creates a new Gdk::ContentFormats from a mime type.

Parameters

  mime_type | A mime type.

Returns
  The new Gdk::ContentFormats.

## ◆ create() [2/3]

static Glib::RefPtr<ContentFormats> Gdk::ContentFormats::create | ( | const std::vector< Glib::ustring > & | mime_types = `{}` | ) |
| static

Creates a new Gdk::ContentFormats from an array of mime types.

The mime types must be different or the behavior of the return value is undefined. If you cannot guarantee this, use Gdk::ContentFormatsBuilder instead.

Parameters

  mime_types | A vector of mime types.

Returns
  The new Gdk::ContentFormats.

## ◆ create() [3/3]

static Glib::RefPtr<ContentFormats> Gdk::ContentFormats::create | ( | GType | type | ) |
| static

Creates a new Gdk::ContentFormats from a GType.

Parameters

  type | A GType.

Returns
  The new Gdk::ContentFormats.

## ◆ get_gtypes()

std::vector<GType> Gdk::ContentFormats::get_gtypes | ( |  | ) | const

Gets the Types included in the ContentFormats.

Note that they may not contain any Types, in particular when they are empty. In that case an empty vector will be returned.

Returns
  A vector of types included in the ContentFormats. May be empty.

## ◆ get_mime_types()

std::vector<Glib::ustring> Gdk::ContentFormats::get_mime_types | ( |  | ) | const

Gets the mime types included in the ContentFormats.

Note that they may not contain any mime types, in particular when they are empty. In that case an empty vector will be returned.

Returns
  A vector of mime types included in the ContentFormats. May be empty.

## ◆ gobj() [1/2]

GdkContentFormats* Gdk::ContentFormats::gobj | ( |  | ) |

Provides access to the underlying C instance.

## ◆ gobj() [2/2]

const GdkContentFormats* Gdk::ContentFormats::gobj | ( |  | ) | const

Provides access to the underlying C instance.

## ◆ gobj_copy()

GdkContentFormats* Gdk::ContentFormats::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

## ◆ join()

Glib::RefPtr<ContentFormats> Gdk::ContentFormats::join | ( | const Glib::RefPtr< const ContentFormats > & | second | ) | const

Append all missing types from second to `*this`, in the order they had in second.

Parameters

  second | The ContentFormats to merge from.

Returns
  A new ContentFormats.

## ◆ match()

bool Gdk::ContentFormats::match | ( | const Glib::RefPtr< const ContentFormats > & | second | ) | const

Checks if first and second have any matching formats.

Parameters

  second | The `Gdk::ContentFormats` to intersect with.

Returns
  `true` if a matching format was found.

## ◆ match_gtype()

GType Gdk::ContentFormats::match_gtype | ( | const Glib::RefPtr< const ContentFormats > & | second | ) | const

Finds the first `GType` from first that is also contained in second.

If no matching `GType` is found, G_TYPE_INVALID is returned.

Parameters

  second | The `Gdk::ContentFormats` to intersect with.

Returns
  The first common `GType` or G_TYPE_INVALID if none.

## ◆ match_mime_type()

Glib::ustring Gdk::ContentFormats::match_mime_type | ( | const Glib::RefPtr< const ContentFormats > & | second | ) | const

Finds the first mime type from `*this` that is also contained in second.

If no matching mime type is found, an empty string is returned.

Parameters

  second | The Gdk::ContentFormats to intersect with.

Returns
  The first common mime type, or an empty string if none.

## ◆ operator delete()

void Gdk::ContentFormats::operator delete | ( | void * | ,
|  | std::size_t |
| ) |  |
| protected

## ◆ operator=()

ContentFormats& Gdk::ContentFormats::operator= | ( | const ContentFormats & |  | ) |
| delete

## ◆ parse()

static Glib::RefPtr<ContentFormats> Gdk::ContentFormats::parse | ( | const Glib::ustring & | string | ) |
| static

Parses the given string into `Gdk::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, `nullptr` is returned.

Since gtkmm 4.4:

Parameters

  string | The string to parse.

Returns
  The content formats if string is valid.

## ◆ reference()

void Gdk::ContentFormats::reference | ( |  | ) | const

Increment the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

## ◆ to_string()

Glib::ustring Gdk::ContentFormats::to_string | ( |  | ) | const

Prints the given ContentFormats into a string for human consumption.

The resulting string can be parsed with parse().

Returns
  A new string.

## ◆ unreference()

void Gdk::ContentFormats::unreference | ( |  | ) | const

Decrement the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

## Friends And Related Function Documentation

## ◆ wrap()

Glib::RefPtr< Gdk::ContentFormats > wrap | ( | GdkContentFormats * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.