blob: fc78ffd0c0600c5a0e520539e0071e3c961aba98 [file] [log] [blame]
Jack Jansene91a29d1999-12-16 16:54:55 +00001/***********************************************************
2Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3The Netherlands.
4
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI or Corporation for National Research Initiatives or
13CNRI not be used in advertising or publicity pertaining to
14distribution of the software without specific, written prior
15permission.
16
17While CWI is the initial source for this software, a modified version
18is made available by the Corporation for National Research Initiatives
19(CNRI) at the Internet address ftp://ftp.python.org.
20
21STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
22REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
23MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
24CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28PERFORMANCE OF THIS SOFTWARE.
29
30******************************************************************/
31
32#include "Python.h"
33#include "macglue.h"
34#include <Navigation.h>
35
36/* Exported by AEModule.c: */
37extern PyObject *AEDesc_New(AppleEvent *);
38extern int AEDesc_Convert(PyObject *, AppleEvent *);
39/* Exported by Resmodule.c */
40extern PyObject *ResObj_New(Handle);
41extern int ResObj_Convert(PyObject *, Handle *);
42
43static PyObject *ErrorObject;
44
45/* ----------------------------------------------------- */
46static int
47filldialogoptions(PyObject *d,
48 NavDialogOptions *opt,
49 NavEventUPP *eventProcP,
50 NavPreviewUPP *previewProcP,
51 NavObjectFilterUPP *filterProcP,
Jack Jansene1a45b31999-12-16 22:21:30 +000052 NavTypeListHandle *typeListP,
53 OSType *creatorP,
54 OSType *typeP)
Jack Jansene91a29d1999-12-16 16:54:55 +000055{
56 int pos = 0;
57 PyObject *key, *value;
58 char *keystr;
59
Jack Jansene1a45b31999-12-16 22:21:30 +000060 NavGetDefaultDialogOptions(opt);
Jack Jansene91a29d1999-12-16 16:54:55 +000061 if ( eventProcP ) *eventProcP = NULL;
62 if ( previewProcP ) *previewProcP = NULL;
63 if ( filterProcP ) *filterProcP = NULL;
64 if ( typeListP ) *typeListP = NULL;
Jack Jansene1a45b31999-12-16 22:21:30 +000065 if ( creatorP ) *creatorP = 0;
66 if ( typeP ) *typeP = 0;
Jack Jansene91a29d1999-12-16 16:54:55 +000067
68 while ( PyDict_Next(d, &pos, &key, &value) ) {
69 if ( !key || !value || !PyString_Check(key) ) {
70 PyErr_SetString(ErrorObject, "DialogOption has non-string key");
71 return 0;
72 }
73 keystr = PyString_AsString(key);
74 if( strcmp(keystr, "version") == 0 ) {
75 if ( !PyArg_Parse(value, "h", &opt->version) )
76 return 0;
77 } else if( strcmp(keystr, "dialogOptionFlags") == 0 ) {
78 if ( !PyArg_Parse(value, "l", &opt->dialogOptionFlags) )
79 return 0;
80 } else if( strcmp(keystr, "location") == 0 ) {
81 if ( !PyArg_Parse(value, "O&", PyMac_GetPoint, &opt->location) )
82 return 0;
83 } else if( strcmp(keystr, "clientName") == 0 ) {
84 if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->clientName) )
85 return 0;
86 } else if( strcmp(keystr, "windowTitle") == 0 ) {
87 if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->windowTitle) )
88 return 0;
89 } else if( strcmp(keystr, "actionButtonLabel") == 0 ) {
90 if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->actionButtonLabel) )
91 return 0;
92 } else if( strcmp(keystr, "cancelButtonLabel") == 0 ) {
93 if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->cancelButtonLabel) )
94 return 0;
95 } else if( strcmp(keystr, "savedFileName") == 0 ) {
96 if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->savedFileName) )
97 return 0;
98 } else if( strcmp(keystr, "message") == 0 ) {
99 if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->message) )
100 return 0;
101 } else if( strcmp(keystr, "preferenceKey") == 0 ) {
102 if ( !PyArg_Parse(value, "O&", PyMac_GetOSType, &opt->preferenceKey) )
103 return 0;
104 } else if( strcmp(keystr, "popupExtension") == 0 ) {
105 if ( !PyArg_Parse(value, "O&", ResObj_Convert, &opt->popupExtension) )
106 return 0;
Jack Jansene1a45b31999-12-16 22:21:30 +0000107 } else if( eventProcP && strcmp(keystr, "eventProc") == 0 ) {
Jack Jansene91a29d1999-12-16 16:54:55 +0000108 PyErr_SetString(ErrorObject, "No callbacks implemented yet");
109 return 0;
Jack Jansene1a45b31999-12-16 22:21:30 +0000110 } else if( previewProcP && strcmp(keystr, "previewProc") == 0 ) {
Jack Jansene91a29d1999-12-16 16:54:55 +0000111 PyErr_SetString(ErrorObject, "No callbacks implemented yet");
112 return 0;
Jack Jansene1a45b31999-12-16 22:21:30 +0000113 } else if( filterProcP && strcmp(keystr, "filterProc") == 0 ) {
Jack Jansene91a29d1999-12-16 16:54:55 +0000114 PyErr_SetString(ErrorObject, "No callbacks implemented yet");
115 return 0;
Jack Jansene1a45b31999-12-16 22:21:30 +0000116 } else if( typeListP && strcmp(keystr, "typeList") == 0 ) {
Jack Jansene91a29d1999-12-16 16:54:55 +0000117 if ( !PyArg_Parse(value, "O&", ResObj_Convert, typeListP) )
118 return 0;
Jack Jansene1a45b31999-12-16 22:21:30 +0000119 } else if( creatorP && strcmp(keystr, "creator") == 0 ) {
120 if ( !PyArg_Parse(value, "O&", PyMac_GetOSType, creatorP) )
121 return 0;
122 } else if( typeP && strcmp(keystr, "type") == 0 ) {
123 if ( !PyArg_Parse(value, "O&", PyMac_GetOSType, typeP) )
124 return 0;
Jack Jansene91a29d1999-12-16 16:54:55 +0000125 } else {
126 PyErr_Format(ErrorObject, "Unknown DialogOption key: %s", keystr);
127 return 0;
128 }
129 }
130 return 1;
131}
132
133/* ----------------------------------------------------- */
134
135/* Declarations for objects of type NavReplyRecord */
136
137typedef struct {
138 PyObject_HEAD
139 NavReplyRecord itself;
140} navrrobject;
141
142staticforward PyTypeObject Navrrtype;
143
144
145
146/* ---------------------------------------------------------------- */
147
148static struct PyMethodDef navrr_methods[] = {
149
150 {NULL, NULL} /* sentinel */
151};
152
153/* ---------- */
154
155
156static navrrobject *
157newnavrrobject(NavReplyRecord *itself)
158{
159 navrrobject *self;
160
161 self = PyObject_NEW(navrrobject, &Navrrtype);
162 if (self == NULL)
163 return NULL;
164 self->itself = *itself;
165 return self;
166}
167
168
169static void
170navrr_dealloc(self)
171 navrrobject *self;
172{
173 NavDisposeReply(&self->itself);
174 PyMem_DEL(self);
175}
176
177static PyObject *
178navrr_getattr(self, name)
179 navrrobject *self;
180 char *name;
181{
182 if( strcmp(name, "version") == 0 )
183 return Py_BuildValue("h", self->itself.version);
184 if( strcmp(name, "validRecord") == 0 )
185 return Py_BuildValue("l", (long)self->itself.validRecord);
186 if( strcmp(name, "replacing") == 0 )
187 return Py_BuildValue("l", (long)self->itself.replacing);
188 if( strcmp(name, "isStationery") == 0 )
189 return Py_BuildValue("l", (long)self->itself.isStationery);
190 if( strcmp(name, "translationNeeded") == 0 )
191 return Py_BuildValue("l", (long)self->itself.translationNeeded);
192 if( strcmp(name, "selection") == 0 )
193 return AEDesc_New(&self->itself.selection); /* XXXX Is this ok? */
194 if( strcmp(name, "fileTranslation") == 0 )
195 return ResObj_New((Handle)self->itself.fileTranslation);
196
197
198 return Py_FindMethod(navrr_methods, (PyObject *)self, name);
199}
200
201static int
202navrr_setattr(self, name, v)
203 navrrobject *self;
204 char *name;
205 PyObject *v;
206{
207 /* Set attribute 'name' to value 'v'. v==NULL means delete */
208
209 /* XXXX Add your own setattr code here */
210 return -1;
211}
212
213static char Navrrtype__doc__[] =
214""
215;
216
217static PyTypeObject Navrrtype = {
218 PyObject_HEAD_INIT(&PyType_Type)
219 0, /*ob_size*/
220 "NavReplyRecord", /*tp_name*/
221 sizeof(navrrobject), /*tp_basicsize*/
222 0, /*tp_itemsize*/
223 /* methods */
224 (destructor)navrr_dealloc, /*tp_dealloc*/
225 (printfunc)0, /*tp_print*/
226 (getattrfunc)navrr_getattr, /*tp_getattr*/
227 (setattrfunc)navrr_setattr, /*tp_setattr*/
228 (cmpfunc)0, /*tp_compare*/
229 (reprfunc)0, /*tp_repr*/
230 0, /*tp_as_number*/
231 0, /*tp_as_sequence*/
232 0, /*tp_as_mapping*/
233 (hashfunc)0, /*tp_hash*/
234 (ternaryfunc)0, /*tp_call*/
235 (reprfunc)0, /*tp_str*/
236
237 /* Space for future expansion */
238 0L,0L,0L,0L,
239 Navrrtype__doc__ /* Documentation string */
240};
241
242/* End of code for NavReplyRecord objects */
243
244/* ----------------------------------------------------- */
245
246static char nav_NavGetFile__doc__[] =
247""
248;
249
250static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000251nav_NavGetFile(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000252 PyObject *self; /* Not used */
253 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000254 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000255{
256 PyObject *dict;
257 AEDesc *defaultLocation = NULL;
258 NavReplyRecord reply;
259 NavDialogOptions dialogOptions;
260 NavEventUPP eventProc = NULL;
261 NavPreviewUPP previewProc = NULL;
262 NavObjectFilterUPP filterProc = NULL;
263 NavTypeListHandle typeList = NULL;
264 OSErr err;
265
Jack Jansene1a45b31999-12-16 22:21:30 +0000266 if ( kw ) {
267 if (!PyArg_ParseTuple(args, ""))
268 return NULL;
269 dict = kw;
270 } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
Jack Jansene91a29d1999-12-16 16:54:55 +0000271 return NULL;
Jack Jansene1a45b31999-12-16 22:21:30 +0000272 if (!filldialogoptions(dict, &dialogOptions, &eventProc, &previewProc, &filterProc, &typeList, NULL, NULL))
Jack Jansene91a29d1999-12-16 16:54:55 +0000273 return NULL;
274 err = NavGetFile(defaultLocation, &reply, &dialogOptions,
275 eventProc, previewProc, filterProc, typeList, (void *)dict);
276 if ( err ) {
Jack Jansene1a45b31999-12-16 22:21:30 +0000277 PyErr_Mac(ErrorObject, err);
Jack Jansene91a29d1999-12-16 16:54:55 +0000278 return NULL;
279 }
280 return (PyObject *)newnavrrobject(&reply);
281}
282
283static char nav_NavPutFile__doc__[] =
284""
285;
286
287static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000288nav_NavPutFile(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000289 PyObject *self; /* Not used */
290 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000291 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000292{
293
294 if (!PyArg_ParseTuple(args, ""))
295 return NULL;
296 Py_INCREF(Py_None);
297 return Py_None;
298}
299
300static char nav_NavAskSaveChanges__doc__[] =
301""
302;
303
304static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000305nav_NavAskSaveChanges(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000306 PyObject *self; /* Not used */
307 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000308 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000309{
310
311 if (!PyArg_ParseTuple(args, ""))
312 return NULL;
313 Py_INCREF(Py_None);
314 return Py_None;
315}
316
317static char nav_NavCustomAskSaveChanges__doc__[] =
318""
319;
320
321static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000322nav_NavCustomAskSaveChanges(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000323 PyObject *self; /* Not used */
324 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000325 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000326{
327
328 if (!PyArg_ParseTuple(args, ""))
329 return NULL;
330 Py_INCREF(Py_None);
331 return Py_None;
332}
333
334static char nav_NavAskDiscardChanges__doc__[] =
335""
336;
337
338static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000339nav_NavAskDiscardChanges(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000340 PyObject *self; /* Not used */
341 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000342 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000343{
344
345 if (!PyArg_ParseTuple(args, ""))
346 return NULL;
347 Py_INCREF(Py_None);
348 return Py_None;
349}
350
351static char nav_NavChooseFile__doc__[] =
352""
353;
354
355static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000356nav_NavChooseFile(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000357 PyObject *self; /* Not used */
358 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000359 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000360{
361
362 if (!PyArg_ParseTuple(args, ""))
363 return NULL;
364 Py_INCREF(Py_None);
365 return Py_None;
366}
367
368static char nav_NavChooseFolder__doc__[] =
369""
370;
371
372static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000373nav_NavChooseFolder(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000374 PyObject *self; /* Not used */
375 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000376 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000377{
378
379 if (!PyArg_ParseTuple(args, ""))
380 return NULL;
381 Py_INCREF(Py_None);
382 return Py_None;
383}
384
385static char nav_NavChooseVolume__doc__[] =
386""
387;
388
389static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000390nav_NavChooseVolume(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000391 PyObject *self; /* Not used */
392 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000393 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000394{
395
396 if (!PyArg_ParseTuple(args, ""))
397 return NULL;
398 Py_INCREF(Py_None);
399 return Py_None;
400}
401
402static char nav_NavChooseObject__doc__[] =
403""
404;
405
406static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000407nav_NavChooseObject(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000408 PyObject *self; /* Not used */
409 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000410 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000411{
412
413 if (!PyArg_ParseTuple(args, ""))
414 return NULL;
415 Py_INCREF(Py_None);
416 return Py_None;
417}
418
419static char nav_NavNewFolder__doc__[] =
420""
421;
422
423static PyObject *
Jack Jansene1a45b31999-12-16 22:21:30 +0000424nav_NavNewFolder(self, args, kw)
Jack Jansene91a29d1999-12-16 16:54:55 +0000425 PyObject *self; /* Not used */
426 PyObject *args;
Jack Jansene1a45b31999-12-16 22:21:30 +0000427 PyObject *kw;
Jack Jansene91a29d1999-12-16 16:54:55 +0000428{
429
430 if (!PyArg_ParseTuple(args, ""))
431 return NULL;
432 Py_INCREF(Py_None);
433 return Py_None;
434}
435
436static char nav_NavTranslateFile__doc__[] =
437""
438;
439
440static PyObject *
441nav_NavTranslateFile(self, args)
442 PyObject *self; /* Not used */
443 PyObject *args;
444{
445
446 if (!PyArg_ParseTuple(args, ""))
447 return NULL;
448 Py_INCREF(Py_None);
449 return Py_None;
450}
451
452static char nav_NavCompleteSave__doc__[] =
453""
454;
455
456static PyObject *
457nav_NavCompleteSave(self, args)
458 PyObject *self; /* Not used */
459 PyObject *args;
460{
461
462 if (!PyArg_ParseTuple(args, ""))
463 return NULL;
464 Py_INCREF(Py_None);
465 return Py_None;
466}
467
468static char nav_NavCustomControl__doc__[] =
469""
470;
471
472static PyObject *
473nav_NavCustomControl(self, args)
474 PyObject *self; /* Not used */
475 PyObject *args;
476{
477
478 if (!PyArg_ParseTuple(args, ""))
479 return NULL;
480 Py_INCREF(Py_None);
481 return Py_None;
482}
483
484static char nav_NavServicesCanRun__doc__[] =
485""
486;
487
488static PyObject *
489nav_NavServicesCanRun(self, args)
490 PyObject *self; /* Not used */
491 PyObject *args;
492{
493 Boolean rv;
494 if (!PyArg_ParseTuple(args, ""))
495 return NULL;
496 rv = NavServicesCanRun();
497 return Py_BuildValue("l", (long)rv);
498}
499
500static char nav_NavServicesAvailable__doc__[] =
501""
502;
503
504static PyObject *
505nav_NavServicesAvailable(self, args)
506 PyObject *self; /* Not used */
507 PyObject *args;
508{
509 Boolean rv;
510
511 if (!PyArg_ParseTuple(args, ""))
512 return NULL;
513 rv = NavServicesAvailable();
514 return Py_BuildValue("l", (long)rv);
515}
516/* XX */
517static char nav_NavLoad__doc__[] =
518""
519;
520
521static PyObject *
522nav_NavLoad(self, args)
523 PyObject *self; /* Not used */
524 PyObject *args;
525{
526
527 if (!PyArg_ParseTuple(args, ""))
528 return NULL;
529 NavLoad();
530 Py_INCREF(Py_None);
531 return Py_None;
532}
533
534static char nav_NavUnload__doc__[] =
535""
536;
537
538static PyObject *
539nav_NavUnload(self, args)
540 PyObject *self; /* Not used */
541 PyObject *args;
542{
543
544 if (!PyArg_ParseTuple(args, ""))
545 return NULL;
546 NavUnload();
547 Py_INCREF(Py_None);
548 return Py_None;
549}
550
551static char nav_NavLibraryVersion__doc__[] =
552""
553;
554
555static PyObject *
556nav_NavLibraryVersion(self, args)
557 PyObject *self; /* Not used */
558 PyObject *args;
559{
560 UInt32 rv;
561
562 if (!PyArg_ParseTuple(args, ""))
563 return NULL;
564 rv = NavLibraryVersion();
565 return Py_BuildValue("l", (long)rv);
566}
567
568#ifdef notyet
569static char nav_NavGetDefaultDialogOptions__doc__[] =
570""
571;
572
573static PyObject *
574nav_NavGetDefaultDialogOptions(self, args)
575 PyObject *self; /* Not used */
576 PyObject *args;
577{
578
579 if (!PyArg_ParseTuple(args, ""))
580 return NULL;
581 Py_INCREF(Py_None);
582 return Py_None;
583}
584#endif
585
586
587/* List of methods defined in the module */
588
589static struct PyMethodDef nav_methods[] = {
Jack Jansene1a45b31999-12-16 22:21:30 +0000590 {"NavGetFile", (PyCFunction)nav_NavGetFile, METH_VARARGS|METH_KEYWORDS, nav_NavGetFile__doc__},
591 {"NavPutFile", (PyCFunction)nav_NavPutFile, METH_VARARGS|METH_KEYWORDS, nav_NavPutFile__doc__},
592 {"NavAskSaveChanges", (PyCFunction)nav_NavAskSaveChanges, METH_VARARGS|METH_KEYWORDS, nav_NavAskSaveChanges__doc__},
593 {"NavCustomAskSaveChanges", (PyCFunction)nav_NavCustomAskSaveChanges, METH_VARARGS|METH_KEYWORDS, nav_NavCustomAskSaveChanges__doc__},
594 {"NavAskDiscardChanges", (PyCFunction)nav_NavAskDiscardChanges, METH_VARARGS|METH_KEYWORDS, nav_NavAskDiscardChanges__doc__},
595 {"NavChooseFile", (PyCFunction)nav_NavChooseFile, METH_VARARGS|METH_KEYWORDS, nav_NavChooseFile__doc__},
596 {"NavChooseFolder", (PyCFunction)nav_NavChooseFolder, METH_VARARGS|METH_KEYWORDS, nav_NavChooseFolder__doc__},
597 {"NavChooseVolume", (PyCFunction)nav_NavChooseVolume, METH_VARARGS|METH_KEYWORDS, nav_NavChooseVolume__doc__},
598 {"NavChooseObject", (PyCFunction)nav_NavChooseObject, METH_VARARGS|METH_KEYWORDS, nav_NavChooseObject__doc__},
599 {"NavNewFolder", (PyCFunction)nav_NavNewFolder, METH_VARARGS|METH_KEYWORDS, nav_NavNewFolder__doc__},
Jack Jansene91a29d1999-12-16 16:54:55 +0000600 {"NavTranslateFile", (PyCFunction)nav_NavTranslateFile, METH_VARARGS, nav_NavTranslateFile__doc__},
601 {"NavCompleteSave", (PyCFunction)nav_NavCompleteSave, METH_VARARGS, nav_NavCompleteSave__doc__},
602 {"NavCustomControl", (PyCFunction)nav_NavCustomControl, METH_VARARGS, nav_NavCustomControl__doc__},
603 {"NavServicesCanRun", (PyCFunction)nav_NavServicesCanRun, METH_VARARGS, nav_NavServicesCanRun__doc__},
604 {"NavServicesAvailable", (PyCFunction)nav_NavServicesAvailable, METH_VARARGS, nav_NavServicesAvailable__doc__},
605 {"NavLoad", (PyCFunction)nav_NavLoad, METH_VARARGS, nav_NavLoad__doc__},
606 {"NavUnload", (PyCFunction)nav_NavUnload, METH_VARARGS, nav_NavUnload__doc__},
607 {"NavLibraryVersion", (PyCFunction)nav_NavLibraryVersion, METH_VARARGS, nav_NavLibraryVersion__doc__},
608#ifdef notdef
609 {"NavGetDefaultDialogOptions", (PyCFunction)nav_NavGetDefaultDialogOptions, METH_VARARGS, nav_NavGetDefaultDialogOptions__doc__},
610#endif
611 {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
612};
613
614
615/* Initialization function for the module (*must* be called initNav) */
616
617static char Nav_module_documentation[] =
618""
619;
620
621void
622initNav()
623{
624 PyObject *m, *d;
625
626 /* Create the module and add the functions */
627 m = Py_InitModule4("Nav", nav_methods,
628 Nav_module_documentation,
629 (PyObject*)NULL,PYTHON_API_VERSION);
630
631 /* Add some symbolic constants to the module */
632 d = PyModule_GetDict(m);
633 ErrorObject = PyString_FromString("Nav.error");
634 PyDict_SetItemString(d, "error", ErrorObject);
635
636 /* XXXX Add constants here */
637
638 /* Check for errors */
639 if (PyErr_Occurred())
640 Py_FatalError("can't initialize module Nav");
641}
642