+
+bool wxClipboard::GetData( wxDataObject *data )
+{
+ wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
+
+ m_receivedData = data;
+
+ wxCHECK_MSG( m_receivedData, FALSE, "invalid data object" );
+
+ /* STEP ONE: check if there is such data in the clipboard */
+
+ m_targetRequested = data->GetFormat().GetAtom();
+
+ wxCHECK_MSG( m_targetRequested, FALSE, "invalid clipboard format" );
+
+ if (m_targetRequested == 0) return FALSE;
+
+ /* add handler for target (= format) query */
+
+ gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
+ "selection_received",
+ GTK_SIGNAL_FUNC( targets_selection_received ),
+ (gpointer) this );
+
+ m_formatSupported = FALSE;
+
+ /* perform query. this will set m_formatSupported to
+ * TRUE if m_targetRequested is supported */
+
+ gtk_selection_convert( m_clipboardWidget,
+ g_clipboardAtom,
+ g_targetsAtom,
+ GDK_CURRENT_TIME );
+
+ gtk_signal_disconnect_by_func( GTK_OBJECT(m_clipboardWidget),
+ GTK_SIGNAL_FUNC( targets_selection_received ),
+ (gpointer) this );
+
+ if (!m_formatSupported) return FALSE;
+
+ /* STEP TWO: get the data from the clipboard */
+
+ m_formatSupported = FALSE;
+
+ gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
+ "selection_received",
+ GTK_SIGNAL_FUNC( selection_received ),
+ (gpointer) this );
+
+ gtk_selection_convert( m_clipboardWidget,
+ g_clipboardAtom,
+ m_targetRequested,
+ GDK_CURRENT_TIME );
+
+ gtk_signal_disconnect_by_func( GTK_OBJECT(m_clipboardWidget),
+ GTK_SIGNAL_FUNC( selection_received ),
+ (gpointer) this );
+
+ /* this is a true error as we checked for the presence of such data before */
+
+ wxCHECK_MSG( m_formatSupported, FALSE, "error retrieving data from clipboard" );
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// wxClipboardModule
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule,wxModule)
+
+bool wxClipboardModule::OnInit()
+{
+ wxTheClipboard = new wxClipboard();
+
+ return TRUE;
+}
+
+void wxClipboardModule::OnExit()
+{
+ if (wxTheClipboard) delete wxTheClipboard;
+ wxTheClipboard = (wxClipboard*) NULL;
+}
+
+#endif
+
+ // wxUSE_CLIPBOARD
+