+
+//-----------------------------------------------------------------------------
+// "selection_clear"
+//-----------------------------------------------------------------------------
+
+static gint
+selection_clear( GtkWidget *widget, GdkEventSelection *event )
+{
+ /* The clipboard is no longer in our hands. We can delete the
+ * clipboard data. I hope I got that one right... */
+
+ if (!wxTheClipboard) return TRUE;
+
+ wxTheClipboard->SetData( (wxDataObject*) NULL );
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// selection handler for supplying data
+//-----------------------------------------------------------------------------
+
+static void
+selection_handler( GtkWidget *WXUNUSED(widget), GtkSelectionData *selection_data, gpointer WXUNUSED(data) )
+{
+ if (!wxTheClipboard) return;
+
+ wxDataObject *data_object = wxTheClipboard->m_data;
+
+ if (!data_object) return;
+
+ if (data_object->GetDataSize() == 0) return;
+
+ gint len = data_object->GetDataSize();
+ guchar *bin_data = (guchar*) malloc( len );
+ data_object->GetDataHere( (void*)bin_data );
+
+ if (selection_data->target == GDK_SELECTION_TYPE_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 );
+}