]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
added Resource(), to create new resources from Python
authorGuido van Rossum <guido@python.org>
Sun, 5 Feb 1995 16:54:27 +0000 (16:54 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 5 Feb 1995 16:54:27 +0000 (16:54 +0000)
Mac/Modules/res/Resmodule.c
Mac/Modules/res/ressupport.py

index 484bca6c83d296a32988f8623a2b5fca2f00f5f8..a0e487c3d19e57a5772f823b893a63b13548ac44 100644 (file)
@@ -30,6 +30,8 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
 extern PyObject *CtlObj_New(ControlHandle);
 extern int CtlObj_Convert(PyObject *, ControlHandle *);
 
+extern PyObject *WinObj_WhichWindow(WindowPtr);
+
 #include <Resources.h>
 
 #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
@@ -1161,6 +1163,30 @@ static PyObject *Res_FSpCreateResFile(_self, _args)
        return _res;
 }
 
+static PyObject *Res_Resource(_self, _args)
+       PyObject *_self;
+       PyObject *_args;
+{
+       PyObject *_res = NULL;
+
+       char *buf;
+       int len;
+       Handle h;
+
+       if (!PyArg_ParseTuple(_args, "s#", &buf, &len))
+               return NULL;
+       h = NewHandle(len);
+       if ( h == NULL ) {
+               PyErr_NoMemory();
+               return NULL;
+       }
+       HLock(h);
+       memcpy(*h, buf, len);
+       HUnlock(h);
+       return (PyObject *)ResObj_New(h);
+
+}
+
 static PyMethodDef Res_methods[] = {
        {"InitResources", (PyCFunction)Res_InitResources, 1,
         "() -> (short _rv)"},
@@ -1228,6 +1254,8 @@ static PyMethodDef Res_methods[] = {
         "(FSSpec spec, SignedByte permission) -> (short _rv)"},
        {"FSpCreateResFile", (PyCFunction)Res_FSpCreateResFile, 1,
         "(FSSpec spec, OSType creator, OSType fileType, ScriptCode scriptTag) -> None"},
+       {"Resource", (PyCFunction)Res_Resource, 1,
+        "Convert a string to a resource object.\n\nThe created resource object is actually just a handle.\nApply AddResource() to write it to a resource file.\n"},
        {NULL, NULL, 0}
 };
 
index 5c0d70f0dc86648f39946db9a500fab9ac1c43fe..a44af098b238f64b28273812f26090aa8ef1e036 100644 (file)
@@ -69,6 +69,7 @@ functions = []
 resmethods = []
 
 execfile('resgen.py')
+execfile('resedit.py')
 
 for f in functions: module.add(f)
 for f in resmethods: resobject.add(f)