+// ----------------------------------------------------------------------------
+// wxClipboard helper functions
+// ----------------------------------------------------------------------------
+
+GdkAtom wxClipboard::GTKGetClipboardAtom() const
+{
+ return m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY
+ : g_clipboardAtom;
+}
+
+void wxClipboard::GTKClearData(Kind kind)
+{
+ wxDataObject *&data = Data();
+ if ( data )
+ {
+ delete data;
+ data = NULL;
+ }
+}
+
+bool wxClipboard::SetSelectionOwner(bool set)
+{
+ bool rc = gtk_selection_owner_set
+ (
+ set ? m_clipboardWidget : NULL,
+ GTKGetClipboardAtom(),
+ (guint32)GDK_CURRENT_TIME
+ );
+
+ if ( !rc )
+ {
+ wxLogTrace(TRACE_CLIPBOARD, _T("Failed to %sset selection owner"),
+ set ? _T("") : _T("un"));
+ }
+
+ return rc;
+}
+
+void wxClipboard::AddSupportedTarget(GdkAtom atom)
+{
+ gtk_selection_add_target
+ (
+ m_clipboardWidget,
+ GTKGetClipboardAtom(),
+ atom,
+ 0 // info (same as client data) unused
+ );
+}
+
+bool wxClipboard::DoIsSupported(const wxDataFormat& format)
+{
+ wxCHECK_MSG( format, false, wxT("invalid clipboard format") );
+
+ wxLogTrace(TRACE_CLIPBOARD, wxT("Checking if format %s is available"),
+ format.GetId().c_str());
+
+ // these variables will be used by our GTKOnTargetReceived()
+ m_targetRequested = format;
+ m_formatSupported = false;
+
+ // block until m_formatSupported is set from targets_selection_received
+ // callback
+ {
+ wxClipboardSync sync(*this);
+
+ gtk_selection_convert( m_targetsWidget,
+ GTKGetClipboardAtom(),
+ g_targetsAtom,
+ (guint32) GDK_CURRENT_TIME );
+ }
+
+ return m_formatSupported;
+}
+
+// ----------------------------------------------------------------------------
+// wxClipboard public API implementation
+// ----------------------------------------------------------------------------
+