Paste

When the user asks to paste data from the Clipboard, you should request a specific format and provide a callback method which will be called with the actual data. For instance:

void ExampleWindow::on_button_paste()
{
  get_clipboard()->read_text_async(sigc::mem_fun(*this,
              &ExampleWindow::on_clipboard_received));
}

Here is an example callback method:

void ExampleWindow::on_clipboard_received(Glib::RefPtr<Gio::AsyncResult>& result)
{
  auto text = get_clipboard()->read_text_finish(result);
  //Do something with the pasted data.
}

18.3.1. Discovering the available formats

To find out what formats are currently available on the Clipboard for pasting, call the get_formats() method. Then call a Gdk::ContentFormats method to find out if a format that your application supports is available.