Chapter 16. The Clipboard

Table of Contents

Targets
Copy
Paste
Discovering the available targets
Examples
Simple
Ideal

Simple text copy-paste functionality is provided for free by widgets such as Gtk::Entry and Gtk::TextView, but you might need special code to deal with your own data formats. For instance, a drawing program would need special code to allow copy and paste within a view, or between documents.

Gtk::Clipboard is a singleton. You can get the one and only instance with Gtk::Clipboard::get().

So your application doesn't need to wait for clipboard operations, particularly between the time when the user chooses Copy and then later chooses Paste, most Gtk::Clipboard methods take SigC::Slots which specify callback methods. When Gtk::Clipboard is ready, it will call these methods, either providing the requested data, or asking for data.


Google

Reference

Targets

Different applications contain different types of data, and they might make that data available in a variety of formats. gtkmm calls these data types targets.

For instance, gedit can supply and receive the "UTF8_STRING" target, so you can paste data into gedit from any application that supplies that target. Or two different image editing applications might supply and receive a variety of image formats as targets. As long as one application can receive one of the targets that the other supplies then you will be able to copy data from one to the other.