Simple text copy-paste functionality is provided for free by widgets such as
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.
You can get a clipboard instance with
Your application doesn't need to wait for clipboard operations, particularly
between the time when the user chooses Copy and then later chooses Paste. Many
Gdk::Clipboard methods take
which specify callback methods. When
Gdk::Clipboard is ready,
it will call these methods, providing the requested data.
Different applications contain different types of data, and they might make that data available in
a variety of formats. gtkmm calls these data types
For instance, gedit can supply and receive the
text/plain mime type,
so you can paste data into gedit from any application that supplies that format.
Or two different image editing applications might supply and receive a variety of image formats.
As long as one application can receive one of the formats that the other supplies
then you will be able to copy data from one to the other.
Clipboard data can be in a variety of binary formats. This chapter, and the examples, assume that the data is 8-bit text. This would allow us to use an XML format for the clipboard data. However this would probably not be appropriate for binary data such as images.
The Drag and Drop API uses the same mechanism. You should probably use the same data formats for both Clipboard and Drag and Drop operations.