- wxDataObject *data_object = (wxDataObject *)node->Data();
-
- if (data_object->m_formatAtom != selection_data->target)
- {
- node = node->Next();
- break;
- }
-
- switch (data_object->GetFormat())
- {
- case wxDF_TEXT:
- {
- wxTextDataObject *text_object = (wxTextDataObject*) data_object;
-
- wxString text = text_object->GetText();
-
- char *s = WXSTRINGCAST text;
- int len = (int) text.Length();
-
- gtk_selection_data_set(
- selection_data,
- GDK_SELECTION_TYPE_STRING,
- 8*sizeof(gchar),
- (unsigned char*) s,
- len );
-
- break;
- }
-
- case wxDF_BITMAP:
- {
- // wxBitmapDataObject *private_object = (wxBitmapDataObject*) data_object;
-
- // how do we do that ?
-
- break;
- }
-
- case wxDF_PRIVATE:
- {
- wxPrivateDataObject *private_object = (wxPrivateDataObject*) data_object;
-
- if (private_object->GetDataSize() == 0) return;
-
- gtk_selection_data_set(
- selection_data,
- GDK_SELECTION_TYPE_STRING,
- 8*sizeof(gchar),
- (unsigned char*) private_object->GetData(),
- (int) private_object->GetDataSize() );
- }
-
- default:
- break;
- }
-
- node = node->Next();
+ guint timestamp = GPOINTER_TO_UINT (signal_data);
+ gtk_selection_data_set(selection_data,
+ GDK_SELECTION_TYPE_INTEGER,
+ 32,
+ (guchar*)&(timestamp),
+ sizeof(timestamp));
+ wxLogTrace(TRACE_CLIPBOARD,
+ _T("Clipboard TIMESTAMP requested, returning timestamp=%u"),
+ timestamp);
+ return;
+ }
+
+ wxDataFormat format( selection_data->target );
+
+#ifdef __WXDEBUG__
+ wxLogTrace(TRACE_CLIPBOARD,
+ _T("clipboard data in format %s, GtkSelectionData is target=%s type=%s selection=%s timestamp=%u"),
+ format.GetId().c_str(),
+ wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->target))).c_str(),
+ wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->type))).c_str(),
+ wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->selection))).c_str(),
+ GPOINTER_TO_UINT( signal_data )
+ );
+#endif
+
+ if (!data->IsSupportedFormat( format )) return;
+
+ int size = data->GetDataSize( format );
+
+ if (size == 0) return;
+
+ wxCharBuffer buf(size);
+
+ // text data must be returned in UTF8 if format is wxDF_UNICODETEXT
+ data->GetDataHere( format, buf.data() );
+
+ // use UTF8_STRING format if requested in Unicode build but just plain
+ // STRING one in ANSI or if explicitly asked in Unicode
+#if wxUSE_UNICODE
+ if (format == wxDataFormat(wxDF_UNICODETEXT))
+ {
+ gtk_selection_data_set_text(
+ selection_data,
+ (const gchar*)buf.data(),
+ size );