Discovering the available targets
To find out what targets are currently available on the clipboard for pasting, call the request_methods() method, specifying a method to be called with the information. For instance:
refClipboard->request_targets( SigC::slot(*this, &ExampleWindow::on_clipboard_received_targets) );
In your callback, compare the list of available targets with those that your application supports for pasting. You could enable or disable a Paste menu item, depending on whether pasting is currently possible. For instance:
void ExampleWindow::on_clipboard_received_targets(const Gtk::SelectionData& selection_data)
{
bool bPasteIsPossible = false;
//Get the list of available clipboard targets:
typedef std::list<Glib::ustring> type_listTargets;
type_listTargets targets = selection_data.get_targets();
//and see if one is suitable:
for(type_listTargets::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
{
if(*iter == "example_custom_target")
bPasteIsPossible = true;
}
//Do something, depending on whether bPasteIsPossible is true.
}