+public:
+ wxClipboardSync(wxClipboard& clipboard)
+ {
+ wxASSERT_MSG( !ms_clipboard, _T("reentrancy in clipboard code") );
+ ms_clipboard = &clipboard;
+ }
+
+ ~wxClipboardSync()
+ {
+ while ( ms_clipboard )
+ gtk_main_iteration();
+ }
+
+ // this method must be called by GTK+ callbacks to indicate that we got the
+ // result for our clipboard operation
+ static void OnDone(wxClipboard *clipboard)
+ {
+ wxASSERT_MSG( clipboard == ms_clipboard,
+ _T("got notification for alien clipboard") );
+
+ ms_clipboard = NULL;
+ }
+
+ // this method should be called if it's possible that no async clipboard
+ // operation is currently in progress (like it can be the case when the
+ // clipboard is cleared but not because we asked about it), it should only
+ // be called if such situation is expected -- otherwise call OnDone() which
+ // would assert in this case
+ static void OnDoneIfInProgress(wxClipboard *clipboard)
+ {
+ if ( ms_clipboard )
+ OnDone(clipboard);
+ }
+
+private:
+ static wxClipboard *ms_clipboard;
+
+ DECLARE_NO_COPY_CLASS(wxClipboardSync)