]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_taskbar.i
Update ReST docs
[wxWidgets.git] / wxPython / src / _taskbar.i
index a43322bb81d204f34efd9eb2a26194d0df2be15c..9ae6d122506717ea14e36475c0d18a2f4aca5ac6 100644 (file)
@@ -58,64 +58,61 @@ enum {
 
 
 #else
 
 
 #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
 %}
 
 
 
 #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 would be to turn CreatePopupMenu
-// into an event...
-
-MustHaveApp(wxTaskBarIcon);
+MustHaveApp(wxPyTaskBarIcon);
 
 
-class wxTaskBarIcon : public wxEvtHandler
+%rename(TaskBarIcon) wxPyTaskBarIcon;
+class wxPyTaskBarIcon : public wxEvtHandler
 {
 public:
 {
 public:
-    wxTaskBarIcon();
-    ~wxTaskBarIcon();
+    %pythonAppend wxPyTaskBarIcon   "self._setCallbackInfo(self, TaskBarIcon, 0)"
+
+    wxPyTaskBarIcon();
+    ~wxPyTaskBarIcon();
+
+    void _setCallbackInfo(PyObject* self, PyObject* _class, int incref);
 
 
+    %pythonPrepend Destroy "args[0].this.own(False)";
     %extend {
         void Destroy() {
     %extend {
         void Destroy() {
-        #ifndef __WXMAC__
             self->RemoveIcon();
             self->RemoveIcon();
-        #endif
+            delete self;
         }
     }
 
         }
     }