Jack Jansen | 86f25fb | 2003-03-06 23:02:04 +0000 | [diff] [blame^] | 1 | #include <Python/Python.h> |
| 2 | #include <Carbon/Carbon.h> |
| 3 | #include <Python/pymactoolbox.h> |
| 4 | |
| 5 | PyObject * PyOSA_GetAppTerminology(PyObject* self, PyObject* args) { |
| 6 | AEDesc temp; |
| 7 | FSSpec tempFSSpec; |
| 8 | |
| 9 | ComponentInstance defaultComponent; |
| 10 | ScriptingComponentSelector theType; |
| 11 | SInt16 defaultTerminology; |
| 12 | Boolean didLaunch; |
| 13 | |
| 14 | OSAError err; |
| 15 | |
| 16 | PyObject * returnVal; |
| 17 | |
| 18 | if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSSpec, &tempFSSpec)) return NULL; |
| 19 | |
| 20 | defaultComponent = OpenDefaultComponent (kOSAComponentType, |
| 21 | 'ascr'); |
| 22 | // kOSAGenericScriptingComponentSubtype); |
| 23 | |
| 24 | err = GetComponentInstanceError (defaultComponent); |
| 25 | printf("OpenDefaultComponent: %d\n", err); |
| 26 | err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology); |
| 27 | printf("getcurrentdialect: %d\n", err); |
| 28 | err = OSAGetAppTerminology ( |
| 29 | defaultComponent, |
| 30 | kOSAModeNull, |
| 31 | &tempFSSpec, |
| 32 | defaultTerminology, |
| 33 | &didLaunch, |
| 34 | &temp |
| 35 | ); |
| 36 | |
| 37 | /* err = ASGetAppTerminology ( |
| 38 | defaultComponent, |
| 39 | &tempFSSpec, |
| 40 | defaultTerminology, |
| 41 | &didLaunch, |
| 42 | &temp |
| 43 | );*/ |
| 44 | |
| 45 | printf("getappterminology: %d\n", err); |
| 46 | |
| 47 | returnVal = Py_BuildValue("O&i", |
| 48 | AEDesc_New, &temp, didLaunch); |
| 49 | return returnVal; |
| 50 | } |
| 51 | |
| 52 | /* |
| 53 | * List of methods defined in the module |
| 54 | */ |
| 55 | static struct PyMethodDef PyOSA_methods[] = |
| 56 | { |
| 57 | {"GetAppTerminology", |
| 58 | (PyCFunction) PyOSA_GetAppTerminology, |
| 59 | METH_VARARGS, |
| 60 | "Get an applications terminology, as an AEDesc object."}, |
| 61 | |
| 62 | {NULL, (PyCFunction) NULL, 0, NULL} |
| 63 | }; |
| 64 | |
| 65 | |
| 66 | void |
| 67 | initPyOSA(void) |
| 68 | { |
| 69 | Py_InitModule("PyOSA", PyOSA_methods); |
| 70 | } |