gtkmm 4.14.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gdk::ContentProvider Class Reference

Provides content for data transfer between applications. More...

#include <gdkmm/contentprovider.h>

Inheritance diagram for Gdk::ContentProvider:
Inheritance graph
[legend]

Public Member Functions

 ContentProvider (ContentProvider && src) noexcept
 
ContentProvideroperator= (ContentProvider && src) noexcept
 
 ~ContentProvider () noexcept override
 
GdkContentProvider * gobj ()
 Provides access to the underlying C GObject. More...
 
const GdkContentProvider * gobj () const
 Provides access to the underlying C GObject. More...
 
GdkContentProvider * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
Glib::RefPtr< ContentFormatsref_formats () const
 Gets the formats that the provider can provide its current contents in. More...
 
Glib::RefPtr< ContentFormatsref_storable_formats () const
 Gets the formats that the provider suggests other applications to store the data in. More...
 
void content_changed ()
 Emits the signal_content_changed() signal. More...
 
void write_mime_type_async (const Glib::ustring & mime_type, const Glib::RefPtr< Gio::OutputStream > & stream, int io_priority, const Gio::SlotAsyncReady & slot, const Glib::RefPtr< Gio::Cancellable > & cancellable) const
 Asynchronously writes the contents of provider to stream in the given mime_type. More...
 
void write_mime_type_async (const Glib::ustring & mime_type, const Glib::RefPtr< Gio::OutputStream > & stream, int io_priority, const Gio::SlotAsyncReady & slot) const
 A write_mime_type_async() convenience overload. More...
 
void write_mime_type_finish (const Glib::RefPtr< Gio::AsyncResult > & result) const
 Finishes an asynchronous write operation. More...
 
void get_value (Glib::ValueBase & value) const
 Gets the contents of provider stored in value. More...
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ContentFormats > > property_formats () const
 The possible formats that the provider can provide its data in. More...
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ContentFormats > > property_storable_formats () const
 The subset of formats that clipboard managers should store this provider's data in. More...
 
Glib::SignalProxy< void()> signal_content_changed ()
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static Glib::RefPtr< ContentProvidercreate (const Glib::ValueBase & value)
 Create a content provider that provides the given value. More...
 
static Glib::RefPtr< ContentProvidercreate (const std::vector< Glib::RefPtr< ContentProvider > > & providers)
 Creates a content provider that represents all the given providers. More...
 
static Glib::RefPtr< ContentProvidercreate (const Glib::ustring & mime_type, const Glib::RefPtr< const Glib::Bytes > & bytes)
 Create a content provider that provides the given bytes as data for the given mime_type. More...
 

Protected Member Functions

 ContentProvider ()
 
