diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-11-22 23:39:52 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-11-22 23:39:52 (GMT) |
commit | 4b5c7a4f473cd3c7b99fd195b285aeba5e3c484a (patch) | |
tree | c30c97155771112bad69ccfb2d21c17c5f10735a /Mac | |
parent | 8d4c9817a2b7296b3ed828f2e455638604dc60d3 (diff) | |
download | cpython-4b5c7a4f473cd3c7b99fd195b285aeba5e3c484a.zip cpython-4b5c7a4f473cd3c7b99fd195b285aeba5e3c484a.tar.gz cpython-4b5c7a4f473cd3c7b99fd195b285aeba5e3c484a.tar.bz2 |
Allow access to the returned value(s) as FSRefs. Unfortunately for some
reason getting at saveFileName doesn't work, so it currently only really
works for opening files for reading.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Modules/Nav.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/Mac/Modules/Nav.c b/Mac/Modules/Nav.c index 7dfe3e5..d9ca42a 100644 --- a/Mac/Modules/Nav.c +++ b/Mac/Modules/Nav.c @@ -316,10 +316,12 @@ static PyObject * navrr_getattr(navrrobject *self, char *name) { FSSpec fss; + FSRef fsr; if( strcmp(name, "__members__") == 0 ) - return Py_BuildValue("sssssss", "version", "validRecord", "replacing", - "isStationery", "translationNeeded", "selection", "fileTranslation"); + return Py_BuildValue("ssssssssss", "version", "validRecord", "replacing", + "isStationery", "translationNeeded", "selection", "selection_fsr", + "fileTranslation", "keyScript", "saveFileName"); if( strcmp(name, "version") == 0 ) return Py_BuildValue("h", self->itself.version); if( strcmp(name, "validRecord") == 0 ) @@ -364,8 +366,42 @@ navrr_getattr(navrrobject *self, char *name) } return rv; } + if( strcmp(name, "selection_fsr") == 0 ) { + SInt32 i, count; + OSErr err; + PyObject *rv, *rvitem; + AEDesc desc; + + if (err=AECountItems(&self->itself.selection, &count)) { + PyErr_Mac(ErrorObject, err); + return NULL; + } + if ( (rv=PyList_New(count)) == NULL ) + return NULL; + for(i=0; i<count; i++) { + desc.dataHandle = NULL; + if (err=AEGetNthDesc(&self->itself.selection, i+1, typeFSRef, NULL, &desc)) { + Py_DECREF(rv); + PyErr_Mac(ErrorObject, err); + return NULL; + } + if (err=AEGetDescData(&desc, &fsr, sizeof(FSRef))) { + Py_DECREF(rv); + PyErr_Mac(ErrorObject, err); + return NULL; + } + rvitem = PyMac_BuildFSRef(&fsr); + PyList_SetItem(rv, i, rvitem); + AEDisposeDesc(&desc); + } + return rv; + } if( strcmp(name, "fileTranslation") == 0 ) return ResObj_New((Handle)self->itself.fileTranslation); + if( strcmp(name, "keyScript") == 0 ) + return Py_BuildValue("h", (short)self->itself.keyScript); + if( strcmp(name, "saveFileName") == 0 ) + return Py_BuildValue("O&", CFStringRefObj_New, self->itself.saveFileName); return Py_FindMethod(navrr_methods, (PyObject *)self, name); |