Fix transient refleaks in test_urllib2_localnet.
[python.git] / Mac / Modules / help / _Helpmodule.c
bloba6eccf34ff84c6a8d93fbc9cfdff7bf54a4398a0
2 /* ========================== Module _Help ========================== */
4 #include "Python.h"
6 #ifndef __LP64__
9 #include "pymactoolbox.h"
11 /* Macro to test whether a weak-loaded CFM function exists */
12 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
13 PyErr_SetString(PyExc_NotImplementedError, \
14 "Not available in this shared library/OS version"); \
15 return NULL; \
16 }} while(0)
19 #include <Carbon/Carbon.h>
21 static PyObject *Help_Error;
23 static PyObject *Help_HMGetHelpMenu(PyObject *_self, PyObject *_args)
25 PyObject *_res = NULL;
26 OSStatus _err;
27 MenuRef outHelpMenu;
28 MenuItemIndex outFirstCustomItemIndex;
29 if (!PyArg_ParseTuple(_args, ""))
30 return NULL;
31 _err = HMGetHelpMenu(&outHelpMenu,
32 &outFirstCustomItemIndex);
33 if (_err != noErr) return PyMac_Error(_err);
34 _res = Py_BuildValue("O&H",
35 MenuObj_New, outHelpMenu,
36 outFirstCustomItemIndex);
37 return _res;
40 static PyObject *Help_HMAreHelpTagsDisplayed(PyObject *_self, PyObject *_args)
42 PyObject *_res = NULL;
43 Boolean _rv;
44 if (!PyArg_ParseTuple(_args, ""))
45 return NULL;
46 _rv = HMAreHelpTagsDisplayed();
47 _res = Py_BuildValue("b",
48 _rv);
49 return _res;
52 static PyObject *Help_HMSetHelpTagsDisplayed(PyObject *_self, PyObject *_args)
54 PyObject *_res = NULL;
55 OSStatus _err;
56 Boolean inDisplayTags;
57 if (!PyArg_ParseTuple(_args, "b",
58 &inDisplayTags))
59 return NULL;
60 _err = HMSetHelpTagsDisplayed(inDisplayTags);
61 if (_err != noErr) return PyMac_Error(_err);
62 Py_INCREF(Py_None);
63 _res = Py_None;
64 return _res;
67 static PyObject *Help_HMSetTagDelay(PyObject *_self, PyObject *_args)
69 PyObject *_res = NULL;
70 OSStatus _err;
71 Duration inDelay;
72 if (!PyArg_ParseTuple(_args, "l",
73 &inDelay))
74 return NULL;
75 _err = HMSetTagDelay(inDelay);
76 if (_err != noErr) return PyMac_Error(_err);
77 Py_INCREF(Py_None);
78 _res = Py_None;
79 return _res;
82 static PyObject *Help_HMGetTagDelay(PyObject *_self, PyObject *_args)
84 PyObject *_res = NULL;
85 OSStatus _err;
86 Duration outDelay;
87 if (!PyArg_ParseTuple(_args, ""))
88 return NULL;
89 _err = HMGetTagDelay(&outDelay);
90 if (_err != noErr) return PyMac_Error(_err);
91 _res = Py_BuildValue("l",
92 outDelay);
93 return _res;
96 static PyObject *Help_HMSetMenuHelpFromBalloonRsrc(PyObject *_self, PyObject *_args)
98 PyObject *_res = NULL;
99 OSStatus _err;
100 MenuRef inMenu;
101 SInt16 inHmnuRsrcID;
102 if (!PyArg_ParseTuple(_args, "O&h",
103 MenuObj_Convert, &inMenu,
104 &inHmnuRsrcID))
105 return NULL;
106 _err = HMSetMenuHelpFromBalloonRsrc(inMenu,
107 inHmnuRsrcID);
108 if (_err != noErr) return PyMac_Error(_err);
109 Py_INCREF(Py_None);
110 _res = Py_None;
111 return _res;
114 static PyObject *Help_HMSetDialogHelpFromBalloonRsrc(PyObject *_self, PyObject *_args)
116 PyObject *_res = NULL;
117 OSStatus _err;
118 DialogPtr inDialog;
119 SInt16 inHdlgRsrcID;
120 SInt16 inItemStart;
121 if (!PyArg_ParseTuple(_args, "O&hh",
122 DlgObj_Convert, &inDialog,
123 &inHdlgRsrcID,
124 &inItemStart))
125 return NULL;
126 _err = HMSetDialogHelpFromBalloonRsrc(inDialog,
127 inHdlgRsrcID,
128 inItemStart);
129 if (_err != noErr) return PyMac_Error(_err);
130 Py_INCREF(Py_None);
131 _res = Py_None;
132 return _res;
135 static PyObject *Help_HMHideTag(PyObject *_self, PyObject *_args)
137 PyObject *_res = NULL;
138 OSStatus _err;
139 if (!PyArg_ParseTuple(_args, ""))
140 return NULL;
141 _err = HMHideTag();
142 if (_err != noErr) return PyMac_Error(_err);
143 Py_INCREF(Py_None);
144 _res = Py_None;
145 return _res;
148 #endif /* __LP64__ */
150 static PyMethodDef Help_methods[] = {
151 #ifndef __LP64__
152 {"HMGetHelpMenu", (PyCFunction)Help_HMGetHelpMenu, 1,
153 PyDoc_STR("() -> (MenuRef outHelpMenu, MenuItemIndex outFirstCustomItemIndex)")},
154 {"HMAreHelpTagsDisplayed", (PyCFunction)Help_HMAreHelpTagsDisplayed, 1,
155 PyDoc_STR("() -> (Boolean _rv)")},
156 {"HMSetHelpTagsDisplayed", (PyCFunction)Help_HMSetHelpTagsDisplayed, 1,
157 PyDoc_STR("(Boolean inDisplayTags) -> None")},
158 {"HMSetTagDelay", (PyCFunction)Help_HMSetTagDelay, 1,
159 PyDoc_STR("(Duration inDelay) -> None")},
160 {"HMGetTagDelay", (PyCFunction)Help_HMGetTagDelay, 1,
161 PyDoc_STR("() -> (Duration outDelay)")},
162 {"HMSetMenuHelpFromBalloonRsrc", (PyCFunction)Help_HMSetMenuHelpFromBalloonRsrc, 1,
163 PyDoc_STR("(MenuRef inMenu, SInt16 inHmnuRsrcID) -> None")},
164 {"HMSetDialogHelpFromBalloonRsrc", (PyCFunction)Help_HMSetDialogHelpFromBalloonRsrc, 1,
165 PyDoc_STR("(DialogPtr inDialog, SInt16 inHdlgRsrcID, SInt16 inItemStart) -> None")},
166 {"HMHideTag", (PyCFunction)Help_HMHideTag, 1,
167 PyDoc_STR("() -> None")},
168 #endif /* __LP64__ */
169 {NULL, NULL, 0}
175 void init_Help(void)
177 PyObject *m;
178 #ifndef __LP64__
179 PyObject *d;
180 #endif /* __LP64__ */
185 m = Py_InitModule("_Help", Help_methods);
186 #ifndef __LP64__
187 d = PyModule_GetDict(m);
188 Help_Error = PyMac_GetOSErrException();
189 if (Help_Error == NULL ||
190 PyDict_SetItemString(d, "Error", Help_Error) != 0)
191 return;
192 #endif /* __LP64__ */
195 /* ======================== End module _Help ======================== */