Bump version to 0.9.1.
[python/dscho.git] / Mac / Modules / help / Helpmodule.c
blobfac21b6db2b758ac2bdc9432c7971790e5b3eb32
2 /* ========================== Module Help =========================== */
4 #include "Python.h"
8 #include "macglue.h"
9 #include "pymactoolbox.h"
11 #include <Balloons.h>
13 static PyObject *Help_Error;
15 static PyObject *Help_HMGetHelpMenuHandle(_self, _args)
16 PyObject *_self;
17 PyObject *_args;
19 PyObject *_res = NULL;
20 OSErr _err;
21 MenuHandle mh;
22 if (!PyArg_ParseTuple(_args, ""))
23 return NULL;
24 _err = HMGetHelpMenuHandle(&mh);
25 if (_err != noErr) return PyMac_Error(_err);
26 _res = Py_BuildValue("O&",
27 MenuObj_New, mh);
28 return _res;
31 static PyObject *Help_HMRemoveBalloon(_self, _args)
32 PyObject *_self;
33 PyObject *_args;
35 PyObject *_res = NULL;
36 OSErr _err;
37 if (!PyArg_ParseTuple(_args, ""))
38 return NULL;
39 _err = HMRemoveBalloon();
40 if (_err != noErr) return PyMac_Error(_err);
41 Py_INCREF(Py_None);
42 _res = Py_None;
43 return _res;
46 static PyObject *Help_HMIsBalloon(_self, _args)
47 PyObject *_self;
48 PyObject *_args;
50 PyObject *_res = NULL;
51 Boolean _rv;
52 if (!PyArg_ParseTuple(_args, ""))
53 return NULL;
54 _rv = HMIsBalloon();
55 _res = Py_BuildValue("b",
56 _rv);
57 return _res;
60 static PyObject *Help_HMGetBalloons(_self, _args)
61 PyObject *_self;
62 PyObject *_args;
64 PyObject *_res = NULL;
65 Boolean _rv;
66 if (!PyArg_ParseTuple(_args, ""))
67 return NULL;
68 _rv = HMGetBalloons();
69 _res = Py_BuildValue("b",
70 _rv);
71 return _res;
74 static PyObject *Help_HMSetBalloons(_self, _args)
75 PyObject *_self;
76 PyObject *_args;
78 PyObject *_res = NULL;
79 OSErr _err;
80 Boolean flag;
81 if (!PyArg_ParseTuple(_args, "b",
82 &flag))
83 return NULL;
84 _err = HMSetBalloons(flag);
85 if (_err != noErr) return PyMac_Error(_err);
86 Py_INCREF(Py_None);
87 _res = Py_None;
88 return _res;
91 static PyObject *Help_HMSetFont(_self, _args)
92 PyObject *_self;
93 PyObject *_args;
95 PyObject *_res = NULL;
96 OSErr _err;
97 SInt16 font;
98 if (!PyArg_ParseTuple(_args, "h",
99 &font))
100 return NULL;
101 _err = HMSetFont(font);
102 if (_err != noErr) return PyMac_Error(_err);
103 Py_INCREF(Py_None);
104 _res = Py_None;
105 return _res;
108 static PyObject *Help_HMSetFontSize(_self, _args)
109 PyObject *_self;
110 PyObject *_args;
112 PyObject *_res = NULL;
113 OSErr _err;
114 UInt16 fontSize;
115 if (!PyArg_ParseTuple(_args, "H",
116 &fontSize))
117 return NULL;
118 _err = HMSetFontSize(fontSize);
119 if (_err != noErr) return PyMac_Error(_err);
120 Py_INCREF(Py_None);
121 _res = Py_None;
122 return _res;
125 static PyObject *Help_HMGetFont(_self, _args)
126 PyObject *_self;
127 PyObject *_args;
129 PyObject *_res = NULL;
130 OSErr _err;
131 SInt16 font;
132 if (!PyArg_ParseTuple(_args, ""))
133 return NULL;
134 _err = HMGetFont(&font);
135 if (_err != noErr) return PyMac_Error(_err);
136 _res = Py_BuildValue("h",
137 font);
138 return _res;
141 static PyObject *Help_HMGetFontSize(_self, _args)
142 PyObject *_self;
143 PyObject *_args;
145 PyObject *_res = NULL;
146 OSErr _err;
147 UInt16 fontSize;
148 if (!PyArg_ParseTuple(_args, ""))
149 return NULL;
150 _err = HMGetFontSize(&fontSize);
151 if (_err != noErr) return PyMac_Error(_err);
152 _res = Py_BuildValue("H",
153 fontSize);
154 return _res;
157 static PyObject *Help_HMSetDialogResID(_self, _args)
158 PyObject *_self;
159 PyObject *_args;
161 PyObject *_res = NULL;
162 OSErr _err;
163 SInt16 resID;
164 if (!PyArg_ParseTuple(_args, "h",
165 &resID))
166 return NULL;
167 _err = HMSetDialogResID(resID);
168 if (_err != noErr) return PyMac_Error(_err);
169 Py_INCREF(Py_None);
170 _res = Py_None;
171 return _res;
174 static PyObject *Help_HMSetMenuResID(_self, _args)
175 PyObject *_self;
176 PyObject *_args;
178 PyObject *_res = NULL;
179 OSErr _err;
180 SInt16 menuID;
181 SInt16 resID;
182 if (!PyArg_ParseTuple(_args, "hh",
183 &menuID,
184 &resID))
185 return NULL;
186 _err = HMSetMenuResID(menuID,
187 resID);
188 if (_err != noErr) return PyMac_Error(_err);
189 Py_INCREF(Py_None);
190 _res = Py_None;
191 return _res;
194 static PyObject *Help_HMScanTemplateItems(_self, _args)
195 PyObject *_self;
196 PyObject *_args;
198 PyObject *_res = NULL;
199 OSErr _err;
200 SInt16 whichID;
201 SInt16 whichResFile;
202 ResType whichType;
203 if (!PyArg_ParseTuple(_args, "hhO&",
204 &whichID,
205 &whichResFile,
206 PyMac_GetOSType, &whichType))
207 return NULL;
208 _err = HMScanTemplateItems(whichID,
209 whichResFile,
210 whichType);
211 if (_err != noErr) return PyMac_Error(_err);
212 Py_INCREF(Py_None);
213 _res = Py_None;
214 return _res;
217 static PyObject *Help_HMGetDialogResID(_self, _args)
218 PyObject *_self;
219 PyObject *_args;
221 PyObject *_res = NULL;
222 OSErr _err;
223 SInt16 resID;
224 if (!PyArg_ParseTuple(_args, ""))
225 return NULL;
226 _err = HMGetDialogResID(&resID);
227 if (_err != noErr) return PyMac_Error(_err);
228 _res = Py_BuildValue("h",
229 resID);
230 return _res;
233 static PyObject *Help_HMGetMenuResID(_self, _args)
234 PyObject *_self;
235 PyObject *_args;
237 PyObject *_res = NULL;
238 OSErr _err;
239 SInt16 menuID;
240 SInt16 resID;
241 if (!PyArg_ParseTuple(_args, "h",
242 &menuID))
243 return NULL;
244 _err = HMGetMenuResID(menuID,
245 &resID);
246 if (_err != noErr) return PyMac_Error(_err);
247 _res = Py_BuildValue("h",
248 resID);
249 return _res;
252 static PyObject *Help_HMGetBalloonWindow(_self, _args)
253 PyObject *_self;
254 PyObject *_args;
256 PyObject *_res = NULL;
257 OSErr _err;
258 WindowPtr window;
259 if (!PyArg_ParseTuple(_args, ""))
260 return NULL;
261 _err = HMGetBalloonWindow(&window);
262 if (_err != noErr) return PyMac_Error(_err);
263 _res = Py_BuildValue("O&",
264 WinObj_New, window);
265 return _res;
268 static PyMethodDef Help_methods[] = {
269 {"HMGetHelpMenuHandle", (PyCFunction)Help_HMGetHelpMenuHandle, 1,
270 "() -> (MenuHandle mh)"},
271 {"HMRemoveBalloon", (PyCFunction)Help_HMRemoveBalloon, 1,
272 "() -> None"},
273 {"HMIsBalloon", (PyCFunction)Help_HMIsBalloon, 1,
274 "() -> (Boolean _rv)"},
275 {"HMGetBalloons", (PyCFunction)Help_HMGetBalloons, 1,
276 "() -> (Boolean _rv)"},
277 {"HMSetBalloons", (PyCFunction)Help_HMSetBalloons, 1,
278 "(Boolean flag) -> None"},
279 {"HMSetFont", (PyCFunction)Help_HMSetFont, 1,
280 "(SInt16 font) -> None"},
281 {"HMSetFontSize", (PyCFunction)Help_HMSetFontSize, 1,
282 "(UInt16 fontSize) -> None"},
283 {"HMGetFont", (PyCFunction)Help_HMGetFont, 1,
284 "() -> (SInt16 font)"},
285 {"HMGetFontSize", (PyCFunction)Help_HMGetFontSize, 1,
286 "() -> (UInt16 fontSize)"},
287 {"HMSetDialogResID", (PyCFunction)Help_HMSetDialogResID, 1,
288 "(SInt16 resID) -> None"},
289 {"HMSetMenuResID", (PyCFunction)Help_HMSetMenuResID, 1,
290 "(SInt16 menuID, SInt16 resID) -> None"},
291 {"HMScanTemplateItems", (PyCFunction)Help_HMScanTemplateItems, 1,
292 "(SInt16 whichID, SInt16 whichResFile, ResType whichType) -> None"},
293 {"HMGetDialogResID", (PyCFunction)Help_HMGetDialogResID, 1,
294 "() -> (SInt16 resID)"},
295 {"HMGetMenuResID", (PyCFunction)Help_HMGetMenuResID, 1,
296 "(SInt16 menuID) -> (SInt16 resID)"},
297 {"HMGetBalloonWindow", (PyCFunction)Help_HMGetBalloonWindow, 1,
298 "() -> (WindowPtr window)"},
299 {NULL, NULL, 0}
305 void initHelp()
307 PyObject *m;
308 PyObject *d;
313 m = Py_InitModule("Help", Help_methods);
314 d = PyModule_GetDict(m);
315 Help_Error = PyMac_GetOSErrException();
316 if (Help_Error == NULL ||
317 PyDict_SetItemString(d, "Error", Help_Error) != 0)
318 Py_FatalError("can't initialize Help.Error");
321 /* ======================== End module Help ========================= */