gtkmm: Gdk::Clipboard Class Reference

Share data between applications for Copy-and-Paste. More...

#include <gdkmm/clipboard.h>

Inheritance diagram for Gdk::Clipboard:

Public Member Functions

 Clipboard (Clipboard&& src) noexcept
 
Clipboardoperator= (Clipboard&& src) noexcept
 
 ~Clipboard () noexcept override
 
GdkClipboard* gobj ()
 Provides access to the underlying C GObject. More...

 
const GdkClipboard* gobj () const
 Provides access to the underlying C GObject. More...

 
GdkClipboard* 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< Displayget_display ()
 Gets the Gdk::Display that the clipboard was created for. More...

 
Glib::RefPtr< const Displayget_display () const
 Gets the Gdk::Display that the clipboard was created for. More...

 
Glib::RefPtr< ContentFormatsget_formats ()
 Gets the formats that the clipboard can provide its current contents in. More...

 
Glib::RefPtr< const ContentFormatsget_formats () const
 Gets the formats that the clipboard can provide its current contents in. More...

 
bool is_local () const
 Returns if the clipboard is local. More...

 
Glib::RefPtr< ContentProviderget_content ()
 Returns the Gdk::ContentProvider currently set on clipboard. More...

 
Glib::RefPtr< const ContentProviderget_content () const
 Returns the Gdk::ContentProvider currently set on clipboard. More...

 
void read_async (const std::vector< Glib::ustring >& mime_types, int io_priority, const Gio::SlotAsyncReady& slot, const Glib::RefPtr< Gio::Cancellable >& cancellable)
 Asynchronously requests an input stream to read the clipboard's contents from. More...

 
void read_async (const std::vector< Glib::ustring >& mime_types, int io_priority, const Gio::SlotAsyncReady& slot)
 A read_async() convenience overload. More...

 
Glib::RefPtr< Gio::InputStreamread_finish (const Glib::RefPtr< Gio::AsyncResult >& result, Glib::ustring& out_mime_type)
 Finishes an asynchronous clipboard read started with read_async(). More...

 
void read_texture_async (const Gio::SlotAsyncReady& slot, const Glib::RefPtr< Gio::Cancellable >& cancellable)
 Asynchronously request the clipboard contents converted to a Gdk::Pixbuf. More...

 
void read_texture_async (const Gio::SlotAsyncReady& slot)
 A read_texture_async() convenience overload. More...

 
Glib::RefPtr< Textureread_texture_finish (const Glib::RefPtr< Gio::AsyncResult >& result)
 Finishes an asynchronous clipboard read started with read_texture_async(). More...

 
void read_text_async (const Gio::SlotAsyncReady& slot, const Glib::RefPtr< Gio::Cancellable >& cancellable)
 Asynchronously request the clipboard contents converted to a string. More...

 
void read_text_async (const Gio::SlotAsyncReady& slot)
 A read_text_async() convenience overload. More...

 
Glib::ustring read_text_finish (const Glib::RefPtr< Gio::AsyncResult >& result)
 Finishes an asynchronous clipboard read started with read_text_async(). More...

 
bool set_content (const Glib::RefPtr< const ContentProvider >& provider)
 Sets a new content provider on clipboard. More...

 
bool unset_content ()
 Clears the clipboard. More...

 
void set_text (const Glib::ustring& text)
 Puts the given text into the clipboard. More...

 
void set_texture (const Glib::RefPtr< const Texture >& texture)
 Puts the given texture into the clipboard. More...

 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Display > > property_display () const
 The Gdk::Display that the clipboard belongs to. More...

 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ContentFormats > > property_formats () const
 The possible formats that the clipboard can provide its data in. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_local () const
 true if the contents of the clipboard are owned by this process. More...

 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ContentProvider > > property_content () const
 The Gdk::ContentProvider or nullptr if the clipboard is empty or contents are provided otherwise. More...

 
Glib::SignalProxy< void()> signal_changed ()
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
void * get_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
void * steal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
PropertyType get_property (const Glib::ustring &property_name) const
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src) noexcept
 
 ~trackable ()
 
void add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src) noexcept
 
void remove_destroy_notify_callback (notifiable *data) const
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...

 

Related Functions

(Note that these are not member functions.)

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

 

