diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-04-22 13:55:23 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-04-22 13:55:23 (GMT) |
commit | 8c46ce9addf8c30cce1e3a3f3814789160a430c4 (patch) | |
tree | e0a104f07fba833b9c2cd3fb2f048a9707d8ffcb /Mac/Modules | |
parent | f776dee6dd3d11f084071f52200838aeed0f4613 (diff) | |
download | cpython-8c46ce9addf8c30cce1e3a3f3814789160a430c4.zip cpython-8c46ce9addf8c30cce1e3a3f3814789160a430c4.tar.gz cpython-8c46ce9addf8c30cce1e3a3f3814789160a430c4.tar.bz2 |
Allow setting the auto dispose flag on window objects.
Diffstat (limited to 'Mac/Modules')
-rw-r--r-- | Mac/Modules/win/_Winmodule.c | 26 | ||||
-rw-r--r-- | Mac/Modules/win/winedit.py | 19 |
2 files changed, 42 insertions, 3 deletions
diff --git a/Mac/Modules/win/_Winmodule.c b/Mac/Modules/win/_Winmodule.c index 258845d..d1b3ada 100644 --- a/Mac/Modules/win/_Winmodule.c +++ b/Mac/Modules/win/_Winmodule.c @@ -14,9 +14,9 @@ /* 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) @@ -2300,6 +2300,24 @@ static PyObject *WinObj_ShowWindow(WindowObject *_self, PyObject *_args) 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)")}, @@ -2540,6 +2558,8 @@ static PyMethodDef WinObj_methods[] = { 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} }; diff --git a/Mac/Modules/win/winedit.py b/Mac/Modules/win/winedit.py index d2551af..d79356f 100644 --- a/Mac/Modules/win/winedit.py +++ b/Mac/Modules/win/winedit.py @@ -48,5 +48,24 @@ f = Method(void, 'ShowWindow', ) 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) |