1 | /*
|
---|
2 | ** This module is a one-trick pony: given an FSSpec it gets the aeut
|
---|
3 | ** resources. It was written by Donovan Preston and slightly modified
|
---|
4 | ** by Jack.
|
---|
5 | **
|
---|
6 | ** It should be considered a placeholder, it will probably be replaced
|
---|
7 | ** by a full interface to OpenScripting.
|
---|
8 | */
|
---|
9 | #include "Python.h"
|
---|
10 | #include "pymactoolbox.h"
|
---|
11 |
|
---|
12 | #include <Carbon/Carbon.h>
|
---|
13 |
|
---|
14 | static PyObject *
|
---|
15 | PyOSA_GetAppTerminology(PyObject* self, PyObject* args)
|
---|
16 | {
|
---|
17 | AEDesc theDesc = {0,0};
|
---|
18 | FSSpec fss;
|
---|
19 | ComponentInstance defaultComponent = NULL;
|
---|
20 | SInt16 defaultTerminology = 0;
|
---|
21 | Boolean didLaunch = 0;
|
---|
22 | OSAError err;
|
---|
23 | long modeFlags = 0;
|
---|
24 |
|
---|
25 | if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
|
---|
26 | return NULL;
|
---|
27 |
|
---|
28 | defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
|
---|
29 | err = GetComponentInstanceError (defaultComponent);
|
---|
30 | if (err) return PyMac_Error(err);
|
---|
31 | err = OSAGetAppTerminology (
|
---|
32 | defaultComponent,
|
---|
33 | modeFlags,
|
---|
34 | &fss,
|
---|
35 | defaultTerminology,
|
---|
36 | &didLaunch,
|
---|
37 | &theDesc
|
---|
38 | );
|
---|
39 | if (err) return PyMac_Error(err);
|
---|
40 | return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
|
---|
41 | }
|
---|
42 |
|
---|
43 | static PyObject *
|
---|
44 | PyOSA_GetSysTerminology(PyObject* self, PyObject* args)
|
---|
45 | {
|
---|
46 | AEDesc theDesc = {0,0};
|
---|
47 | FSSpec fss;
|
---|
48 | ComponentInstance defaultComponent = NULL;
|
---|
49 | SInt16 defaultTerminology = 0;
|
---|
50 | Boolean didLaunch = 0;
|
---|
51 | OSAError err;
|
---|
52 | long modeFlags = 0;
|
---|
53 |
|
---|
54 | if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
|
---|
55 | return NULL;
|
---|
56 |
|
---|
57 | defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
|
---|
58 | err = GetComponentInstanceError (defaultComponent);
|
---|
59 | if (err) return PyMac_Error(err);
|
---|
60 | err = OSAGetAppTerminology (
|
---|
61 | defaultComponent,
|
---|
62 | modeFlags,
|
---|
63 | &fss,
|
---|
64 | defaultTerminology,
|
---|
65 | &didLaunch,
|
---|
66 | &theDesc
|
---|
67 | );
|
---|
68 | if (err) return PyMac_Error(err);
|
---|
69 | return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
|
---|
70 | }
|
---|
71 |
|
---|
72 | /*
|
---|
73 | * List of methods defined in the module
|
---|
74 | */
|
---|
75 | static struct PyMethodDef OSATerminology_methods[] =
|
---|
76 | {
|
---|
77 | {"GetAppTerminology",
|
---|
78 | (PyCFunction) PyOSA_GetAppTerminology,
|
---|
79 | METH_VARARGS,
|
---|
80 | "Get an applications terminology, as an AEDesc object."},
|
---|
81 | {"GetSysTerminology",
|
---|
82 | (PyCFunction) PyOSA_GetSysTerminology,
|
---|
83 | METH_VARARGS,
|
---|
84 | "Get an applications system terminology, as an AEDesc object."},
|
---|
85 | {NULL, (PyCFunction) NULL, 0, NULL}
|
---|
86 | };
|
---|
87 |
|
---|
88 |
|
---|
89 | void
|
---|
90 | initOSATerminology(void)
|
---|
91 | {
|
---|
92 | Py_InitModule("OSATerminology", OSATerminology_methods);
|
---|
93 | }
|
---|