]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_taskbar.i
This workaround is no longer needed because of fix in
[wxWidgets.git] / wxPython / src / _taskbar.i
index 24a1d4abd93fc952ae328f1ada3c1fc938ee9ea6..b5fe68cbd36a133b4b6fd98b53b2dcf5054d186b 100644 (file)
 class wxTaskBarIcon : public wxEvtHandler
 {
 public:
-    wxTaskBarIcon()  { PyErr_SetNone(PyExc_NotImplementedError); }
+    wxTaskBarIcon()  { wxPyRaiseNotImplemented(); }
 };
+
 
 class wxTaskBarIconEvent : public wxEvent
 {
 public:
     wxTaskBarIconEvent(wxEventType, wxTaskBarIcon *)
-        { PyErr_SetNone(PyExc_NotImplementedError); }
+        { wxPyRaiseNotImplemented(); }
     virtual wxEvent* Clone() const { return NULL; }
 };
 
@@ -50,25 +50,78 @@ enum {
     wxEVT_TASKBAR_LEFT_DCLICK = 0,
     wxEVT_TASKBAR_RIGHT_DCLICK = 0,
 };
+
+
+#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);
+
 #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);
 
 class wxTaskBarIcon : public wxEvtHandler
 {
 public:
     wxTaskBarIcon();
     ~wxTaskBarIcon();
-   
+
+    %extend {
+        void Destroy() {
+        #ifndef __WXMAC__
+            self->RemoveIcon();
+        #endif
+        }
+    }
 
 #ifndef __WXMAC__
     bool IsOk() const;
+    %pythoncode { def __nonzero__(self): return self.IsOk() }
+
     bool IsIconInstalled() const;
 
     bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxPyEmptyString);
-    bool RemoveIcon(void);
+    bool RemoveIcon();
     bool PopupMenu(wxMenu *menu);
 #endif
 };
@@ -100,6 +153,6 @@ EVT_TASKBAR_RIGHT_DOWN = wx.PyEventBinder (   wxEVT_TASKBAR_RIGHT_DOWN )
 EVT_TASKBAR_RIGHT_UP = wx.PyEventBinder (     wxEVT_TASKBAR_RIGHT_UP )
 EVT_TASKBAR_LEFT_DCLICK = wx.PyEventBinder (  wxEVT_TASKBAR_LEFT_DCLICK )
 EVT_TASKBAR_RIGHT_DCLICK = wx.PyEventBinder ( wxEVT_TASKBAR_RIGHT_DCLICK )
-}   
+}
 
 //---------------------------------------------------------------------------