Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 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 "macglue.h" |
| 34 | #include <Navigation.h> |
| 35 | |
| 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 int ResObj_Convert(PyObject *, Handle *); |
| 42 | |
| 43 | static PyObject *ErrorObject; |
| 44 | |
| 45 | /* ----------------------------------------------------- */ |
| 46 | static int |
| 47 | filldialogoptions(PyObject *d, |
| 48 | NavDialogOptions *opt, |
| 49 | NavEventUPP *eventProcP, |
| 50 | NavPreviewUPP *previewProcP, |
| 51 | NavObjectFilterUPP *filterProcP, |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 52 | NavTypeListHandle *typeListP, |
| 53 | OSType *creatorP, |
| 54 | OSType *typeP) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 55 | { |
| 56 | int pos = 0; |
| 57 | PyObject *key, *value; |
| 58 | char *keystr; |
| 59 | |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 60 | NavGetDefaultDialogOptions(opt); |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 61 | if ( eventProcP ) *eventProcP = NULL; |
| 62 | if ( previewProcP ) *previewProcP = NULL; |
| 63 | if ( filterProcP ) *filterProcP = NULL; |
| 64 | if ( typeListP ) *typeListP = NULL; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 65 | if ( creatorP ) *creatorP = 0; |
| 66 | if ( typeP ) *typeP = 0; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 67 | |
| 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 Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 107 | } else if( eventProcP && strcmp(keystr, "eventProc") == 0 ) { |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 108 | PyErr_SetString(ErrorObject, "No callbacks implemented yet"); |
| 109 | return 0; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 110 | } else if( previewProcP && strcmp(keystr, "previewProc") == 0 ) { |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 111 | PyErr_SetString(ErrorObject, "No callbacks implemented yet"); |
| 112 | return 0; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 113 | } else if( filterProcP && strcmp(keystr, "filterProc") == 0 ) { |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 114 | PyErr_SetString(ErrorObject, "No callbacks implemented yet"); |
| 115 | return 0; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 116 | } else if( typeListP && strcmp(keystr, "typeList") == 0 ) { |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 117 | if ( !PyArg_Parse(value, "O&", ResObj_Convert, typeListP) ) |
| 118 | return 0; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 119 | } 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 Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 125 | } 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 | |
| 137 | typedef struct { |
| 138 | PyObject_HEAD |
| 139 | NavReplyRecord itself; |
| 140 | } navrrobject; |
| 141 | |
| 142 | staticforward PyTypeObject Navrrtype; |
| 143 | |
| 144 | |
| 145 | |
| 146 | /* ---------------------------------------------------------------- */ |
| 147 | |
| 148 | static struct PyMethodDef navrr_methods[] = { |
| 149 | |
| 150 | {NULL, NULL} /* sentinel */ |
| 151 | }; |
| 152 | |
| 153 | /* ---------- */ |
| 154 | |
| 155 | |
| 156 | static navrrobject * |
| 157 | newnavrrobject(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 | |
| 169 | static void |
| 170 | navrr_dealloc(self) |
| 171 | navrrobject *self; |
| 172 | { |
| 173 | NavDisposeReply(&self->itself); |
| 174 | PyMem_DEL(self); |
| 175 | } |
| 176 | |
| 177 | static PyObject * |
| 178 | navrr_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 | |
| 201 | static int |
| 202 | navrr_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 | |
| 213 | static char Navrrtype__doc__[] = |
| 214 | "" |
| 215 | ; |
| 216 | |
| 217 | static 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 | |
| 246 | static char nav_NavGetFile__doc__[] = |
| 247 | "" |
| 248 | ; |
| 249 | |
| 250 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 251 | nav_NavGetFile(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 252 | PyObject *self; /* Not used */ |
| 253 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 254 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 255 | { |
| 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 Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 266 | if ( kw ) { |
| 267 | if (!PyArg_ParseTuple(args, "")) |
| 268 | return NULL; |
| 269 | dict = kw; |
| 270 | } else if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &dict)) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 271 | return NULL; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 272 | if (!filldialogoptions(dict, &dialogOptions, &eventProc, &previewProc, &filterProc, &typeList, NULL, NULL)) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 273 | return NULL; |
| 274 | err = NavGetFile(defaultLocation, &reply, &dialogOptions, |
| 275 | eventProc, previewProc, filterProc, typeList, (void *)dict); |
| 276 | if ( err ) { |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 277 | PyErr_Mac(ErrorObject, err); |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 278 | return NULL; |
| 279 | } |
| 280 | return (PyObject *)newnavrrobject(&reply); |
| 281 | } |
| 282 | |
| 283 | static char nav_NavPutFile__doc__[] = |
| 284 | "" |
| 285 | ; |
| 286 | |
| 287 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 288 | nav_NavPutFile(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 289 | PyObject *self; /* Not used */ |
| 290 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 291 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 292 | { |
| 293 | |
| 294 | if (!PyArg_ParseTuple(args, "")) |
| 295 | return NULL; |
| 296 | Py_INCREF(Py_None); |
| 297 | return Py_None; |
| 298 | } |
| 299 | |
| 300 | static char nav_NavAskSaveChanges__doc__[] = |
| 301 | "" |
| 302 | ; |
| 303 | |
| 304 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 305 | nav_NavAskSaveChanges(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 306 | PyObject *self; /* Not used */ |
| 307 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 308 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 309 | { |
| 310 | |
| 311 | if (!PyArg_ParseTuple(args, "")) |
| 312 | return NULL; |
| 313 | Py_INCREF(Py_None); |
| 314 | return Py_None; |
| 315 | } |
| 316 | |
| 317 | static char nav_NavCustomAskSaveChanges__doc__[] = |
| 318 | "" |
| 319 | ; |
| 320 | |
| 321 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 322 | nav_NavCustomAskSaveChanges(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 323 | PyObject *self; /* Not used */ |
| 324 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 325 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 326 | { |
| 327 | |
| 328 | if (!PyArg_ParseTuple(args, "")) |
| 329 | return NULL; |
| 330 | Py_INCREF(Py_None); |
| 331 | return Py_None; |
| 332 | } |
| 333 | |
| 334 | static char nav_NavAskDiscardChanges__doc__[] = |
| 335 | "" |
| 336 | ; |
| 337 | |
| 338 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 339 | nav_NavAskDiscardChanges(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 340 | PyObject *self; /* Not used */ |
| 341 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 342 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 343 | { |
| 344 | |
| 345 | if (!PyArg_ParseTuple(args, "")) |
| 346 | return NULL; |
| 347 | Py_INCREF(Py_None); |
| 348 | return Py_None; |
| 349 | } |
| 350 | |
| 351 | static char nav_NavChooseFile__doc__[] = |
| 352 | "" |
| 353 | ; |
| 354 | |
| 355 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 356 | nav_NavChooseFile(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 357 | PyObject *self; /* Not used */ |
| 358 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 359 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 360 | { |
| 361 | |
| 362 | if (!PyArg_ParseTuple(args, "")) |
| 363 | return NULL; |
| 364 | Py_INCREF(Py_None); |
| 365 | return Py_None; |
| 366 | } |
| 367 | |
| 368 | static char nav_NavChooseFolder__doc__[] = |
| 369 | "" |
| 370 | ; |
| 371 | |
| 372 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 373 | nav_NavChooseFolder(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 374 | PyObject *self; /* Not used */ |
| 375 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 376 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 377 | { |
| 378 | |
| 379 | if (!PyArg_ParseTuple(args, "")) |
| 380 | return NULL; |
| 381 | Py_INCREF(Py_None); |
| 382 | return Py_None; |
| 383 | } |
| 384 | |
| 385 | static char nav_NavChooseVolume__doc__[] = |
| 386 | "" |
| 387 | ; |
| 388 | |
| 389 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 390 | nav_NavChooseVolume(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 391 | PyObject *self; /* Not used */ |
| 392 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 393 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 394 | { |
| 395 | |
| 396 | if (!PyArg_ParseTuple(args, "")) |
| 397 | return NULL; |
| 398 | Py_INCREF(Py_None); |
| 399 | return Py_None; |
| 400 | } |
| 401 | |
| 402 | static char nav_NavChooseObject__doc__[] = |
| 403 | "" |
| 404 | ; |
| 405 | |
| 406 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 407 | nav_NavChooseObject(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 408 | PyObject *self; /* Not used */ |
| 409 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 410 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 411 | { |
| 412 | |
| 413 | if (!PyArg_ParseTuple(args, "")) |
| 414 | return NULL; |
| 415 | Py_INCREF(Py_None); |
| 416 | return Py_None; |
| 417 | } |
| 418 | |
| 419 | static char nav_NavNewFolder__doc__[] = |
| 420 | "" |
| 421 | ; |
| 422 | |
| 423 | static PyObject * |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 424 | nav_NavNewFolder(self, args, kw) |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 425 | PyObject *self; /* Not used */ |
| 426 | PyObject *args; |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 427 | PyObject *kw; |
Jack Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 428 | { |
| 429 | |
| 430 | if (!PyArg_ParseTuple(args, "")) |
| 431 | return NULL; |
| 432 | Py_INCREF(Py_None); |
| 433 | return Py_None; |
| 434 | } |
| 435 | |
| 436 | static char nav_NavTranslateFile__doc__[] = |
| 437 | "" |
| 438 | ; |
| 439 | |
| 440 | static PyObject * |
| 441 | nav_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 | |
| 452 | static char nav_NavCompleteSave__doc__[] = |
| 453 | "" |
| 454 | ; |
| 455 | |
| 456 | static PyObject * |
| 457 | nav_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 | |
| 468 | static char nav_NavCustomControl__doc__[] = |
| 469 | "" |
| 470 | ; |
| 471 | |
| 472 | static PyObject * |
| 473 | nav_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 | |
| 484 | static char nav_NavServicesCanRun__doc__[] = |
| 485 | "" |
| 486 | ; |
| 487 | |
| 488 | static PyObject * |
| 489 | nav_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 | |
| 500 | static char nav_NavServicesAvailable__doc__[] = |
| 501 | "" |
| 502 | ; |
| 503 | |
| 504 | static PyObject * |
| 505 | nav_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 */ |
| 517 | static char nav_NavLoad__doc__[] = |
| 518 | "" |
| 519 | ; |
| 520 | |
| 521 | static PyObject * |
| 522 | nav_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 | |
| 534 | static char nav_NavUnload__doc__[] = |
| 535 | "" |
| 536 | ; |
| 537 | |
| 538 | static PyObject * |
| 539 | nav_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 | |
| 551 | static char nav_NavLibraryVersion__doc__[] = |
| 552 | "" |
| 553 | ; |
| 554 | |
| 555 | static PyObject * |
| 556 | nav_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 |
| 569 | static char nav_NavGetDefaultDialogOptions__doc__[] = |
| 570 | "" |
| 571 | ; |
| 572 | |
| 573 | static PyObject * |
| 574 | nav_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 | |
| 589 | static struct PyMethodDef nav_methods[] = { |
Jack Jansen | e1a45b3 | 1999-12-16 22:21:30 +0000 | [diff] [blame^] | 590 | {"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 Jansen | e91a29d | 1999-12-16 16:54:55 +0000 | [diff] [blame] | 600 | {"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 | |
| 617 | static char Nav_module_documentation[] = |
| 618 | "" |
| 619 | ; |
| 620 | |
| 621 | void |
| 622 | initNav() |
| 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 | |