/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
- PyErr_SetString(PyExc_NotImplementedError, \
- "Not available in this shared library/OS version"); \
- return NULL; \
+ PyErr_SetString(PyExc_NotImplementedError, \
+ "Not available in this shared library/OS version"); \
+ return NULL; \
}} while(0)
return _res;
}
+static PyObject *WinObj_AutoDispose(WindowObject *_self, PyObject *_args)
+{
+ PyObject *_res = NULL;
+
+ int onoff, old = 0;
+ if (!PyArg_ParseTuple(_args, "i", &onoff))
+ return NULL;
+ if ( _self->ob_freeit )
+ old = 1;
+ if ( onoff )
+ _self->ob_freeit = PyMac_AutoDisposeWindow;
+ else
+ _self->ob_freeit = NULL;
+ _res = Py_BuildValue("i", old);
+ return _res;
+
+}
+
static PyMethodDef WinObj_methods[] = {
{"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
PyDoc_STR("() -> (UInt32 outCount)")},
PyDoc_STR("(short hGlobal, short vGlobal, Boolean front) -> None")},
{"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
PyDoc_STR("() -> None")},
+ {"AutoDispose", (PyCFunction)WinObj_AutoDispose, 1,
+ PyDoc_STR("(int)->int. Automatically DisposeHandle the object on Python object cleanup")},
{NULL, NULL, 0}
};
)
methods.append(f)
+#
+# A method to set the auto-dispose flag
+#
+AutoDispose_body = """
+int onoff, old = 0;
+if (!PyArg_ParseTuple(_args, "i", &onoff))
+ return NULL;
+if ( _self->ob_freeit )
+ old = 1;
+if ( onoff )
+ _self->ob_freeit = PyMac_AutoDisposeWindow;
+else
+ _self->ob_freeit = NULL;
+_res = Py_BuildValue("i", old);
+return _res;
+"""
+f = ManualGenerator("AutoDispose", AutoDispose_body)
+f.docstring = lambda: "(int)->int. Automatically DisposeHandle the object on Python object cleanup"
+methods.append(f)