X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d07d2bc9d05408c58b76c53a0a291915b88e5064..2a783b2daaae6f06928e7095ebbc4fc039583907:/wxPython/src/_clipbrd.i diff --git a/wxPython/src/_clipbrd.i b/wxPython/src/_clipbrd.i index 89c143f3b4..b11ac31e96 100644 --- a/wxPython/src/_clipbrd.i +++ b/wxPython/src/_clipbrd.i @@ -65,7 +65,7 @@ True on success.", ""); - %apply SWIGTYPE *DISOWN { wxDataObject *data }; + %disownarg( wxDataObject *data ); DocDeclStr( virtual bool , AddData( wxDataObject *data ), @@ -84,8 +84,8 @@ do not delete the data explicitly. :see: `wx.DataObject`", ""); - - %clear wxDataObject *data; + %cleardisown( wxDataObject *data ); + DocDeclStr( virtual bool , IsSupported( const wxDataFormat& format ), @@ -113,17 +113,47 @@ exit. Returns False if the operation is unsuccesful for any reason.", ""); DocDeclStr( - virtual void , UsePrimarySelection( bool primary = True ), + virtual void , UsePrimarySelection( bool primary = true ), "On platforms supporting it (the X11 based platforms), selects the so called PRIMARY SELECTION as the clipboard as opposed to the normal clipboard, if primary is True.", ""); -}; -%immutable; -wxClipboard* const wxTheClipboard; -%mutable; + DocDeclStr( + static wxClipboard *, Get(), + "Returns global instance (wxTheClipboard) of the object.", ""); + + %property(Data, GetData, SetData, doc="See `GetData` and `SetData`"); + +}; + +// Previously we just declared wxTheClipboard as a global, but in C++ +// is has been changed to be a macro for wxClipboard::Get, but the +// swig generated code will try to evaluate it when it assigns to the +// swig wrapper var so this causes Get to be called too early on +// wxGTK. So instead we'll create a Python class that can delay the +// Get until it is really needed, which is similar in effect to what +// is really happening on the C++ side too. +%pythoncode { + class _wxPyDelayedInitWrapper(object): + def __init__(self, initfunc, *args, **kwargs): + self._initfunc = initfunc + self._args = args + self._kwargs = kwargs + self._instance = None + def _checkInstance(self): + if self._instance is None: + if wx.GetApp(): + self._instance = self._initfunc(*self._args, **self._kwargs) + def __getattr__(self, name): + self._checkInstance() + return getattr(self._instance, name) + def __repr__(self): + self._checkInstance() + return repr(self._instance) + TheClipboard = _wxPyDelayedInitWrapper(Clipboard.Get) +} //---------------------------------------------------------------------------