Additional Inherited Members

- Public Types inherited from Glib::Object
typedef void(*)(gpointer data DestroyNotify)
 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 
- Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify func_destroy_notify
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Detailed Description

Share data between applications for Copy-and-Paste.

The Gdk::Clipboard object represents a clipboard of data shared between different applications or between different parts of the same application.

To get a Clipboard object, use Gdk::Display::get_clipboard() or Gdk::Display::get_primary_clipboard(). You can find out about the data that is currently available in a clipboard using get_formats().

To make text or image data available in a clipboard, use set_text() or set_texture(). For other data, you can use set_content(), which takes a Gdk::ContentProvider object.

To read textual or image data from a clipboard, use read_text_async() or read_texture_async(). For other data, use read_async(), which provides a Gio::InputStream object.

See also
Gdk::ContentProvider, Gdk::ContentFormats
Since gtkmm 3.94:

Constructor & Destructor Documentation

Gdk::Clipboard::Clipboard ( Clipboard&&  src)
noexcept
Gdk::Clipboard::~Clipboard ( )
overridenoexcept

Member Function Documentation

Glib::RefPtr<ContentProvider> Gdk::Clipboard::get_content ( )

Returns the Gdk::ContentProvider currently set on clipboard.

If the clipboard is empty or its contents are not owned by the current process, nullptr will be returned.

Returns
The content of a clipboard or nullptr if the clipboard does not maintain any content.
Glib::RefPtr<const ContentProvider> Gdk::Clipboard::get_content ( ) const

Returns the Gdk::ContentProvider currently set on clipboard.

If the clipboard is empty or its contents are not owned by the current process, nullptr will be returned.

Returns
The content of a clipboard or nullptr if the clipboard does not maintain any content.
Glib::RefPtr<Display> Gdk::Clipboard::get_display ( )

Gets the Gdk::Display that the clipboard was created for.

Returns
A Gdk::Display.
Glib::RefPtr<const Display> Gdk::Clipboard::get_display ( ) const

Gets the Gdk::Display that the clipboard was created for.

Returns
A Gdk::Display.
Glib::RefPtr<ContentFormats> Gdk::Clipboard::get_formats ( )

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

Returns
The formats of the clipboard.
Glib::RefPtr<const ContentFormats> Gdk::Clipboard::get_formats ( ) const

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

Returns
The formats of the clipboard.
static GType Gdk::Clipboard::get_type ( )
static

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

GdkClipboard* Gdk::Clipboard::gobj ( )
inline

Provides access to the underlying C GObject.

const GdkClipboard* Gdk::Clipboard::gobj ( ) const
inline

Provides access to the underlying C GObject.

GdkClipboard* Gdk::Clipboard::gobj_copy ( )

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

bool Gdk::Clipboard::is_local ( ) const

Returns if the clipboard is local.

A clipboard is considered local if it was last claimed by the running application.

Note that get_content() may return nullptr even on a local clipboard. In this case the clipboard is empty.

Returns
true if the clipboard is local.
Clipboard& Gdk::Clipboard::operator= ( Clipboard&&  src)
noexcept
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<ContentProvider> > Gdk::Clipboard::property_content ( ) const

The Gdk::ContentProvider or nullptr if the clipboard is empty or contents are provided otherwise.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Display> > Gdk::Clipboard::property_display ( ) const

The Gdk::Display that the clipboard belongs to.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<ContentFormats> > Gdk::Clipboard::property_formats ( ) const

The possible formats that the clipboard 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.
Glib::PropertyProxy_ReadOnly< bool > Gdk::Clipboard::property_local ( ) const

true if the contents of the clipboard are owned by this process.

Default value: true

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.
void Gdk::Clipboard::read_async ( const std::vector< Glib::ustring > &  mime_types,
int  io_priority,
const Gio::SlotAsyncReady &  slot,
const Glib::RefPtr< Gio::Cancellable > &  cancellable 
)

Asynchronously requests an input stream to read the clipboard's contents from.

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

The clipboard will choose the most suitable mime type from the given list to fulfill the request, preferring the ones listed first.

