1 /***********************************************************
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
7 Permission to use, copy, modify, and distribute this software and its
8 documentation for any purpose and without fee is hereby granted,
9 provided that the above copyright notice appear in all copies and that
10 both that copyright notice and this permission notice appear in
11 supporting documentation, and that the names of Stichting Mathematisch
12 Centrum or CWI or Corporation for National Research Initiatives or
13 CNRI not be used in advertising or publicity pertaining to
14 distribution of the software without specific, written prior
17 While CWI is the initial source for this software, a modified version
18 is made available by the Corporation for National Research Initiatives
19 (CNRI) at the Internet address ftp://ftp.python.org.
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28 PERFORMANCE OF THIS SOFTWARE.
30 ******************************************************************/
34 #include <Navigation.h>
36 /* Exported by AEModule.c: */
37 extern PyObject
*AEDesc_New(AppleEvent
*);
38 extern int AEDesc_Convert(PyObject
*, AppleEvent
*);
39 /* Exported by Resmodule.c */
40 extern PyObject
*ResObj_New(Handle
);
41 extern PyObject
*OptResObj_New(Handle
);
42 extern int ResObj_Convert(PyObject
*, Handle
*);
44 static PyObject
*ErrorObject
;
46 static NavEventUPP my_eventProcUPP
;
47 static NavPreviewUPP my_previewProcUPP
;
48 static NavObjectFilterUPP my_filterProcUPP
;
50 /* Callback functions */
52 my_eventProc(NavEventCallbackMessage callBackSelector
,
53 NavCBRecPtr callBackParms
,
54 NavCallBackUserData callbackUD
)
56 PyObject
*dict
= (PyObject
*)callbackUD
;
61 if ( (pyfunc
= PyDict_GetItemString(dict
, "eventProc")) == NULL
) {
65 if ( pyfunc
== Py_None
) {
66 /* Special case: give update events to the Python event handling code */
67 if ( callBackSelector
== kNavCBEvent
&&
68 callBackParms
->eventData
.eventDataParms
.event
->what
== updateEvt
)
69 PyMac_HandleEvent(callBackParms
->eventData
.eventDataParms
.event
);
73 rv
= PyObject_CallFunction(pyfunc
, "ls#", (long)callBackSelector
,
74 (void *)callBackParms
, sizeof(NavCBRec
));
78 fprintf(stderr
, "Nav: exception in eventProc callback\n");
84 my_previewProc(NavCBRecPtr callBackParms
,
85 NavCallBackUserData callbackUD
)
87 PyObject
*dict
= (PyObject
*)callbackUD
;
93 if ( (pyfunc
= PyDict_GetItemString(dict
, "previewProc")) == NULL
) {
97 rv
= PyObject_CallFunction(pyfunc
, "s#", (void *)callBackParms
, sizeof(NavCBRec
));
99 c_rv
= PyObject_IsTrue(rv
);
102 fprintf(stderr
, "Nav: exception in previewProc callback\n");
108 static pascal Boolean
109 my_filterProc(AEDesc
*theItem
, void *info
,
110 NavCallBackUserData callbackUD
,
111 NavFilterModes filterMode
)
113 PyObject
*dict
= (PyObject
*)callbackUD
;
116 Boolean c_rv
= false;
119 if ( (pyfunc
= PyDict_GetItemString(dict
, "filterProc")) == NULL
) {
123 rv
= PyObject_CallFunction(pyfunc
, "O&s#h",
124 AEDesc_New
, theItem
, info
, sizeof(NavFileOrFolderInfo
), (short)filterMode
);
126 c_rv
= PyObject_IsTrue(rv
);
129 fprintf(stderr
, "Nav: exception in filterProc callback\n");
135 /* ----------------------------------------------------- */
137 filldialogoptions(PyObject
*d
,
138 AEDesc
**defaultLocationP
,
139 NavDialogOptions
*opt
,
140 NavEventUPP
*eventProcP
,
141 NavPreviewUPP
*previewProcP
,
142 NavObjectFilterUPP
*filterProcP
,
143 NavTypeListHandle
*typeListP
,
145 OSType
*fileCreatorP
)
148 PyObject
*key
, *value
;
150 AEDesc
*defaultLocation_storage
;
152 NavGetDefaultDialogOptions(opt
);
154 while ( PyDict_Next(d
, &pos
, &key
, &value
) ) {
155 if ( !key
|| !value
|| !PyString_Check(key
) ) {
156 PyErr_SetString(ErrorObject
, "DialogOption has non-string key");
159 keystr
= PyString_AsString(key
);
160 if( strcmp(keystr
, "defaultLocation") == 0 ) {
161 if ( (defaultLocation_storage
= PyMem_NEW(AEDesc
, 1)) == NULL
) {
165 if ( !PyArg_Parse(value
, "O&", AEDesc_Convert
, defaultLocation_storage
) ) {
166 PyMem_DEL(defaultLocation_storage
);
169 *defaultLocationP
= defaultLocation_storage
;
170 } else if( strcmp(keystr
, "version") == 0 ) {
171 if ( !PyArg_Parse(value
, "h", &opt
->version
) )
173 } else if( strcmp(keystr
, "dialogOptionFlags") == 0 ) {
174 if ( !PyArg_Parse(value
, "l", &opt
->dialogOptionFlags
) )
176 } else if( strcmp(keystr
, "location") == 0 ) {
177 if ( !PyArg_Parse(value
, "O&", PyMac_GetPoint
, &opt
->location
) )
179 } else if( strcmp(keystr
, "clientName") == 0 ) {
180 if ( !PyArg_Parse(value
, "O&", PyMac_GetStr255
, &opt
->clientName
) )
182 } else if( strcmp(keystr
, "windowTitle") == 0 ) {
183 if ( !PyArg_Parse(value
, "O&", PyMac_GetStr255
, &opt
->windowTitle
) )
185 } else if( strcmp(keystr
, "actionButtonLabel") == 0 ) {
186 if ( !PyArg_Parse(value
, "O&", PyMac_GetStr255
, &opt
->actionButtonLabel
) )
188 } else if( strcmp(keystr
, "cancelButtonLabel") == 0 ) {
189 if ( !PyArg_Parse(value
, "O&", PyMac_GetStr255
, &opt
->cancelButtonLabel
) )
191 } else if( strcmp(keystr
, "savedFileName") == 0 ) {
192 if ( !PyArg_Parse(value
, "O&", PyMac_GetStr255
, &opt
->savedFileName
) )
194 } else if( strcmp(keystr
, "message") == 0 ) {
195 if ( !PyArg_Parse(value
, "O&", PyMac_GetStr255
, &opt
->message
) )
197 } else if( strcmp(keystr
, "preferenceKey") == 0 ) {
198 if ( !PyArg_Parse(value
, "O&", PyMac_GetOSType
, &opt
->preferenceKey
) )
200 } else if( strcmp(keystr
, "popupExtension") == 0 ) {
201 if ( !PyArg_Parse(value
, "O&", ResObj_Convert
, &opt
->popupExtension
) )
203 } else if( eventProcP
&& strcmp(keystr
, "eventProc") == 0 ) {
204 *eventProcP
= my_eventProcUPP
;
205 } else if( previewProcP
&& strcmp(keystr
, "previewProc") == 0 ) {
206 PyErr_SetString(ErrorObject
, "No callbacks implemented yet");
208 } else if( filterProcP
&& strcmp(keystr
, "filterProc") == 0 ) {
209 PyErr_SetString(ErrorObject
, "No callbacks implemented yet");
211 } else if( typeListP
&& strcmp(keystr
, "typeList") == 0 ) {
212 if ( !PyArg_Parse(value
, "O&", ResObj_Convert
, typeListP
) )
214 } else if( fileTypeP
&& strcmp(keystr
, "fileType") == 0 ) {
215 if ( !PyArg_Parse(value
, "O&", PyMac_GetOSType
, fileTypeP
) )
217 } else if( fileCreatorP
&& strcmp(keystr
, "fileCreator") == 0 ) {
218 if ( !PyArg_Parse(value
, "O&", PyMac_GetOSType
, fileCreatorP
) )
221 PyErr_Format(ErrorObject
, "Unknown DialogOption key: %s", keystr
);
228 /* ----------------------------------------------------- */
230 /* Declarations for objects of type NavReplyRecord */
234 NavReplyRecord itself
;
237 staticforward PyTypeObject Navrrtype
;
241 /* ---------------------------------------------------------------- */
243 static char nav_NavTranslateFile__doc__
[] =
244 "(NavTranslationOptions)->None"
248 nav_NavTranslateFile(self
, args
)
252 NavTranslationOptions howToTranslate
;
255 if (!PyArg_ParseTuple(args
, "l", &howToTranslate
))
257 err
= NavTranslateFile(&self
->itself
, howToTranslate
);
259 PyErr_Mac(ErrorObject
, err
);
266 static char nav_NavCompleteSave__doc__
[] =
267 "(NavTranslationOptions)->None"
271 nav_NavCompleteSave(self
, args
)
275 NavTranslationOptions howToTranslate
;
278 if (!PyArg_ParseTuple(args
, "l", &howToTranslate
))
280 err
= NavCompleteSave(&self
->itself
, howToTranslate
);
282 PyErr_Mac(ErrorObject
, err
);
290 static struct PyMethodDef navrr_methods
[] = {
291 {"NavTranslateFile", (PyCFunction
)nav_NavTranslateFile
, METH_VARARGS
, nav_NavTranslateFile__doc__
},
292 {"NavCompleteSave", (PyCFunction
)nav_NavCompleteSave
, METH_VARARGS
, nav_NavCompleteSave__doc__
},
294 {NULL
, NULL
} /* sentinel */
301 newnavrrobject(NavReplyRecord
*itself
)
305 self
= PyObject_NEW(navrrobject
, &Navrrtype
);
308 self
->itself
= *itself
;
317 NavDisposeReply(&self
->itself
);
322 navrr_getattr(self
, name
)
326 if( strcmp(name
, "__members__") == 0 )
327 return Py_BuildValue("sssssss", "version", "validRecord", "replacing",
328 "isStationery", "translationNeeded", "selection", "fileTranslation");
329 if( strcmp(name
, "version") == 0 )
330 return Py_BuildValue("h", self
->itself
.version
);
331 if( strcmp(name
, "validRecord") == 0 )
332 return Py_BuildValue("l", (long)self
->itself
.validRecord
);
333 if( strcmp(name
, "replacing") == 0 )
334 return Py_BuildValue("l", (long)self
->itself
.replacing
);
335 if( strcmp(name
, "isStationery") == 0 )
336 return Py_BuildValue("l", (long)self
->itself
.isStationery
);
337 if( strcmp(name
, "translationNeeded") == 0 )
338 return Py_BuildValue("l", (long)self
->itself
.translationNeeded
);
339 if( strcmp(name
, "selection") == 0 ) {
342 PyObject
*rv
, *rvitem
;
345 if (err
=AECountItems(&self
->itself
.selection
, &count
)) {
346 PyErr_Mac(ErrorObject
, err
);
349 if ( (rv
=PyList_New(count
)) == NULL
)
351 for(i
=0; i
<count
; i
++) {
352 desc
.dataHandle
= NULL
;
353 if (err
=AEGetNthDesc(&self
->itself
.selection
, i
+1, typeFSS
, NULL
, &desc
)) {
355 PyErr_Mac(ErrorObject
, err
);
358 rvitem
= PyMac_BuildFSSpec((FSSpec
*)*desc
.dataHandle
);
359 PyList_SetItem(rv
, i
, rvitem
);
360 AEDisposeDesc(&desc
);
364 if( strcmp(name
, "fileTranslation") == 0 )
365 return ResObj_New((Handle
)self
->itself
.fileTranslation
);
368 return Py_FindMethod(navrr_methods
, (PyObject
*)self
, name
);
372 navrr_setattr(self
, name
, v
)
377 /* Set attribute 'name' to value 'v'. v==NULL means delete */
379 /* XXXX Add your own setattr code here */
383 static char Navrrtype__doc__
[] =
384 "Record containing result of a Nav file selection call. Use dir() for member names."
387 static PyTypeObject Navrrtype
= {
388 PyObject_HEAD_INIT(&PyType_Type
)
390 "NavReplyRecord", /*tp_name*/
391 sizeof(navrrobject
), /*tp_basicsize*/
394 (destructor
)navrr_dealloc
, /*tp_dealloc*/
395 (printfunc
)0, /*tp_print*/
396 (getattrfunc
)navrr_getattr
, /*tp_getattr*/
397 (setattrfunc
)navrr_setattr
, /*tp_setattr*/
398 (cmpfunc
)0, /*tp_compare*/
399 (reprfunc
)0, /*tp_repr*/
401 0, /*tp_as_sequence*/
403 (hashfunc
)0, /*tp_hash*/
404 (ternaryfunc
)0, /*tp_call*/
405 (reprfunc
)0, /*tp_str*/
407 /* Space for future expansion */
409 Navrrtype__doc__
/* Documentation string */
412 /* End of code for NavReplyRecord objects */
414 /* ----------------------------------------------------- */
416 static char nav_NavGetFile__doc__
[] =
417 "(DialogOptions dict or kwargs+defaultLocation,eventProc,previewProc,filterProc,typeList) -> NavReplyRecord"
421 nav_NavGetFile(self
, args
, kw
)
422 PyObject
*self
; /* Not used */
427 AEDesc
*defaultLocation
= NULL
;
428 NavReplyRecord reply
;
429 NavDialogOptions dialogOptions
;
430 NavEventUPP eventProc
= NULL
;
431 NavPreviewUPP previewProc
= NULL
;
432 NavObjectFilterUPP filterProc
= NULL
;
433 NavTypeListHandle typeList
= NULL
;
437 if (!PyArg_ParseTuple(args
, ""))
440 } else if (!PyArg_ParseTuple(args
, "O!", &PyDict_Type
, &dict
))
442 if (!filldialogoptions(dict
, &defaultLocation
, &dialogOptions
, &eventProc
, &previewProc
, &filterProc
, &typeList
, NULL
, NULL
))
444 err
= NavGetFile(defaultLocation
, &reply
, &dialogOptions
,
445 eventProc
, previewProc
, filterProc
, typeList
, (void *)dict
);
446 PyMem_XDEL(defaultLocation
);
448 PyErr_Mac(ErrorObject
, err
);
451 return (PyObject
*)newnavrrobject(&reply
);
454 static char nav_NavPutFile__doc__
[] =
455 "(DialogOptions dict or kwargs+defaultLocation,eventProc,fileCreator,fileType) -> NavReplyRecord"
459 nav_NavPutFile(self
, args
, kw
)
460 PyObject
*self
; /* Not used */
465 AEDesc
*defaultLocation
= NULL
;
466 NavReplyRecord reply
;
467 NavDialogOptions dialogOptions
;
468 NavEventUPP eventProc
= NULL
;
474 if (!PyArg_ParseTuple(args
, ""))
477 } else if (!PyArg_ParseTuple(args
, "O!", &PyDict_Type
, &dict
))
479 if (!filldialogoptions(dict
, &defaultLocation
, &dialogOptions
, &eventProc
, NULL
, NULL
, NULL
, &fileType
, &fileCreator
))
481 err
= NavPutFile(defaultLocation
, &reply
, &dialogOptions
,
482 eventProc
, fileType
, fileCreator
, (void *)dict
);
483 PyMem_XDEL(defaultLocation
);
485 PyErr_Mac(ErrorObject
, err
);
488 return (PyObject
*)newnavrrobject(&reply
);
491 static char nav_NavAskSaveChanges__doc__
[] =
492 "(NavAskSaveChangesAction, DialogOptions dict or kwargs+eventProc) -> NavAskSaveChangesResult"
497 nav_NavAskSaveChanges(self
, args
, kw
)
498 PyObject
*self
; /* Not used */
503 NavDialogOptions dialogOptions
;
504 NavAskSaveChangesAction action
;
505 NavAskSaveChangesResult reply
;
506 NavEventUPP eventProc
= NULL
;
510 if (!PyArg_ParseTuple(args
, "l", &action
))
513 } else if (!PyArg_ParseTuple(args
, "lO!", &action
, &PyDict_Type
, &dict
))
515 if (!filldialogoptions(dict
, NULL
, &dialogOptions
, &eventProc
, NULL
, NULL
, NULL
, NULL
, NULL
))
517 err
= NavAskSaveChanges(&dialogOptions
, action
, &reply
, eventProc
, (void *)dict
);
519 PyErr_Mac(ErrorObject
, err
);
522 return Py_BuildValue("l", (long)reply
);
525 static char nav_NavCustomAskSaveChanges__doc__
[] =
526 "(DialogOptions dict or kwargs+eventProc) -> NavAskSaveChangesResult"
530 nav_NavCustomAskSaveChanges(self
, args
, kw
)
531 PyObject
*self
; /* Not used */
536 NavDialogOptions dialogOptions
;
537 NavAskSaveChangesResult reply
;
538 NavEventUPP eventProc
= NULL
;
542 if (!PyArg_ParseTuple(args
, ""))
545 } else if (!PyArg_ParseTuple(args
, "O!", &PyDict_Type
, &dict
))
547 if (!filldialogoptions(dict
, NULL
, &dialogOptions
, &eventProc
, NULL
, NULL
, NULL
, NULL
, NULL
))
549 err
= NavCustomAskSaveChanges(&dialogOptions
, &reply
, eventProc
, (void *)dict
);
551 PyErr_Mac(ErrorObject
, err
);
554 return Py_BuildValue("l", (long)reply
);
557 static char nav_NavAskDiscardChanges__doc__
[] =
558 "(DialogOptions dict or kwargs+eventProc) -> NavAskSaveChangesResult"
562 nav_NavAskDiscardChanges(self
, args
, kw
)
563 PyObject
*self
; /* Not used */
568 NavDialogOptions dialogOptions
;
569 NavAskSaveChangesResult reply
;
570 NavEventUPP eventProc
= NULL
;
574 if (!PyArg_ParseTuple(args
, ""))
577 } else if (!PyArg_ParseTuple(args
, "O!", &PyDict_Type
, &dict
))
579 if (!filldialogoptions(dict
, NULL
, &dialogOptions
, &eventProc
, NULL
, NULL
, NULL
, NULL
, NULL
))
581 err
= NavAskDiscardChanges(&dialogOptions
, &reply
, eventProc
, (void *)dict
);
583 PyErr_Mac(ErrorObject
, err
);
586 return Py_BuildValue("l", (long)reply
);
589 static char nav_NavChooseFile__doc__
[] =
590 "(DialogOptions dict or kwargs+defaultLocation,eventProc,previewProc,filterProc,typeList) -> NavReplyRecord"
594 nav_NavChooseFile(self
, args
, kw
)
595 PyObject
*self
; /* Not used */
600 AEDesc
*defaultLocation
= NULL
;
601 NavReplyRecord reply
;
602 NavDialogOptions dialogOptions
;
603 NavEventUPP eventProc
= NULL
;
604 NavPreviewUPP previewProc
= NULL
;
605 NavObjectFilterUPP filterProc
= NULL
;
606 NavTypeListHandle typeList
= NULL
;
610 if (!PyArg_ParseTuple(args
, ""))
613 } else if (!PyArg_ParseTuple(args
, "O!", &PyDict_Type
, &dict
))
615 if (!filldialogoptions(dict
, &defaultLocation
, &dialogOptions
, &eventProc
, &previewProc
, &filterProc
, &typeList
, NULL
, NULL
))
617 err
= NavChooseFile(defaultLocation
, &reply
, &dialogOptions
,
618 eventProc
, previewProc
, filterProc
, typeList
, (void *)dict
);
619 PyMem_XDEL(defaultLocation
);
621 PyErr_Mac(ErrorObject
, err
);
624 return (PyObject
*)newnavrrobject(&reply
);
627 static char nav_NavChooseFolder__doc__
[] =
628 "(DialogOptions dict or kwargs+defaultLocation,eventProc,filterProc) -> NavReplyRecord"
632 nav_NavChooseFolder(self
, args
, kw
)
633 PyObject
*self
; /* Not used */
638 AEDesc
*defaultLocation
= NULL
;
639 NavReplyRecord reply
;
640 NavDialogOptions dialogOptions
;
641 NavEventUPP eventProc
= NULL
;
642 NavObjectFilterUPP filterProc
= NULL
;
646 if (!PyArg_ParseTuple(args
, ""))
649 } else if (!PyArg_ParseTuple(args
, "O!", &PyDict_Type
, &dict
))
651 if (!filldialogoptions(dict
, &defaultLocation
, &dialogOptions
, &eventProc
, NULL
, &filterProc
, NULL
, NULL
, NULL
))
653 err
= NavChooseFolder(defaultLocation
, &reply
, &dialogOptions
,
654 eventProc
, filterProc
, (void *)dict
);
655 PyMem_XDEL(defaultLocation
);
657 PyErr_Mac(ErrorObject
, err
);
660 return (PyObject
*)newnavrrobject(&reply
);
663 static char nav_NavChooseVolume__doc__
[] =
664 "(DialogOptions dict or kwargs+defaultLocation,eventProc,filterProc) -> NavReplyRecord"
668 nav_NavChooseVolume(self
, args
, kw
)
669 PyObject
*self
; /* Not used */
674 AEDesc
*defaultLocation
= NULL
;
675 NavReplyRecord reply
;
676 NavDialogOptions dialogOptions
;
677 NavEventUPP eventProc
= NULL
;
678 NavObjectFilterUPP filterProc
= NULL
;
682 if (!PyArg_ParseTuple(args
, ""))
685 } else if (!PyArg_ParseTuple(args
, "O!", &PyDict_Type
, &dict
))
687 if (!filldialogoptions(dict
, &defaultLocation
, &dialogOptions
, &eventProc
, NULL
, &filterProc
, NULL
, NULL
, NULL
))
689 err
= NavChooseVolume(defaultLocation
, &reply
, &dialogOptions
,
690 eventProc
, filterProc
, (void *)dict
);
691 PyMem_XDEL(defaultLocation
);
693 PyErr_Mac(ErrorObject
, err
);
696 return (PyObject
*)newnavrrobject(&reply
);
699 static char nav_NavChooseObject__doc__
[] =
700 "(DialogOptions dict or kwargs+defaultLocation,eventProc,filterProc) -> NavReplyRecord"
704 nav_NavChooseObject(self
, args
, kw
)
705 PyObject
*self
; /* Not used */
710 AEDesc
*defaultLocation
= NULL
;
711 NavReplyRecord reply
;
712 NavDialogOptions dialogOptions
;
713 NavEventUPP eventProc
= NULL
;
714 NavObjectFilterUPP filterProc
= NULL
;
718 if (!PyArg_ParseTuple(args
, ""))
721 } else if (!PyArg_ParseTuple(args
, "O!", &PyDict_Type
, &dict
))
723 if (!filldialogoptions(dict
, &defaultLocation
, &dialogOptions
, &eventProc
, NULL
, &filterProc
, NULL
, NULL
, NULL
))
725 err
= NavChooseObject(defaultLocation
, &reply
, &dialogOptions
,
726 eventProc
, filterProc
, (void *)dict
);
727 PyMem_XDEL(defaultLocation
);
729 PyErr_Mac(ErrorObject
, err
);
732 return (PyObject
*)newnavrrobject(&reply
);
735 static char nav_NavNewFolder__doc__
[] =
736 "(DialogOptions dict or kwargs+defaultLocation,eventProc) -> NavReplyRecord"
740 nav_NavNewFolder(self
, args
, kw
)
741 PyObject
*self
; /* Not used */
746 AEDesc
*defaultLocation
= NULL
;
747 NavReplyRecord reply
;
748 NavDialogOptions dialogOptions
;
749 NavEventUPP eventProc
= NULL
;
753 if (!PyArg_ParseTuple(args
, ""))
756 } else if (!PyArg_ParseTuple(args
, "O!", &PyDict_Type
, &dict
))
758 if (!filldialogoptions(dict
, &defaultLocation
, &dialogOptions
, &eventProc
, NULL
, NULL
, NULL
, NULL
, NULL
))
760 err
= NavNewFolder(defaultLocation
, &reply
, &dialogOptions
, eventProc
, (void *)dict
);
761 PyMem_XDEL(defaultLocation
);
763 PyErr_Mac(ErrorObject
, err
);
766 return (PyObject
*)newnavrrobject(&reply
);
770 XXXX I don
't know what to do with the void * argument
771 static char nav_NavCustomControl__doc__[] =
777 nav_NavCustomControl(self, args)
778 PyObject *self; /* Not used */
782 if (!PyArg_ParseTuple(args, ""))
789 static char nav_NavServicesCanRun__doc__[] =
794 nav_NavServicesCanRun(self, args)
795 PyObject *self; /* Not used */
799 if (!PyArg_ParseTuple(args, ""))
801 rv = NavServicesCanRun();
802 return Py_BuildValue("l", (long)rv);
805 static char nav_NavServicesAvailable__doc__[] =
810 nav_NavServicesAvailable(self, args)
811 PyObject *self; /* Not used */
816 if (!PyArg_ParseTuple(args, ""))
818 rv = NavServicesAvailable();
819 return Py_BuildValue("l", (long)rv);
822 static char nav_NavLoad__doc__[] =
827 nav_NavLoad(self, args)
828 PyObject *self; /* Not used */
832 if (!PyArg_ParseTuple(args, ""))
839 static char nav_NavUnload__doc__[] =
844 nav_NavUnload(self, args)
845 PyObject *self; /* Not used */
849 if (!PyArg_ParseTuple(args, ""))
856 static char nav_NavLibraryVersion__doc__[] =
861 nav_NavLibraryVersion(self, args)
862 PyObject *self; /* Not used */
867 if (!PyArg_ParseTuple(args, ""))
869 rv = NavLibraryVersion();
870 return Py_BuildValue("l", (long)rv);
873 static char nav_NavGetDefaultDialogOptions__doc__[] =
874 "()->dict\nPass dict or keyword args with same names to other calls."
878 nav_NavGetDefaultDialogOptions(self, args)
879 PyObject *self; /* Not used */
882 NavDialogOptions dialogOptions;
885 err = NavGetDefaultDialogOptions(&dialogOptions);
887 PyErr_Mac(ErrorObject, err);
890 return Py_BuildValue("{s:h,s:l,s:O&,s:O&,s:O&,s:O&,s:O&,s:O&,s:O&,s:O&,s:O&}",
891 "version", dialogOptions.version,
892 "dialogOptionFlags", dialogOptions.dialogOptionFlags,
893 "location", PyMac_BuildPoint, dialogOptions.location,
894 "clientName", PyMac_BuildStr255, &dialogOptions.clientName,
895 "windowTitle", PyMac_BuildStr255, &dialogOptions.windowTitle,
896 "actionButtonLabel", PyMac_BuildStr255, &dialogOptions.actionButtonLabel,
897 "cancelButtonLabel", PyMac_BuildStr255, &dialogOptions.cancelButtonLabel,
898 "savedFileName", PyMac_BuildStr255, &dialogOptions.savedFileName,
899 "message", PyMac_BuildStr255, &dialogOptions.message,
900 "preferenceKey", PyMac_BuildOSType, dialogOptions.preferenceKey,
901 "popupExtension", OptResObj_New, dialogOptions.popupExtension);
904 /* List of methods defined in the module */
906 static struct PyMethodDef nav_methods[] = {
907 {"NavGetFile", (PyCFunction)nav_NavGetFile, METH_VARARGS|METH_KEYWORDS, nav_NavGetFile__doc__},
908 {"NavPutFile", (PyCFunction)nav_NavPutFile, METH_VARARGS|METH_KEYWORDS, nav_NavPutFile__doc__},
909 {"NavAskSaveChanges", (PyCFunction)nav_NavAskSaveChanges, METH_VARARGS|METH_KEYWORDS, nav_NavAskSaveChanges__doc__},
910 {"NavCustomAskSaveChanges", (PyCFunction)nav_NavCustomAskSaveChanges, METH_VARARGS|METH_KEYWORDS, nav_NavCustomAskSaveChanges__doc__},
911 {"NavAskDiscardChanges", (PyCFunction)nav_NavAskDiscardChanges, METH_VARARGS|METH_KEYWORDS, nav_NavAskDiscardChanges__doc__},
912 {"NavChooseFile", (PyCFunction)nav_NavChooseFile, METH_VARARGS|METH_KEYWORDS, nav_NavChooseFile__doc__},
913 {"NavChooseFolder", (PyCFunction)nav_NavChooseFolder, METH_VARARGS|METH_KEYWORDS, nav_NavChooseFolder__doc__},
914 {"NavChooseVolume", (PyCFunction)nav_NavChooseVolume, METH_VARARGS|METH_KEYWORDS, nav_NavChooseVolume__doc__},
915 {"NavChooseObject", (PyCFunction)nav_NavChooseObject, METH_VARARGS|METH_KEYWORDS, nav_NavChooseObject__doc__},
916 {"NavNewFolder", (PyCFunction)nav_NavNewFolder, METH_VARARGS|METH_KEYWORDS, nav_NavNewFolder__doc__},
918 {"NavCustomControl", (PyCFunction)nav_NavCustomControl, METH_VARARGS, nav_NavCustomControl__doc__},
920 {"NavServicesCanRun", (PyCFunction)nav_NavServicesCanRun, METH_VARARGS, nav_NavServicesCanRun__doc__},
921 {"NavServicesAvailable", (PyCFunction)nav_NavServicesAvailable, METH_VARARGS, nav_NavServicesAvailable__doc__},
922 {"NavLoad", (PyCFunction)nav_NavLoad, METH_VARARGS, nav_NavLoad__doc__},
923 {"NavUnload", (PyCFunction)nav_NavUnload, METH_VARARGS, nav_NavUnload__doc__},
924 {"NavLibraryVersion", (PyCFunction)nav_NavLibraryVersion, METH_VARARGS, nav_NavLibraryVersion__doc__},
925 {"NavGetDefaultDialogOptions", (PyCFunction)nav_NavGetDefaultDialogOptions, METH_VARARGS, nav_NavGetDefaultDialogOptions__doc__},
926 {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
930 /* Initialization function for the module (*must* be called initNav) */
932 static char Nav_module_documentation[] =
933 "Interface to Navigation Services\n"
934 "Most calls accept a NavDialogOptions dictionary or keywords with the same names, pass {}\n"
935 "if you want the default options.\n"
936 "Use NavGetDefaultDialogOptions() to find out common option names.\n"
937 "See individual docstrings for additional keyword args/dictentries supported by each call.\n"
938 "Pass None as eventProc to get movable-modal dialogs that process updates through the standard Python mechanism."
946 /* Create the module and add the functions */
947 m = Py_InitModule4("Nav", nav_methods,
948 Nav_module_documentation,
949 (PyObject*)NULL,PYTHON_API_VERSION);
951 /* Add some symbolic constants to the module */
952 d = PyModule_GetDict(m);
953 ErrorObject = PyString_FromString("Nav.error");
954 PyDict_SetItemString(d, "error", ErrorObject);
956 /* XXXX Add constants here */
959 my_eventProcUPP = NewNavEventProc(my_eventProc);
960 my_previewProcUPP = NewNavPreviewProc(my_previewProc);
961 my_filterProcUPP = NewNavObjectFilterProc(my_filterProc);
963 /* Check for errors */
964 if (PyErr_Occurred())
965 Py_FatalError("can't initialize module Nav
");