- switch (m_data->GetPreferredFormat())
- {
- case wxDF_TEXT:
- gtk_selection_add_handler( m_clipboardWidget,
- g_clipboardAtom,
- // g_textAtom,
- GDK_TARGET_STRING,
- selection_handler,
- NULL );
- break;
- default:
- break;
- }
+ if (data->GetFormat() == wxDF_PRIVATE)
+ {
+ wxPrivateDataObject* pd = (wxPrivateDataObject*) data;
+
+ wxCHECK_MSG( !pd->GetId().IsEmpty(), FALSE, "private clipboard format requires ID string" );
+
+ data->m_formatAtom = GetTargetAtom( data->GetFormat(), pd->GetId() );
+ }
+ else
+ {
+ data->m_formatAtom = GetTargetAtom( data->GetFormat() );
+ }
+
+ // This should happen automatically
+
+ m_ownsClipboard = FALSE;
+ m_ownsPrimarySelection = FALSE;
+
+ // Add handlers if someone requests data
+
+ gtk_selection_add_handler( m_clipboardWidget,
+ g_clipboardAtom,
+ data->m_formatAtom,
+ selection_handler,
+ NULL );
+
+ gtk_selection_add_handler( m_clipboardWidget,
+ GDK_SELECTION_PRIMARY,
+ data->m_formatAtom,
+ selection_handler,
+ 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;
+
+ return TRUE;