Parameters
mime_typesA nullptr-terminated array of mime types to choose from.
io_priorityThe [I/O priority][io-priority] of the request.
cancellableOptional Gio::Cancellable object, nullptr to ignore.
slotCallback to call when the request is satisfied.
void Gdk::Clipboard::read_async ( const std::vector< Glib::ustring > &  mime_types,
int  io_priority,
const Gio::SlotAsyncReady &  slot 
)

A read_async() convenience overload.

Glib::RefPtr<Gio::InputStream> Gdk::Clipboard::read_finish ( const Glib::RefPtr< Gio::AsyncResult > &  result,
Glib::ustring out_mime_type 
)

Finishes an asynchronous clipboard read started with read_async().

Parameters
resultA AsyncResult.
out_mime_typePointer to store the chosen mime type in or nullptr.
Returns
A Gio::InputStream or nullptr on error.
Exceptions
Glib::Error
void Gdk::Clipboard::read_text_async ( const Gio::SlotAsyncReady &  slot,
const Glib::RefPtr< Gio::Cancellable > &  cancellable 
)

Asynchronously request the clipboard contents converted to a string.

When the operation is finished slot will be called. You can then call read_text_finish() to get the result.

This is a simple wrapper around read_value_async(). Use that function or read_async() directly if you need more control over the operation.

Parameters
cancellableOptional Gio::Cancellable object, nullptr to ignore.
slotCallback to call when the request is satisfied.
void Gdk::Clipboard::read_text_async ( const Gio::SlotAsyncReady &  slot)

A read_text_async() convenience overload.

Glib::ustring Gdk::Clipboard::read_text_finish ( const Glib::RefPtr< Gio::AsyncResult > &  result)

Finishes an asynchronous clipboard read started with read_text_async().

Parameters
resultA AsyncResult.
Returns
A new string or nullptr on error.
Exceptions
Glib::Error
void Gdk::Clipboard::read_texture_async ( const Gio::SlotAsyncReady &  slot,
const Glib::RefPtr< Gio::Cancellable > &  cancellable 
)

Asynchronously request the clipboard contents converted to a Gdk::Pixbuf.

When the operation is finished slot will be called. You can then call read_texture_finish() to get the result.

This is a simple wrapper around read_value_async(). Use that function or read_async() directly if you need more control over the operation.

Parameters
cancellableOptional Gio::Cancellable object, nullptr to ignore.
slotCallback to call when the request is satisfied.
void Gdk::Clipboard::read_texture_async ( const Gio::SlotAsyncReady &  slot)

A read_texture_async() convenience overload.

Glib::RefPtr<Texture> Gdk::Clipboard::read_texture_finish ( const Glib::RefPtr< Gio::AsyncResult > &  result)

Finishes an asynchronous clipboard read started with read_texture_async().

Parameters
resultA AsyncResult.
Returns
A new Gdk::Texture or nullptr on error.
Exceptions
Glib::Error
bool Gdk::Clipboard::set_content ( const Glib::RefPtr< const ContentProvider >&  provider)

Sets a new content provider on clipboard.

The clipboard will claim the Gdk::Display's resources and advertise these new contents to other applications.

In the rare case of a failure, this function will return false. The clipboard will then continue reporting its old contents and ignore provider.

If the contents are read by either an external application or the clipboard's read functions, clipboard will select the best format to transfer the contents and then request that format from provider.

Parameters
providerThe new contents of clipboard or nullptr to clear the clipboard.
Returns
true if setting the clipboard succeeded.
void Gdk::Clipboard::set_text ( const Glib::ustring text)

Puts the given text into the clipboard.

Parameters
textText to put into the clipboard.
void Gdk::Clipboard::set_texture ( const Glib::RefPtr< const Texture >&  texture)

Puts the given texture into the clipboard.

Parameters
textureA Gdk::Texture to put into the clipboard.
Glib::SignalProxy<void()> Gdk::Clipboard::signal_changed ( )
Slot Prototype:
void on_my_changed()

Flags: Run Last

The signal_changed() signal is emitted when the clipboard changes ownership.

bool Gdk::Clipboard::unset_content ( )

Clears the clipboard.

In the rare case of a failure, this function will return false. The clipboard will then continue reporting its old contents.

Returns
true if unsetting the clipboard succeeded.

Friends And Related Function Documentation

Glib::RefPtr< Gdk::Clipboard > wrap ( GdkClipboard *  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.