X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b8400a3a9dd9ae5cc405d568a7b20f85cc17c480..3bdec81e147765682eda34adb84288a5eb9ab6c2:/wxPython/src/_taskbar.i diff --git a/wxPython/src/_taskbar.i b/wxPython/src/_taskbar.i index b5fe68cbd3..f0f110698f 100644 --- a/wxPython/src/_taskbar.i +++ b/wxPython/src/_taskbar.i @@ -23,8 +23,8 @@ %{ -#ifdef __WXMAC__ -// implement dummy classes and such for wxMac +#ifndef wxHAS_TASK_BAR_ICON +// implement dummy classes for platforms that don't have it class wxTaskBarIcon : public wxEvtHandler { @@ -39,6 +39,11 @@ public: wxTaskBarIconEvent(wxEventType, wxTaskBarIcon *) { wxPyRaiseNotImplemented(); } virtual wxEvent* Clone() const { return NULL; } + bool IsOk() const { return false; } + bool IsIconInstalled() const { return false; } + bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxPyEmptyString) { return false; } + bool RemoveIcon() { return false; } + bool PopupMenu(wxMenu *menu) { return false; } }; enum { @@ -53,68 +58,64 @@ enum { #else -// // Otherwise make a class that can virtualize CreatePopupMenu -// class wxPyTaskBarIcon : public wxTaskBarIcon -// { -// DECLARE_ABSTRACT_CLASS(wxPyTaskBarIcon); -// public: -// wxPyTaskBarIcon() : wxTaskBarIcon() -// {} - -// wxMenu* CreatePopupMenu() { -// wxMenu *rval = NULL; -// bool found; -// bool blocked = wxPyBeginBlockThreads(); -// if ((found = wxPyCBH_findCallback(m_myInst, "CreatePopupMenu"))) { -// PyObject* ro; -// wxMenu* ptr; -// ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); -// if (ro) { -// if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxMenu"))) -// rval = ptr; -// Py_DECREF(ro); -// } -// } -// wxPyEndBlockThreads(blocked); -// if (! found) -// rval = wxTaskBarIcon::CreatePopupMenu(); -// return rval; -// } - -// PYPRIVATE; -// }; - -// IMPLEMENT_ABSTRACT_CLASS(wxPyTaskBarIcon, wxTaskBarIcon); +// Otherwise make a class that can virtualize CreatePopupMenu +class wxPyTaskBarIcon : public wxTaskBarIcon +{ + DECLARE_ABSTRACT_CLASS(wxPyTaskBarIcon) +public: + wxPyTaskBarIcon() : wxTaskBarIcon() + {} + + wxMenu* CreatePopupMenu() { + wxMenu *rval = NULL; + bool found; + wxPyBlock_t blocked = wxPyBeginBlockThreads(); + if ((found = wxPyCBH_findCallback(m_myInst, "CreatePopupMenu"))) { + PyObject* ro; + wxMenu* ptr; + ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); + if (ro) { + if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxMenu"))) + rval = ptr; + Py_DECREF(ro); + } + } + wxPyEndBlockThreads(blocked); + if (! found) + rval = wxTaskBarIcon::CreatePopupMenu(); + return rval; + } + + PYPRIVATE; +}; + +IMPLEMENT_ABSTRACT_CLASS(wxPyTaskBarIcon, wxTaskBarIcon); #endif %} -// NOTE: TaskbarIcon has not yet been changed to be able to virtualize the -// CreatePopupMenu method because it is just before a release and I worry that -// there will be a problem in this case with it holding a reference to itself -// (since it depends on the dtor for cleanup.) Better safe than sorry! -// -// Perhaps a better mechanism for wxPython woudl be to turn CreatePopupMenu -// into an event... - -MustHaveApp(wxTaskBarIcon); +MustHaveApp(wxPyTaskBarIcon); -class wxTaskBarIcon : public wxEvtHandler +%rename(TaskBarIcon) wxPyTaskBarIcon; +class wxPyTaskBarIcon : public wxEvtHandler { public: - wxTaskBarIcon(); - ~wxTaskBarIcon(); + %pythonAppend wxPyTaskBarIcon setCallbackInfo(TaskBarIcon) + wxPyTaskBarIcon(); + ~wxPyTaskBarIcon(); + + void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=0); + + %pythonPrepend Destroy "args[0].this.own(False)"; %extend { void Destroy() { - #ifndef __WXMAC__ self->RemoveIcon(); - #endif + delete self; } } -#ifndef __WXMAC__ bool IsOk() const; %pythoncode { def __nonzero__(self): return self.IsOk() } @@ -123,7 +124,6 @@ public: bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxPyEmptyString); bool RemoveIcon(); bool PopupMenu(wxMenu *menu); -#endif };