virtual void on_content_changed ()
 This is a default handler for the signal signal_content_changed(). More...
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gdk::ContentProviderwrap (GdkContentProvider * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

Provides content for data transfer between applications.

A Gdk::ContentProvider is used to provide content for the clipboard in a number of formats.

To create a ContentProvider, use one of the overloaded create() methods.

GDK knows how to handle common text and image formats out-of-the-box. See Gdk::ContentSerializer and Gdk::ContentDeserializer if you want to add support for application-specific data formats.

See also
Gdk::ContentSerializer, Gdk::ContentDeserializer
Since gtkmm 3.94:

Constructor & Destructor Documentation

◆ ContentProvider() [1/2]

Gdk::ContentProvider::ContentProvider ( ContentProvider &&  src)
noexcept

◆ ~ContentProvider()

Gdk::ContentProvider::~ContentProvider ( )
overridenoexcept

◆ ContentProvider() [2/2]

Gdk::ContentProvider::ContentProvider ( )
protected

Member Function Documentation

◆ content_changed()

void Gdk::ContentProvider::content_changed ( )

Emits the signal_content_changed() signal.

◆ create() [1/3]

static Glib::RefPtr< ContentProvider > Gdk::ContentProvider::create ( const Glib::ustring &  mime_type,
const Glib::RefPtr< const Glib::Bytes > &  bytes 
)
static

Create a content provider that provides the given bytes as data for the given mime_type.

Parameters
mime_typeThe mime type.
bytesA Glib::Bytes with the data for mime_type.
Returns
A new Gdk::ContentProvider.

◆ create() [2/3]

static Glib::RefPtr< ContentProvider > Gdk::ContentProvider::create ( const Glib::ValueBase &  value)
static

Create a content provider that provides the given value.

Parameters
valueA Glib::Value.
Returns
A new Gdk::ContentProvider.

◆ create() [3/3]

static Glib::RefPtr< ContentProvider > Gdk::ContentProvider::create ( const std::vector< Glib::RefPtr< ContentProvider > > &  providers)
static

Creates a content provider that represents all the given providers.

Whenever data needs to be written, the union provider will try the given providers in the given order and the first one supporting a format will be chosen to provide it.

This allows an easy way to support providing data in different formats. For example, an image may be provided by its file and by the image contents with a call such as

[C example ellipted]

Parameters
providersThe Gdk::ContentProviders to present the union of.
n_providersThe number of providers.
Returns
A new Gdk::ContentProvider.

◆ get_type()

static GType Gdk::ContentProvider::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ get_value()

void Gdk::ContentProvider::get_value ( Glib::ValueBase &  value) const

Gets the contents of provider stored in value.

The value will have been initialized to the GType the value should be provided in. This given GType does not need to be listed in the formats returned by ref_formats(). However, if the given GType is not supported, this operation can fail and Gio::Error::NOT_SUPPORTED will be reported.

Parameters
valueThe Glib::Value to fill.
Exceptions
Glib::Error

◆ gobj() [1/2]

GdkContentProvider * Gdk::ContentProvider::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GdkContentProvider * Gdk::ContentProvider::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GdkContentProvider * Gdk::ContentProvider::gobj_copy ( )

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

◆ on_content_changed()

virtual void Gdk::ContentProvider::on_content_changed ( )
protectedvirtual

This is a default handler for the signal signal_content_changed().

◆ operator=()

ContentProvider & Gdk::ContentProvider::operator= ( ContentProvider &&  src)
noexcept

◆ property_formats()

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ContentFormats > > Gdk::ContentProvider::property_formats ( ) const

The possible formats that the provider can provide its data in.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_storable_formats()

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ContentFormats > > Gdk::ContentProvider::property_storable_formats ( ) const

The subset of formats that clipboard managers should store this provider's data in.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ ref_formats()

Glib::RefPtr< ContentFormats > Gdk::ContentProvider::ref_formats ( ) const

Gets the formats that the provider can provide its current contents in.

Returns
The formats of the provider.

◆ ref_storable_formats()

Glib::RefPtr< ContentFormats > Gdk::ContentProvider::ref_storable_formats ( ) const

Gets the formats that the provider suggests other applications to store the data in.

An example of such an application would be a clipboard manager.

This can be assumed to be a subset of ref_formats().

Returns
The storable formats of the provider.

◆ signal_content_changed()

Glib::SignalProxy< void()> Gdk::ContentProvider::signal_content_changed ( )
Slot Prototype:
void on_my_content_changed()

Flags: Run Last

Emitted whenever the content provided by this provider has changed.

◆ write_mime_type_async() [1/2]

void Gdk::ContentProvider::write_mime_type_async ( const Glib::ustring &  mime_type,
const Glib::RefPtr< Gio::OutputStream > &  stream,
int  io_priority,
const Gio::SlotAsyncReady &  slot 
) const

A write_mime_type_async() convenience overload.

◆ write_mime_type_async() [2/2]

void Gdk::ContentProvider::write_mime_type_async ( const Glib::ustring &  mime_type,
const Glib::RefPtr< Gio::OutputStream > &  stream,
int  io_priority,
const Gio::SlotAsyncReady &  slot,
const Glib::RefPtr< Gio::Cancellable > &  cancellable 
) const

Asynchronously writes the contents of provider to stream in the given mime_type.

When the operation is finished slot will be called. You must then call write_mime_type_finish() to get the result of the operation.

The given mime type does not need to be listed in the formats returned by ref_formats(). However, if the given GType is not supported, Gio::Error::NOT_SUPPORTED will be reported.

The given stream will not be closed.

Parameters
mime_typeThe mime type to provide the data in.
streamThe Gio::OutputStream to write to.
io_priorityI/O priority of the request.
cancellableOptional Gio::Cancellable object, nullptr to ignore.
slotCallback to call when the request is satisfied.

◆ write_mime_type_finish()

void Gdk::ContentProvider::write_mime_type_finish ( const Glib::RefPtr< Gio::AsyncResult > &  result) const

Finishes an asynchronous write operation.

See write_mime_type_async().

Parameters
resultA Gio::AsyncResult.
Exceptions
Glib::Error

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gdk::ContentProvider > wrap ( GdkContentProvider *  object,
bool  take_copy = false 
)
related

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

Parameters
objectThe C instance.
take_copyFalse 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.