+ Clear();
+
+ if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
+}
+
+void wxClipboard::Clear()
+{
+ if (m_dataBroker)
+ {
+ /* As we have data we also own the clipboard. Once we no longer own
+ it, clear_selection is called which will set m_data to zero */
+
+ if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window)
+ {
+ gtk_selection_owner_set( (GtkWidget*) NULL, g_clipboardAtom, GDK_CURRENT_TIME );
+ }
+
+ if (gdk_selection_owner_get( GDK_SELECTION_PRIMARY ) == m_clipboardWidget->window)
+ {
+ gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
+ }
+
+ if (m_dataBroker)
+ {
+ delete m_dataBroker;
+ m_dataBroker = (wxDataBroker*) NULL;
+ }
+ }
+
+ m_targetRequested = 0;
+
+ m_formatSupported = FALSE;
+}
+
+bool wxClipboard::Open()
+{
+ wxCHECK_MSG( !m_open, FALSE, "clipboard already open" );
+
+ m_open = TRUE;
+
+ return TRUE;
+}
+
+bool wxClipboard::SetData( wxDataBroker *data )
+{
+ wxCHECK_MSG( data, FALSE, "data is invalid" );
+
+ Clear();
+
+ m_dataBroker = data;
+
+ if (!m_dataBroker) return FALSE;
+
+ wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
+
+ wxNode *node = m_dataBroker->m_dataObjects.First();
+ while (node)
+ {
+ wxDataObject *dobj = (wxDataObject*)node->Data();
+
+ GdkAtom format = dobj->GetFormat().GetAtom();
+
+ if (format != (GdkAtom) 0)
+ {
+ /* This should happen automatically */
+
+ m_ownsClipboard = FALSE;
+ m_ownsPrimarySelection = FALSE;
+
+ /* Add handlers if someone requests data */
+
+ gtk_selection_add_handler( m_clipboardWidget,
+ g_clipboardAtom,
+ format,
+ selection_handler,
+ (gpointer) NULL );
+
+ gtk_selection_add_handler( m_clipboardWidget,
+ GDK_SELECTION_PRIMARY,
+ format,
+ selection_handler,
+ (gpointer) NULL );
+
+ /* Tell the world we offer clipboard data */
+
+ if (!gtk_selection_owner_set( m_clipboardWidget,
+ g_clipboardAtom,
+ GDK_CURRENT_TIME ))
+ {
+ return FALSE;
+ }
+ m_ownsClipboard = TRUE;
+
+ if (!gtk_selection_owner_set( m_clipboardWidget,
+ GDK_SELECTION_PRIMARY,
+ GDK_CURRENT_TIME ))
+ {
+ return FALSE;
+ }
+ m_ownsPrimarySelection = TRUE;
+ }
+
+ node = node->Next();
+ }
+
+ return TRUE;
+}
+
+void wxClipboard::Close()
+{
+ wxCHECK_RET( m_open, "clipboard not open" );
+
+ m_open = FALSE;