| 1 | /***********************************************************
|
|---|
| 2 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
|
|---|
| 3 | The Netherlands.
|
|---|
| 4 |
|
|---|
| 5 | All Rights Reserved
|
|---|
| 6 |
|
|---|
| 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
|
|---|
| 15 | permission.
|
|---|
| 16 |
|
|---|
| 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.
|
|---|
| 20 |
|
|---|
| 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.
|
|---|
| 29 |
|
|---|
| 30 | ******************************************************************/
|
|---|
| 31 |
|
|---|
| 32 | #include "Python.h"
|
|---|
| 33 | #include "pymactoolbox.h"
|
|---|
| 34 | #include <Carbon/Carbon.h>
|
|---|
| 35 |
|
|---|
| 36 | static PyObject *ErrorObject;
|
|---|
| 37 |
|
|---|
| 38 | static NavEventUPP my_eventProcUPP;
|
|---|
| 39 | static NavPreviewUPP my_previewProcUPP;
|
|---|
| 40 | static NavObjectFilterUPP my_filterProcUPP;
|
|---|
| 41 |
|
|---|
| 42 | /* Callback functions */
|
|---|
| 43 | static pascal void
|
|---|
| 44 | my_eventProc(NavEventCallbackMessage callBackSelector,
|
|---|
| 45 | NavCBRecPtr callBackParms,
|
|---|
| 46 | NavCallBackUserData callbackUD)
|
|---|
| 47 | {
|
|---|
| 48 | PyObject *dict = (PyObject *)callbackUD;
|
|---|
| 49 | PyObject *pyfunc;
|
|---|
| 50 | PyObject *rv;
|
|---|
| 51 |
|
|---|
| 52 | if (!dict) return;
|
|---|
| 53 | if ( (pyfunc = PyDict_GetItemString(dict, "eventProc")) == NULL ) {
|
|---|
| 54 | PyErr_Print();
|
|---|
| 55 | return;
|
|---|
| 56 | }
|
|---|
| 57 | if ( pyfunc == Py_None ) {
|
|---|
| 58 | return;
|
|---|
| 59 | }
|
|---|
| 60 | rv = PyObject_CallFunction(pyfunc, "ls#", (long)callBackSelector,
|
|---|
| 61 | (void *)callBackParms, sizeof(NavCBRec));
|
|---|
| 62 | if ( rv )
|
|---|
| 63 | Py_DECREF(rv);
|
|---|
| 64 | else {
|
|---|
| 65 | PySys_WriteStderr("Nav: exception in eventProc callback\n");
|
|---|
| 66 | PyErr_Print();
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | static pascal Boolean
|
|---|
| 71 | my_previewProc(NavCBRecPtr callBackParms,
|
|---|
| 72 | NavCallBackUserData callbackUD)
|
|---|
| 73 | {
|
|---|
| 74 | PyObject *dict = (PyObject *)callbackUD;
|
|---|
| 75 | PyObject *pyfunc;
|
|---|
| 76 | PyObject *rv;
|
|---|
| 77 | Boolean c_rv = false;
|
|---|
| 78 |
|
|---|
| 79 | if (!dict) return false;
|
|---|
| 80 | if ( (pyfunc = PyDict_GetItemString(dict, "previewProc")) == NULL ) {
|
|---|
| 81 | PyErr_Print();
|
|---|
| 82 | return false;
|
|---|
| 83 | }
|
|---|
| 84 | rv = PyObject_CallFunction(pyfunc, "s#", (void *)callBackParms, sizeof(NavCBRec));
|
|---|
| 85 | if ( rv ) {
|
|---|
| 86 | c_rv = PyObject_IsTrue(rv);
|
|---|
| 87 | Py_DECREF(rv);
|
|---|
| 88 | } else {
|
|---|
| 89 | PySys_WriteStderr("Nav: exception in previewProc callback\n");
|
|---|
| 90 | PyErr_Print();
|
|---|
| 91 | }
|
|---|
| 92 | return c_rv;
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | static pascal Boolean
|
|---|
| 96 | my_filterProc(AEDesc *theItem, void *info,
|
|---|
| 97 | NavCallBackUserData callbackUD,
|
|---|
| 98 | NavFilterModes filterMode)
|
|---|
| 99 | {
|
|---|
| 100 | PyObject *dict = (PyObject *)callbackUD;
|
|---|
| 101 | PyObject *pyfunc;
|
|---|
| 102 | PyObject *rv;
|
|---|
| 103 | Boolean c_rv = false;
|
|---|
| 104 |
|
|---|
| 105 | if (!dict) return false;
|
|---|
| 106 | if ( (pyfunc = PyDict_GetItemString(dict, "filterProc")) == NULL ) {
|
|---|
| 107 | PyErr_Print();
|
|---|
| 108 | return false;
|
|---|
| 109 | }
|
|---|
| 110 | rv = PyObject_CallFunction(pyfunc, "O&s#h",
|
|---|
| 111 | AEDesc_NewBorrowed, theItem, info, sizeof(NavFileOrFolderInfo), (short)filterMode);
|
|---|
| 112 | if ( rv ) {
|
|---|
| 113 | c_rv = PyObject_IsTrue(rv);
|
|---|
| 114 | Py_DECREF(rv);
|
|---|
| 115 | } else {
|
|---|
| 116 | PySys_WriteStderr("Nav: exception in filterProc callback\n");
|
|---|
| 117 | PyErr_Print();
|
|---|
| 118 | }
|
|---|
| 119 | return c_rv;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | /* ----------------------------------------------------- */
|
|---|
| 123 | static int
|
|---|
| 124 | filldialogoptions(PyObject *d,
|
|---|
| 125 | AEDesc **defaultLocationP,
|
|---|
| 126 | NavDialogOptions *opt,
|
|---|
| 127 | NavEventUPP *eventProcP,
|
|---|
| 128 | NavPreviewUPP *previewProcP,
|
|---|
| 129 | NavObjectFilterUPP *filterProcP,
|
|---|
| 130 | NavTypeListHandle *typeListP,
|
|---|
| 131 | OSType *fileTypeP,
|
|---|
| 132 | OSType *fileCreatorP)
|
|---|
| 133 | {
|
|---|
| 134 | Py_ssize_t pos = 0;
|
|---|
| 135 | PyObject *key, *value;
|
|---|
| 136 | char *keystr;
|
|---|
| 137 | AEDesc *defaultLocation_storage;
|
|---|
| 138 |
|
|---|
| 139 | NavGetDefaultDialogOptions(opt);
|
|---|
| 140 |
|
|---|
| 141 | while ( PyDict_Next(d, &pos, &key, &value) ) {
|
|---|
| 142 | if ( !key || !value || !PyString_Check(key) ) {
|
|---|
| 143 | PyErr_SetString(ErrorObject, "DialogOption has non-string key");
|
|---|
| 144 | return 0;
|
|---|
| 145 | }
|
|---|
| 146 | keystr = PyString_AsString(key);
|
|---|
| 147 | if( strcmp(keystr, "defaultLocation") == 0 ) {
|
|---|
| 148 | if ( (defaultLocation_storage = PyMem_NEW(AEDesc, 1)) == NULL ) {
|
|---|
| 149 | PyErr_NoMemory();
|
|---|
| 150 | return 0;
|
|---|
| 151 | }
|
|---|
| 152 | if ( !PyArg_Parse(value, "O&", AEDesc_Convert, defaultLocation_storage) ) {
|
|---|
| 153 | PyMem_DEL(defaultLocation_storage);
|
|---|
| 154 | return 0;
|
|---|
| 155 | }
|
|---|
| 156 | *defaultLocationP = defaultLocation_storage;
|
|---|
| 157 | } else if( strcmp(keystr, "version") == 0 ) {
|
|---|
| 158 | if ( !PyArg_Parse(value, "H", &opt->version) )
|
|---|
| 159 | return 0;
|
|---|
| 160 | } else if( strcmp(keystr, "dialogOptionFlags") == 0 ) {
|
|---|
| 161 | if ( !PyArg_Parse(value, "k", &opt->dialogOptionFlags) )
|
|---|
| 162 | return 0;
|
|---|
| 163 | } else if( strcmp(keystr, "location") == 0 ) {
|
|---|
| 164 | if ( !PyArg_Parse(value, "O&", PyMac_GetPoint, &opt->location) )
|
|---|
| 165 | return 0;
|
|---|
| 166 | } else if( strcmp(keystr, "clientName") == 0 ) {
|
|---|
| 167 | if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->clientName) )
|
|---|
| 168 | return 0;
|
|---|
| 169 | } else if( strcmp(keystr, "windowTitle") == 0 ) {
|
|---|
| 170 | if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->windowTitle) )
|
|---|
| 171 | return 0;
|
|---|
| 172 | } else if( strcmp(keystr, "actionButtonLabel") == 0 ) {
|
|---|
| 173 | if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->actionButtonLabel) )
|
|---|
| 174 | return 0;
|
|---|
| 175 | } else if( strcmp(keystr, "cancelButtonLabel") == 0 ) {
|
|---|
| 176 | if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->cancelButtonLabel) )
|
|---|
| 177 | return 0;
|
|---|
| 178 | } else if( strcmp(keystr, "savedFileName") == 0 ) {
|
|---|
| 179 | if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->savedFileName) )
|
|---|
| 180 | return 0;
|
|---|
| 181 | } else if( strcmp(keystr, "message") == 0 ) {
|
|---|
| 182 | if ( !PyArg_Parse(value, "O&", PyMac_GetStr255, &opt->message) )
|
|---|
| 183 | return 0;
|
|---|
| 184 | } else if( strcmp(keystr, "preferenceKey") == 0 ) {
|
|---|
| 185 | if ( !PyArg_Parse(value, "O&", PyMac_GetOSType, &opt->preferenceKey) )
|
|---|
| 186 | return 0;
|
|---|
| 187 | } else if( strcmp(keystr, "popupExtension") == 0 ) {
|
|---|
| 188 | if ( !PyArg_Parse(value, "O&", ResObj_Convert, &opt->popupExtension) )
|
|---|
| 189 | return 0;
|
|---|
| 190 | } else if( eventProcP && strcmp(keystr, "eventProc") == 0 ) {
|
|---|
| 191 | *eventProcP = my_eventProcUPP;
|
|---|
| 192 | } else if( previewProcP && strcmp(keystr, "previewProc") == 0 ) {
|
|---|
| 193 | *previewProcP = my_previewProcUPP;
|
|---|
| 194 | } else if( filterProcP && strcmp(keystr, "filterProc") == 0 ) {
|
|---|
| 195 | *filterProcP = my_filterProcUPP;
|
|---|
| 196 | } else if( typeListP && strcmp(keystr, "typeList") == 0 ) {
|
|---|
| 197 | if ( !PyArg_Parse(value, "O&", ResObj_Convert, typeListP) )
|
|---|
| 198 | return 0;
|
|---|
| 199 | } else if( fileTypeP && strcmp(keystr, "fileType") == 0 ) {
|
|---|
| 200 | if ( !PyArg_Parse(value, "O&", PyMac_GetOSType, fileTypeP) )
|
|---|
| 201 | return 0;
|
|---|
| 202 | } else if( fileCreatorP && strcmp(keystr, "fileCreator") == 0 ) {
|
|---|
| 203 | if ( !PyArg_Parse(value, "O&", PyMac_GetOSType, fileCreatorP) )
|
|---|
| 204 | return 0;
|
|---|
| 205 | } else {
|
|---|
| 206 | PyErr_Format(ErrorObject, "Unknown DialogOption key: %s", keystr);
|
|---|
| 207 | return 0;
|
|---|
| 208 | }
|
|---|
| 209 | }
|
|---|
| 210 | return 1;
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | /* ----------------------------------------------------- */
|
|---|
| 214 |
|
|---|
| 215 | /* Declarations for objects of type NavReplyRecord */
|
|---|
| 216 |
|
|---|
| 217 | typedef struct {
|
|---|
| 218 | PyObject_HEAD
|
|---|
| 219 | NavReplyRecord itself;
|
|---|
| 220 | } navrrobject;
|
|---|
| 221 |
|
|---|
| 222 | static PyTypeObject Navrrtype;
|
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 | /* ---------------------------------------------------------------- */
|
|---|
| 227 |
|
|---|
| 228 | static char nav_NavTranslateFile__doc__[] =
|
|---|
| 229 | "(NavTranslationOptions)->None"
|
|---|
| 230 | ;
|
|---|
| 231 |
|
|---|
| 232 | static PyObject *
|
|---|
| 233 | nav_NavTranslateFile(navrrobject *self, PyObject *args)
|
|---|
| 234 | {
|
|---|
| 235 | NavTranslationOptions howToTranslate;
|
|---|
| 236 | OSErr err;
|
|---|
| 237 |
|
|---|
| 238 | if (!PyArg_ParseTuple(args, "k", &howToTranslate))
|
|---|
| 239 | return NULL;
|
|---|
| 240 | err = NavTranslateFile(&self->itself, howToTranslate);
|
|---|
| 241 | if ( err ) {
|
|---|
| 242 | PyErr_Mac(ErrorObject, err);
|
|---|
| 243 | return NULL;
|
|---|
| 244 | }
|
|---|
| 245 | Py_INCREF(Py_None);
|
|---|
| 246 | return Py_None;
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 | static char nav_NavCompleteSave__doc__[] =
|
|---|
| 250 | "(NavTranslationOptions)->None"
|
|---|
| 251 | ;
|
|---|
| 252 |
|
|---|
| 253 | static PyObject *
|
|---|
| 254 | nav_NavCompleteSave(navrrobject *self, PyObject *args)
|
|---|
| 255 | {
|
|---|
| 256 | NavTranslationOptions howToTranslate;
|
|---|
| 257 | OSErr err;
|
|---|
| 258 |
|
|---|
| 259 | if (!PyArg_ParseTuple(args, "k", &howToTranslate))
|
|---|
| 260 | return NULL;
|
|---|
| 261 | err = NavCompleteSave(&self->itself, howToTranslate);
|
|---|
| 262 | if ( err ) {
|
|---|
| 263 | PyErr_Mac(ErrorObject, err);
|
|---|
| 264 | return NULL;
|
|---|
| 265 | }
|
|---|
| 266 | Py_INCREF(Py_None);
|
|---|
| 267 | return Py_None;
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 | static struct PyMethodDef navrr_methods[] = {
|
|---|
| 272 | {"NavTranslateFile", (PyCFunction)nav_NavTranslateFile, METH_VARARGS, nav_NavTranslateFile__doc__},
|
|---|
| 273 | {"NavCompleteSave", (PyCFunction)nav_NavCompleteSave, METH_VARARGS, nav_NavCompleteSave__doc__},
|
|---|
| 274 |
|
|---|
| 275 | {NULL, NULL} /* sentinel */
|
|---|
| 276 | };
|
|---|
| 277 |
|
|---|
| 278 | /* ---------- */
|
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 | static navrrobject *
|
|---|
| 282 | newnavrrobject(NavReplyRecord *itself)
|
|---|
| 283 | {
|
|---|
| 284 | navrrobject *self;
|
|---|
| 285 |
|
|---|
| 286 | self = PyObject_NEW(navrrobject, &Navrrtype);
|
|---|
| 287 | if (self == NULL)
|
|---|
| 288 | return NULL;
|
|---|
| 289 | self->itself = *itself;
|
|---|
| 290 | return self;
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 | static void
|
|---|
| 295 | navrr_dealloc(navrrobject *self)
|
|---|
| 296 | {
|
|---|
| 297 | NavDisposeReply(&self->itself);
|
|---|
| 298 | PyObject_DEL(self);
|
|---|
| 299 | }
|
|---|
| 300 |
|
|---|
| 301 | static PyObject *
|
|---|
| 302 | navrr_getattr(navrrobject *self, char *name)
|
|---|
| 303 | {
|
|---|
| 304 | FSSpec fss;
|
|---|
| 305 | FSRef fsr;
|
|---|
| 306 |
|
|---|
| 307 | if( strcmp(name, "__members__") == 0 )
|
|---|
| 308 | return Py_BuildValue("ssssssssss", "version", "validRecord", "replacing",
|
|---|
| 309 | "isStationery", "translationNeeded", "selection", "selection_fsr",
|
|---|
| 310 | "fileTranslation", "keyScript", "saveFileName");
|
|---|
| 311 | if( strcmp(name, "version") == 0 )
|
|---|
| 312 | return Py_BuildValue("h", self->itself.version);
|
|---|
| 313 | if( strcmp(name, "validRecord") == 0 )
|
|---|
| 314 | return Py_BuildValue("l", (long)self->itself.validRecord);
|
|---|
| 315 | if( strcmp(name, "replacing") == 0 )
|
|---|
| 316 | return Py_BuildValue("l", (long)self->itself.replacing);
|
|---|
| 317 | if( strcmp(name, "isStationery") == 0 )
|
|---|
| 318 | return Py_BuildValue("l", (long)self->itself.isStationery);
|
|---|
| 319 | if( strcmp(name, "translationNeeded") == 0 )
|
|---|
| 320 | return Py_BuildValue("l", (long)self->itself.translationNeeded);
|
|---|
| 321 | if( strcmp(name, "selection") == 0 ) {
|
|---|
| 322 | SInt32 i, count;
|
|---|
| 323 | OSErr err;
|
|---|
| 324 | PyObject *rv, *rvitem;
|
|---|
| 325 | AEDesc desc;
|
|---|
| 326 |
|
|---|
| 327 | if ((err=AECountItems(&self->itself.selection, &count))) {
|
|---|
| 328 | PyErr_Mac(ErrorObject, err);
|
|---|
| 329 | return NULL;
|
|---|
| 330 | }
|
|---|
| 331 | if ( (rv=PyList_New(count)) == NULL )
|
|---|
| 332 | return NULL;
|
|---|
| 333 | for(i=0; i<count; i++) {
|
|---|
| 334 | desc.dataHandle = NULL;
|
|---|
| 335 | if ((err=AEGetNthDesc(&self->itself.selection, i+1, typeFSS, NULL, &desc))) {
|
|---|
| 336 | Py_DECREF(rv);
|
|---|
| 337 | PyErr_Mac(ErrorObject, err);
|
|---|
| 338 | return NULL;
|
|---|
| 339 | }
|
|---|
| 340 | if ((err=AEGetDescData(&desc, &fss, sizeof(FSSpec)))) {
|
|---|
| 341 | Py_DECREF(rv);
|
|---|
| 342 | PyErr_Mac(ErrorObject, err);
|
|---|
| 343 | return NULL;
|
|---|
| 344 | }
|
|---|
| 345 | rvitem = PyMac_BuildFSSpec(&fss);
|
|---|
| 346 | PyList_SetItem(rv, i, rvitem);
|
|---|
| 347 | AEDisposeDesc(&desc);
|
|---|
| 348 | }
|
|---|
| 349 | return rv;
|
|---|
| 350 | }
|
|---|
| 351 | if( strcmp(name, "selection_fsr") == 0 ) {
|
|---|
| 352 | SInt32 i, count;
|
|---|
| 353 | OSErr err;
|
|---|
| 354 | PyObject *rv, *rvitem;
|
|---|
| 355 | AEDesc desc;
|
|---|
| 356 |
|
|---|
| 357 | if ((err=AECountItems(&self->itself.selection, &count))) {
|
|---|
| 358 | PyErr_Mac(ErrorObject, err);
|
|---|
| 359 | return NULL;
|
|---|
| 360 | }
|
|---|
| 361 | if ( (rv=PyList_New(count)) == NULL )
|
|---|
| 362 | return NULL;
|
|---|
| 363 | for(i=0; i<count; i++) {
|
|---|
| 364 | desc.dataHandle = NULL;
|
|---|
| 365 | if ((err=AEGetNthDesc(&self->itself.selection, i+1, typeFSRef, NULL, &desc))) {
|
|---|
| 366 | Py_DECREF(rv);
|
|---|
| 367 | PyErr_Mac(ErrorObject, err);
|
|---|
| 368 | return NULL;
|
|---|
| 369 | }
|
|---|
| 370 | if ((err=AEGetDescData(&desc, &fsr, sizeof(FSRef)))) {
|
|---|
| 371 | Py_DECREF(rv);
|
|---|
| 372 | PyErr_Mac(ErrorObject, err);
|
|---|
| 373 | return NULL;
|
|---|
| 374 | }
|
|---|
| 375 | rvitem = PyMac_BuildFSRef(&fsr);
|
|---|
| 376 | PyList_SetItem(rv, i, rvitem);
|
|---|
| 377 | AEDisposeDesc(&desc);
|
|---|
| 378 | }
|
|---|
| 379 | return rv;
|
|---|
| 380 | }
|
|---|
| 381 | if( strcmp(name, "fileTranslation") == 0 )
|
|---|
| 382 | return ResObj_New((Handle)self->itself.fileTranslation);
|
|---|
| 383 | if( strcmp(name, "keyScript") == 0 )
|
|---|
| 384 | return Py_BuildValue("h", (short)self->itself.keyScript);
|
|---|
| 385 | if( strcmp(name, "saveFileName") == 0 )
|
|---|
| 386 | return Py_BuildValue("O&", CFStringRefObj_New, self->itself.saveFileName);
|
|---|
| 387 |
|
|---|
| 388 |
|
|---|
| 389 | return Py_FindMethod(navrr_methods, (PyObject *)self, name);
|
|---|
| 390 | }
|
|---|
| 391 |
|
|---|
| 392 | static int
|
|---|
| 393 | navrr_setattr(navrrobject *self, char *name, PyObject *v)
|
|---|
| 394 | {
|
|---|
| 395 | /* Set attribute 'name' to value 'v'. v==NULL means delete */
|
|---|
| 396 |
|
|---|
| 397 | /* XXXX Add your own setattr code here */
|
|---|
| 398 | return -1;
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | static char Navrrtype__doc__[] =
|
|---|
| 402 | "Record containing result of a Nav file selection call. Use dir() for member names."
|
|---|
| 403 | ;
|
|---|
| 404 |
|
|---|
| 405 | static PyTypeObject Navrrtype = {
|
|---|
| 406 | PyObject_HEAD_INIT(&PyType_Type)
|
|---|
| 407 | 0, /*ob_size*/
|
|---|
| 408 | "Nav.NavReplyRecord", /*tp_name*/
|
|---|
| 409 | sizeof(navrrobject), /*tp_basicsize*/
|
|---|
| 410 | 0, /*tp_itemsize*/
|
|---|
| 411 | /* methods */
|
|---|
| 412 | (destructor)navrr_dealloc, /*tp_dealloc*/
|
|---|
| 413 | (printfunc)0, /*tp_print*/
|
|---|
| 414 | (getattrfunc)navrr_getattr, /*tp_getattr*/
|
|---|
| 415 | (setattrfunc)navrr_setattr, /*tp_setattr*/
|
|---|
| 416 | (cmpfunc)0, /*tp_compare*/
|
|---|
| 417 | (reprfunc)0, /*tp_repr*/
|
|---|
| 418 | 0, /*tp_as_number*/
|
|---|
| 419 | 0, /*tp_as_sequence*/
|
|---|
| 420 | 0, /*tp_as_mapping*/
|
|---|
| 421 | (hashfunc)0, /*tp_hash*/
|
|---|
| 422 | (ternaryfunc)0, /*tp_call*/
|
|---|
| 423 | (reprfunc)0, /*tp_str*/
|
|---|
| 424 |
|
|---|
| 425 | /* Space for future expansion */
|
|---|
| 426 | 0L,0L,0L,0L,
|
|---|
| 427 | Navrrtype__doc__ /* Documentation string */
|
|---|
| 428 | };
|
|---|
| 429 |
|
|---|
| 430 | /* End of code for NavReplyRecord objects */
|
|---|
| 431 |
|
|---|
| 432 | /* ----------------------------------------------------- */
|
|---|
| 433 |
|
|---|
| 434 | static char nav_NavGetFile__doc__[] =
|
|---|
| 435 | "(DialogOptions dict or kwargs+defaultLocation,eventProc,previewProc,filterProc,typeList) -> NavReplyRecord"
|
|---|
| 436 | ;
|
|---|
| 437 |
|
|---|
| 438 | static PyObject *
|
|---|
| 439 | nav_NavGetFile(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 440 | {
|
|---|
| 441 | PyObject *dict;
|
|---|
| 442 | AEDesc *defaultLocation = NULL;
|
|---|
| 443 | NavReplyRecord reply;
|
|---|
| 444 | NavDialogOptions dialogOptions;
|
|---|
| 445 | NavEventUPP eventProc = NULL;
|
|---|
| 446 | NavPreviewUPP previewProc = NULL;
|
|---|
| 447 | NavObjectFilterUPP filterProc = NULL;
|
|---|
| 448 | NavTypeListHandle typeList = NULL;
|
|---|
| 449 | OSErr err;
|
|---|
| 450 |
|
|---|
| 451 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 452 | if (!PyArg_ParseTuple(args, ";either keyword arguments or dictionary expected"))
|
|---|
| 453 | return NULL;
|
|---|
| 454 | dict = kw;
|
|---|
| 455 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
|
|---|
| 456 | return NULL;
|
|---|
| 457 | if (!filldialogoptions(dict, &defaultLocation, &dialogOptions, &eventProc, &previewProc, &filterProc, &typeList, NULL, NULL))
|
|---|
| 458 | return NULL;
|
|---|
| 459 | err = NavGetFile(defaultLocation, &reply, &dialogOptions,
|
|---|
| 460 | eventProc, previewProc, filterProc, typeList, (void *)dict);
|
|---|
| 461 | PyMem_DEL(defaultLocation);
|
|---|
| 462 | if ( err ) {
|
|---|
| 463 | PyErr_Mac(ErrorObject, err);
|
|---|
| 464 | return NULL;
|
|---|
| 465 | }
|
|---|
| 466 | return (PyObject *)newnavrrobject(&reply);
|
|---|
| 467 | }
|
|---|
| 468 |
|
|---|
| 469 | static char nav_NavPutFile__doc__[] =
|
|---|
| 470 | "(DialogOptions dict or kwargs+defaultLocation,eventProc,fileCreator,fileType) -> NavReplyRecord"
|
|---|
| 471 | ;
|
|---|
| 472 |
|
|---|
| 473 | static PyObject *
|
|---|
| 474 | nav_NavPutFile(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 475 | {
|
|---|
| 476 | PyObject *dict;
|
|---|
| 477 | AEDesc *defaultLocation = NULL;
|
|---|
| 478 | NavReplyRecord reply;
|
|---|
| 479 | NavDialogOptions dialogOptions;
|
|---|
| 480 | NavEventUPP eventProc = NULL;
|
|---|
| 481 | OSType fileType;
|
|---|
| 482 | OSType fileCreator;
|
|---|
| 483 | OSErr err;
|
|---|
| 484 |
|
|---|
| 485 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 486 | if (!PyArg_ParseTuple(args, ";either keyword arguments or dictionary expected"))
|
|---|
| 487 | return NULL;
|
|---|
| 488 | dict = kw;
|
|---|
| 489 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
|
|---|
| 490 | return NULL;
|
|---|
| 491 | if (!filldialogoptions(dict, &defaultLocation, &dialogOptions, &eventProc, NULL, NULL, NULL, &fileType, &fileCreator))
|
|---|
| 492 | return NULL;
|
|---|
| 493 | err = NavPutFile(defaultLocation, &reply, &dialogOptions,
|
|---|
| 494 | eventProc, fileType, fileCreator, (void *)dict);
|
|---|
| 495 | PyMem_DEL(defaultLocation);
|
|---|
| 496 | if ( err ) {
|
|---|
| 497 | PyErr_Mac(ErrorObject, err);
|
|---|
| 498 | return NULL;
|
|---|
| 499 | }
|
|---|
| 500 | return (PyObject *)newnavrrobject(&reply);
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | static char nav_NavAskSaveChanges__doc__[] =
|
|---|
| 504 | "(NavAskSaveChangesAction, DialogOptions dict or kwargs+eventProc) -> NavAskSaveChangesResult"
|
|---|
| 505 |
|
|---|
| 506 | ;
|
|---|
| 507 |
|
|---|
| 508 | static PyObject *
|
|---|
| 509 | nav_NavAskSaveChanges(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 510 | {
|
|---|
| 511 | PyObject *dict;
|
|---|
| 512 | NavDialogOptions dialogOptions;
|
|---|
| 513 | NavAskSaveChangesAction action;
|
|---|
| 514 | NavAskSaveChangesResult reply;
|
|---|
| 515 | NavEventUPP eventProc = NULL;
|
|---|
| 516 | OSErr err;
|
|---|
| 517 |
|
|---|
| 518 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 519 | if (!PyArg_ParseTuple(args, "k", &action))
|
|---|
| 520 | return NULL;
|
|---|
| 521 | dict = kw;
|
|---|
| 522 | } else if (!PyArg_ParseTuple(args, "lO!", &action, &PyDict_Type, &dict))
|
|---|
| 523 | return NULL;
|
|---|
| 524 | if (!filldialogoptions(dict, NULL, &dialogOptions, &eventProc, NULL, NULL, NULL, NULL, NULL))
|
|---|
| 525 | return NULL;
|
|---|
| 526 | err = NavAskSaveChanges(&dialogOptions, action, &reply, eventProc, (void *)dict);
|
|---|
| 527 | if ( err ) {
|
|---|
| 528 | PyErr_Mac(ErrorObject, err);
|
|---|
| 529 | return NULL;
|
|---|
| 530 | }
|
|---|
| 531 | return Py_BuildValue("l", (long)reply);
|
|---|
| 532 | }
|
|---|
| 533 |
|
|---|
| 534 | static char nav_NavCustomAskSaveChanges__doc__[] =
|
|---|
| 535 | "(DialogOptions dict or kwargs+eventProc) -> NavAskSaveChangesResult"
|
|---|
| 536 | ;
|
|---|
| 537 |
|
|---|
| 538 | static PyObject *
|
|---|
| 539 | nav_NavCustomAskSaveChanges(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 540 | {
|
|---|
| 541 | PyObject *dict;
|
|---|
| 542 | NavDialogOptions dialogOptions;
|
|---|
| 543 | NavAskSaveChangesResult reply;
|
|---|
| 544 | NavEventUPP eventProc = NULL;
|
|---|
| 545 | OSErr err;
|
|---|
| 546 |
|
|---|
| 547 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 548 | if (!PyArg_ParseTuple(args, ";either keyword arguments or dictionary expected"))
|
|---|
| 549 | return NULL;
|
|---|
| 550 | dict = kw;
|
|---|
| 551 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
|
|---|
| 552 | return NULL;
|
|---|
| 553 | if (!filldialogoptions(dict, NULL, &dialogOptions, &eventProc, NULL, NULL, NULL, NULL, NULL))
|
|---|
| 554 | return NULL;
|
|---|
| 555 | err = NavCustomAskSaveChanges(&dialogOptions, &reply, eventProc, (void *)dict);
|
|---|
| 556 | if ( err ) {
|
|---|
| 557 | PyErr_Mac(ErrorObject, err);
|
|---|
| 558 | return NULL;
|
|---|
| 559 | }
|
|---|
| 560 | return Py_BuildValue("l", (long)reply);
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | static char nav_NavAskDiscardChanges__doc__[] =
|
|---|
| 564 | "(DialogOptions dict or kwargs+eventProc) -> NavAskSaveChangesResult"
|
|---|
| 565 | ;
|
|---|
| 566 |
|
|---|
| 567 | static PyObject *
|
|---|
| 568 | nav_NavAskDiscardChanges(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 569 | {
|
|---|
| 570 | PyObject *dict;
|
|---|
| 571 | NavDialogOptions dialogOptions;
|
|---|
| 572 | NavAskSaveChangesResult reply;
|
|---|
| 573 | NavEventUPP eventProc = NULL;
|
|---|
| 574 | OSErr err;
|
|---|
| 575 |
|
|---|
| 576 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 577 | if (!PyArg_ParseTuple(args, ";either keyword arguments or dictionary expected"))
|
|---|
| 578 | return NULL;
|
|---|
| 579 | dict = kw;
|
|---|
| 580 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
|
|---|
| 581 | return NULL;
|
|---|
| 582 | if (!filldialogoptions(dict, NULL, &dialogOptions, &eventProc, NULL, NULL, NULL, NULL, NULL))
|
|---|
| 583 | return NULL;
|
|---|
| 584 | err = NavAskDiscardChanges(&dialogOptions, &reply, eventProc, (void *)dict);
|
|---|
| 585 | if ( err ) {
|
|---|
| 586 | PyErr_Mac(ErrorObject, err);
|
|---|
| 587 | return NULL;
|
|---|
| 588 | }
|
|---|
| 589 | return Py_BuildValue("l", (long)reply);
|
|---|
| 590 | }
|
|---|
| 591 |
|
|---|
| 592 | static char nav_NavChooseFile__doc__[] =
|
|---|
| 593 | "(DialogOptions dict or kwargs+defaultLocation,eventProc,previewProc,filterProc,typeList) -> NavReplyRecord"
|
|---|
| 594 | ;
|
|---|
| 595 |
|
|---|
| 596 | static PyObject *
|
|---|
| 597 | nav_NavChooseFile(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 598 | {
|
|---|
| 599 | PyObject *dict;
|
|---|
| 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;
|
|---|
| 607 | OSErr err;
|
|---|
| 608 |
|
|---|
| 609 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 610 | if (!PyArg_ParseTuple(args, ";either keyword arguments or dictionary expected"))
|
|---|
| 611 | return NULL;
|
|---|
| 612 | dict = kw;
|
|---|
| 613 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
|
|---|
| 614 | return NULL;
|
|---|
| 615 | if (!filldialogoptions(dict, &defaultLocation, &dialogOptions, &eventProc, &previewProc, &filterProc, &typeList, NULL, NULL))
|
|---|
| 616 | return NULL;
|
|---|
| 617 | err = NavChooseFile(defaultLocation, &reply, &dialogOptions,
|
|---|
| 618 | eventProc, previewProc, filterProc, typeList, (void *)dict);
|
|---|
| 619 | PyMem_DEL(defaultLocation);
|
|---|
| 620 | if ( err ) {
|
|---|
| 621 | PyErr_Mac(ErrorObject, err);
|
|---|
| 622 | return NULL;
|
|---|
| 623 | }
|
|---|
| 624 | return (PyObject *)newnavrrobject(&reply);
|
|---|
| 625 | }
|
|---|
| 626 |
|
|---|
| 627 | static char nav_NavChooseFolder__doc__[] =
|
|---|
| 628 | "(DialogOptions dict or kwargs+defaultLocation,eventProc,filterProc) -> NavReplyRecord"
|
|---|
| 629 | ;
|
|---|
| 630 |
|
|---|
| 631 | static PyObject *
|
|---|
| 632 | nav_NavChooseFolder(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 633 | {
|
|---|
| 634 | PyObject *dict;
|
|---|
| 635 | AEDesc *defaultLocation = NULL;
|
|---|
| 636 | NavReplyRecord reply;
|
|---|
| 637 | NavDialogOptions dialogOptions;
|
|---|
| 638 | NavEventUPP eventProc = NULL;
|
|---|
| 639 | NavObjectFilterUPP filterProc = NULL;
|
|---|
| 640 | OSErr err;
|
|---|
| 641 |
|
|---|
| 642 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 643 | if (!PyArg_ParseTuple(args, ";either keyword arguments or dictionary expected"))
|
|---|
| 644 | return NULL;
|
|---|
| 645 | dict = kw;
|
|---|
| 646 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
|
|---|
| 647 | return NULL;
|
|---|
| 648 | if (!filldialogoptions(dict, &defaultLocation, &dialogOptions, &eventProc, NULL, &filterProc, NULL, NULL, NULL))
|
|---|
| 649 | return NULL;
|
|---|
| 650 | err = NavChooseFolder(defaultLocation, &reply, &dialogOptions,
|
|---|
| 651 | eventProc, filterProc, (void *)dict);
|
|---|
| 652 | PyMem_DEL(defaultLocation);
|
|---|
| 653 | if ( err ) {
|
|---|
| 654 | PyErr_Mac(ErrorObject, err);
|
|---|
| 655 | return NULL;
|
|---|
| 656 | }
|
|---|
| 657 | return (PyObject *)newnavrrobject(&reply);
|
|---|
| 658 | }
|
|---|
| 659 |
|
|---|
| 660 | static char nav_NavChooseVolume__doc__[] =
|
|---|
| 661 | "(DialogOptions dict or kwargs+defaultLocation,eventProc,filterProc) -> NavReplyRecord"
|
|---|
| 662 | ;
|
|---|
| 663 |
|
|---|
| 664 | static PyObject *
|
|---|
| 665 | nav_NavChooseVolume(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 666 | {
|
|---|
| 667 | PyObject *dict;
|
|---|
| 668 | AEDesc *defaultLocation = NULL;
|
|---|
| 669 | NavReplyRecord reply;
|
|---|
| 670 | NavDialogOptions dialogOptions;
|
|---|
| 671 | NavEventUPP eventProc = NULL;
|
|---|
| 672 | NavObjectFilterUPP filterProc = NULL;
|
|---|
| 673 | OSErr err;
|
|---|
| 674 |
|
|---|
| 675 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 676 | if (!PyArg_ParseTuple(args, ";either keyword arguments or dictionary expected"))
|
|---|
| 677 | return NULL;
|
|---|
| 678 | dict = kw;
|
|---|
| 679 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
|
|---|
| 680 | return NULL;
|
|---|
| 681 | if (!filldialogoptions(dict, &defaultLocation, &dialogOptions, &eventProc, NULL, &filterProc, NULL, NULL, NULL))
|
|---|
| 682 | return NULL;
|
|---|
| 683 | err = NavChooseVolume(defaultLocation, &reply, &dialogOptions,
|
|---|
| 684 | eventProc, filterProc, (void *)dict);
|
|---|
| 685 | PyMem_DEL(defaultLocation);
|
|---|
| 686 | if ( err ) {
|
|---|
| 687 | PyErr_Mac(ErrorObject, err);
|
|---|
| 688 | return NULL;
|
|---|
| 689 | }
|
|---|
| 690 | return (PyObject *)newnavrrobject(&reply);
|
|---|
| 691 | }
|
|---|
| 692 |
|
|---|
| 693 | static char nav_NavChooseObject__doc__[] =
|
|---|
| 694 | "(DialogOptions dict or kwargs+defaultLocation,eventProc,filterProc) -> NavReplyRecord"
|
|---|
| 695 | ;
|
|---|
| 696 |
|
|---|
| 697 | static PyObject *
|
|---|
| 698 | nav_NavChooseObject(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 699 | {
|
|---|
| 700 | PyObject *dict;
|
|---|
| 701 | AEDesc *defaultLocation = NULL;
|
|---|
| 702 | NavReplyRecord reply;
|
|---|
| 703 | NavDialogOptions dialogOptions;
|
|---|
| 704 | NavEventUPP eventProc = NULL;
|
|---|
| 705 | NavObjectFilterUPP filterProc = NULL;
|
|---|
| 706 | OSErr err;
|
|---|
| 707 |
|
|---|
| 708 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 709 | if (!PyArg_ParseTuple(args, ";either keyword arguments or dictionary expected"))
|
|---|
| 710 | return NULL;
|
|---|
| 711 | dict = kw;
|
|---|
| 712 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
|
|---|
| 713 | return NULL;
|
|---|
| 714 | if (!filldialogoptions(dict, &defaultLocation, &dialogOptions, &eventProc, NULL, &filterProc, NULL, NULL, NULL))
|
|---|
| 715 | return NULL;
|
|---|
| 716 | err = NavChooseObject(defaultLocation, &reply, &dialogOptions,
|
|---|
| 717 | eventProc, filterProc, (void *)dict);
|
|---|
| 718 | PyMem_DEL(defaultLocation);
|
|---|
| 719 | if ( err ) {
|
|---|
| 720 | PyErr_Mac(ErrorObject, err);
|
|---|
| 721 | return NULL;
|
|---|
| 722 | }
|
|---|
| 723 | return (PyObject *)newnavrrobject(&reply);
|
|---|
| 724 | }
|
|---|
| 725 |
|
|---|
| 726 | static char nav_NavNewFolder__doc__[] =
|
|---|
| 727 | "(DialogOptions dict or kwargs+defaultLocation,eventProc) -> NavReplyRecord"
|
|---|
| 728 | ;
|
|---|
| 729 |
|
|---|
| 730 | static PyObject *
|
|---|
| 731 | nav_NavNewFolder(PyObject *self, PyObject *args, PyObject *kw)
|
|---|
| 732 | {
|
|---|
| 733 | PyObject *dict;
|
|---|
| 734 | AEDesc *defaultLocation = NULL;
|
|---|
| 735 | NavReplyRecord reply;
|
|---|
| 736 | NavDialogOptions dialogOptions;
|
|---|
| 737 | NavEventUPP eventProc = NULL;
|
|---|
| 738 | OSErr err;
|
|---|
| 739 |
|
|---|
| 740 | if ( kw && PyObject_IsTrue(kw) ) {
|
|---|
| 741 | if (!PyArg_ParseTuple(args, ";either keyword arguments or dictionary expected"))
|
|---|
| 742 | return NULL;
|
|---|
| 743 | dict = kw;
|
|---|
| 744 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict))
|
|---|
| 745 | return NULL;
|
|---|
| 746 | if (!filldialogoptions(dict, &defaultLocation, &dialogOptions, &eventProc, NULL, NULL, NULL, NULL, NULL))
|
|---|
| 747 | return NULL;
|
|---|
| 748 | err = NavNewFolder(defaultLocation, &reply, &dialogOptions, eventProc, (void *)dict);
|
|---|
| 749 | PyMem_DEL(defaultLocation);
|
|---|
| 750 | if ( err ) {
|
|---|
| 751 | PyErr_Mac(ErrorObject, err);
|
|---|
| 752 | return NULL;
|
|---|
| 753 | }
|
|---|
| 754 | return (PyObject *)newnavrrobject(&reply);
|
|---|
| 755 | }
|
|---|
| 756 |
|
|---|
| 757 | #if 0
|
|---|
| 758 | /* XXXX I don't know what to do with the void * argument */
|
|---|
| 759 | static char nav_NavCustomControl__doc__[] =
|
|---|
| 760 | ""
|
|---|
| 761 | ;
|
|---|
| 762 |
|
|---|
| 763 |
|
|---|
| 764 | static PyObject *
|
|---|
| 765 | nav_NavCustomControl(PyObject *self, PyObject *args)
|
|---|
| 766 | {
|
|---|
| 767 |
|
|---|
| 768 | if (!PyArg_ParseTuple(args, ""))
|
|---|
| 769 | return NULL;
|
|---|
| 770 | Py_INCREF(Py_None);
|
|---|
| 771 | return Py_None;
|
|---|
| 772 | }
|
|---|
| 773 | #endif
|
|---|
| 774 |
|
|---|
| 775 | static char nav_NavServicesCanRun__doc__[] =
|
|---|
| 776 | "()->int"
|
|---|
| 777 | ;
|
|---|
| 778 |
|
|---|
| 779 | static PyObject *
|
|---|
| 780 | nav_NavServicesCanRun(PyObject *self, PyObject *args)
|
|---|
| 781 | {
|
|---|
| 782 | Boolean rv;
|
|---|
| 783 | if (!PyArg_ParseTuple(args, ""))
|
|---|
| 784 | return NULL;
|
|---|
| 785 | rv = NavServicesCanRun();
|
|---|
| 786 | return Py_BuildValue("l", (long)rv);
|
|---|
| 787 | }
|
|---|
| 788 |
|
|---|
| 789 | static char nav_NavServicesAvailable__doc__[] =
|
|---|
| 790 | "()->int"
|
|---|
| 791 | ;
|
|---|
| 792 |
|
|---|
| 793 | static PyObject *
|
|---|
| 794 | nav_NavServicesAvailable(PyObject *self, PyObject *args)
|
|---|
| 795 | {
|
|---|
| 796 | Boolean rv;
|
|---|
| 797 |
|
|---|
| 798 | if (!PyArg_ParseTuple(args, ""))
|
|---|
| 799 | return NULL;
|
|---|
| 800 | rv = NavServicesAvailable();
|
|---|
| 801 | return Py_BuildValue("l", (long)rv);
|
|---|
| 802 | }
|
|---|
| 803 | /* XX */
|
|---|
| 804 | static char nav_NavLoad__doc__[] =
|
|---|
| 805 | "()->None"
|
|---|
| 806 | ;
|
|---|
| 807 |
|
|---|
| 808 | static PyObject *
|
|---|
| 809 | nav_NavLoad(PyObject *self, PyObject *args)
|
|---|
| 810 | {
|
|---|
| 811 |
|
|---|
| 812 | if (!PyArg_ParseTuple(args, ""))
|
|---|
| 813 | return NULL;
|
|---|
| 814 | NavLoad();
|
|---|
| 815 | Py_INCREF(Py_None);
|
|---|
| 816 | return Py_None;
|
|---|
| 817 | }
|
|---|
| 818 |
|
|---|
| 819 | static char nav_NavUnload__doc__[] =
|
|---|
| 820 | "()->None"
|
|---|
| 821 | ;
|
|---|
| 822 |
|
|---|
| 823 | static PyObject *
|
|---|
| 824 | nav_NavUnload(PyObject *self, PyObject *args)
|
|---|
| 825 | {
|
|---|
| 826 |
|
|---|
| 827 | if (!PyArg_ParseTuple(args, ""))
|
|---|
| 828 | return NULL;
|
|---|
| 829 | NavUnload();
|
|---|
| 830 | Py_INCREF(Py_None);
|
|---|
| 831 | return Py_None;
|
|---|
| 832 | }
|
|---|
| 833 |
|
|---|
| 834 | static char nav_NavLibraryVersion__doc__[] =
|
|---|
| 835 | "()->int"
|
|---|
| 836 | ;
|
|---|
| 837 |
|
|---|
| 838 | static PyObject *
|
|---|
| 839 | nav_NavLibraryVersion(PyObject *self, PyObject *args)
|
|---|
| 840 | {
|
|---|
| 841 | UInt32 rv;
|
|---|
| 842 |
|
|---|
| 843 | if (!PyArg_ParseTuple(args, ""))
|
|---|
| 844 | return NULL;
|
|---|
| 845 | rv = NavLibraryVersion();
|
|---|
| 846 | return Py_BuildValue("l", (long)rv);
|
|---|
| 847 | }
|
|---|
| 848 |
|
|---|
| 849 | static char nav_NavGetDefaultDialogOptions__doc__[] =
|
|---|
| 850 | "()->dict\nPass dict or keyword args with same names to other calls."
|
|---|
| 851 | ;
|
|---|
| 852 |
|
|---|
| 853 | static PyObject *
|
|---|
| 854 | nav_NavGetDefaultDialogOptions(PyObject *self, PyObject *args)
|
|---|
| 855 | {
|
|---|
| 856 | NavDialogOptions dialogOptions;
|
|---|
| 857 | OSErr err;
|
|---|
| 858 |
|
|---|
| 859 | err = NavGetDefaultDialogOptions(&dialogOptions);
|
|---|
| 860 | if ( err ) {
|
|---|
| 861 | PyErr_Mac(ErrorObject, err);
|
|---|
| 862 | return NULL;
|
|---|
| 863 | }
|
|---|
| 864 | 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&}",
|
|---|
| 865 | "version", dialogOptions.version,
|
|---|
| 866 | "dialogOptionFlags", dialogOptions.dialogOptionFlags,
|
|---|
| 867 | "location", PyMac_BuildPoint, dialogOptions.location,
|
|---|
| 868 | "clientName", PyMac_BuildStr255, &dialogOptions.clientName,
|
|---|
| 869 | "windowTitle", PyMac_BuildStr255, &dialogOptions.windowTitle,
|
|---|
| 870 | "actionButtonLabel", PyMac_BuildStr255, &dialogOptions.actionButtonLabel,
|
|---|
| 871 | "cancelButtonLabel", PyMac_BuildStr255, &dialogOptions.cancelButtonLabel,
|
|---|
| 872 | "savedFileName", PyMac_BuildStr255, &dialogOptions.savedFileName,
|
|---|
| 873 | "message", PyMac_BuildStr255, &dialogOptions.message,
|
|---|
| 874 | "preferenceKey", PyMac_BuildOSType, dialogOptions.preferenceKey,
|
|---|
| 875 | "popupExtension", OptResObj_New, dialogOptions.popupExtension);
|
|---|
| 876 | }
|
|---|
| 877 |
|
|---|
| 878 | /* List of methods defined in the module */
|
|---|
| 879 |
|
|---|
| 880 | static struct PyMethodDef nav_methods[] = {
|
|---|
| 881 | {"NavGetFile", (PyCFunction)nav_NavGetFile, METH_VARARGS|METH_KEYWORDS, nav_NavGetFile__doc__},
|
|---|
| 882 | {"NavPutFile", (PyCFunction)nav_NavPutFile, METH_VARARGS|METH_KEYWORDS, nav_NavPutFile__doc__},
|
|---|
| 883 | {"NavAskSaveChanges", (PyCFunction)nav_NavAskSaveChanges, METH_VARARGS|METH_KEYWORDS, nav_NavAskSaveChanges__doc__},
|
|---|
| 884 | {"NavCustomAskSaveChanges", (PyCFunction)nav_NavCustomAskSaveChanges, METH_VARARGS|METH_KEYWORDS, nav_NavCustomAskSaveChanges__doc__},
|
|---|
| 885 | {"NavAskDiscardChanges", (PyCFunction)nav_NavAskDiscardChanges, METH_VARARGS|METH_KEYWORDS, nav_NavAskDiscardChanges__doc__},
|
|---|
| 886 | {"NavChooseFile", (PyCFunction)nav_NavChooseFile, METH_VARARGS|METH_KEYWORDS, nav_NavChooseFile__doc__},
|
|---|
| 887 | {"NavChooseFolder", (PyCFunction)nav_NavChooseFolder, METH_VARARGS|METH_KEYWORDS, nav_NavChooseFolder__doc__},
|
|---|
| 888 | {"NavChooseVolume", (PyCFunction)nav_NavChooseVolume, METH_VARARGS|METH_KEYWORDS, nav_NavChooseVolume__doc__},
|
|---|
| 889 | {"NavChooseObject", (PyCFunction)nav_NavChooseObject, METH_VARARGS|METH_KEYWORDS, nav_NavChooseObject__doc__},
|
|---|
| 890 | {"NavNewFolder", (PyCFunction)nav_NavNewFolder, METH_VARARGS|METH_KEYWORDS, nav_NavNewFolder__doc__},
|
|---|
| 891 | #if 0
|
|---|
| 892 | {"NavCustomControl", (PyCFunction)nav_NavCustomControl, METH_VARARGS, nav_NavCustomControl__doc__},
|
|---|
| 893 | #endif
|
|---|
| 894 | {"NavServicesCanRun", (PyCFunction)nav_NavServicesCanRun, METH_VARARGS, nav_NavServicesCanRun__doc__},
|
|---|
| 895 | {"NavServicesAvailable", (PyCFunction)nav_NavServicesAvailable, METH_VARARGS, nav_NavServicesAvailable__doc__},
|
|---|
| 896 | {"NavLoad", (PyCFunction)nav_NavLoad, METH_VARARGS, nav_NavLoad__doc__},
|
|---|
| 897 | {"NavUnload", (PyCFunction)nav_NavUnload, METH_VARARGS, nav_NavUnload__doc__},
|
|---|
| 898 | {"NavLibraryVersion", (PyCFunction)nav_NavLibraryVersion, METH_VARARGS, nav_NavLibraryVersion__doc__},
|
|---|
| 899 | {"NavGetDefaultDialogOptions", (PyCFunction)nav_NavGetDefaultDialogOptions, METH_VARARGS, nav_NavGetDefaultDialogOptions__doc__},
|
|---|
| 900 | {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
|
|---|
| 901 | };
|
|---|
| 902 |
|
|---|
| 903 |
|
|---|
| 904 | /* Initialization function for the module (*must* be called initNav) */
|
|---|
| 905 |
|
|---|
| 906 | static char Nav_module_documentation[] =
|
|---|
| 907 | "Interface to Navigation Services\n"
|
|---|
| 908 | "Most calls accept a NavDialogOptions dictionary or keywords with the same names, pass {}\n"
|
|---|
| 909 | "if you want the default options.\n"
|
|---|
| 910 | "Use NavGetDefaultDialogOptions() to find out common option names.\n"
|
|---|
| 911 | "See individual docstrings for additional keyword args/dictentries supported by each call.\n"
|
|---|
| 912 | "Pass None as eventProc to get movable-modal dialogs that process updates through the standard Python mechanism."
|
|---|
| 913 | ;
|
|---|
| 914 |
|
|---|
| 915 | void
|
|---|
| 916 | initNav(void)
|
|---|
| 917 | {
|
|---|
| 918 | PyObject *m, *d;
|
|---|
| 919 |
|
|---|
| 920 | /* Test that we have NavServices */
|
|---|
| 921 | if ( !NavServicesAvailable() ) {
|
|---|
| 922 | PyErr_SetString(PyExc_ImportError, "Navigation Services not available");
|
|---|
| 923 | return;
|
|---|
| 924 | }
|
|---|
| 925 | /* Create the module and add the functions */
|
|---|
| 926 | m = Py_InitModule4("Nav", nav_methods,
|
|---|
| 927 | Nav_module_documentation,
|
|---|
| 928 | (PyObject*)NULL,PYTHON_API_VERSION);
|
|---|
| 929 |
|
|---|
| 930 | /* Add some symbolic constants to the module */
|
|---|
| 931 | d = PyModule_GetDict(m);
|
|---|
| 932 | ErrorObject = PyString_FromString("Nav.error");
|
|---|
| 933 | PyDict_SetItemString(d, "error", ErrorObject);
|
|---|
| 934 |
|
|---|
| 935 | /* XXXX Add constants here */
|
|---|
| 936 |
|
|---|
| 937 | /* Set UPPs */
|
|---|
| 938 | my_eventProcUPP = NewNavEventUPP(my_eventProc);
|
|---|
| 939 | my_previewProcUPP = NewNavPreviewUPP(my_previewProc);
|
|---|
| 940 | my_filterProcUPP = NewNavObjectFilterUPP(my_filterProc);
|
|---|
| 941 |
|
|---|
| 942 | }
|
|---|
| 943 |
|
|---|