+void wxClipboard::GTKOnSelectionReceived(const GtkSelectionData& sel)
+{
+ wxCHECK_RET( m_receivedData, wxT("should be inside GetData()") );
+
+ const wxDataFormat format(gtk_selection_data_get_target(const_cast<GtkSelectionData*>(&sel)));
+ wxLogTrace(TRACE_CLIPBOARD, wxT("Received selection %s"),
+ format.GetId().c_str());
+
+ if ( !m_receivedData->IsSupportedFormat(format) )
+ return;
+
+ m_receivedData->SetData(format,
+ gtk_selection_data_get_length(const_cast<GtkSelectionData*>(&sel)),
+ gtk_selection_data_get_data(const_cast<GtkSelectionData*>(&sel)));
+ m_formatSupported = true;
+}
+
+//-----------------------------------------------------------------------------
+// asynchronous "selection_received" for targets
+//-----------------------------------------------------------------------------
+
+extern "C" {
+static void
+async_targets_selection_received( GtkWidget *WXUNUSED(widget),
+ GtkSelectionData *selection_data,
+ guint32 WXUNUSED(time),
+ wxClipboard *clipboard )
+{
+ if ( !clipboard ) // Assert?
+ return;
+
+ if (!clipboard->m_sink)
+ return;
+
+ wxClipboardEvent *event = new wxClipboardEvent(wxEVT_CLIPBOARD_CHANGED);
+ event->SetEventObject( clipboard );
+
+ int selection_data_length = 0;
+ if (selection_data)
+ selection_data_length = gtk_selection_data_get_length(selection_data);
+
+ if (selection_data_length <= 0)
+ {
+ clipboard->m_sink->QueueEvent( event );
+ clipboard->m_sink.Release();