Klistra in
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));
}
Här är ett exempel på en återanropsmetod:
void ExampleWindow::on_clipboard_received(Glib::RefPtr<Gio::AsyncResult>& result)
{
auto text = get_clipboard()->read_text_finish(result);
//Do something with the pasted data.
}
Upptäcka de tillgängliga formaten
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.