- gint len = data_object->GetDataSize();
- guchar *bin_data = (guchar*) malloc( len );
- data_object->GetDataHere( (void*)bin_data );
-
- if (selection_data->target == GDK_TARGET_STRING)
- {
- gtk_selection_data_set(
- selection_data, GDK_SELECTION_TYPE_STRING, 8*sizeof(gchar), bin_data, len );
- }
-/*
- else if (selection_data->target == g_textAtom)
- {
- gtk_selection_data_set(
- selection_data, g_textAtom, 8*sizeof(gchar), bin_data, len );
- }
-*/
- free( bin_data );
+ wxNode *node = wxTheClipboard->m_dataBroker->m_dataObjects.First();
+
+ while (node)
+ {
+ wxDataObject *data_object = (wxDataObject *)node->Data();
+
+ if (data_object->GetFormat().GetAtom() != selection_data->target)
+ {
+ node = node->Next();
+ break;
+ }
+
+ switch (data_object->GetFormat().GetType())
+ {
+ case wxDF_TEXT:
+ {
+ wxTextDataObject *text_object = (wxTextDataObject*) data_object;
+
+ wxString text = text_object->GetText();
+
+#if wxUSE_UNICODE
+ const wxWX2MBbuf s = text.mbc_str();
+ int len = strlen(s);
+#else // more efficient in non-Unicode
+ const char *s = text.c_str();
+ int len = (int) text.Length();
+#endif
+
+ gtk_selection_data_set(
+ selection_data,
+ GDK_SELECTION_TYPE_STRING,
+ 8*sizeof(gchar),
+ (unsigned char*) (const 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->GetSize() == 0) return;
+
+ gtk_selection_data_set(
+ selection_data,
+ GDK_SELECTION_TYPE_STRING,
+ 8*sizeof(gchar),
+ (unsigned char*) private_object->GetData(),
+ (int) private_object->GetSize() );
+ }
+
+ default:
+ break;
+ }
+
+ node = node->Next();
+ }