* Added description string to operator types, should be set along with ot->idname when defining ops.

* User interface uses this as a tooltip when NULL or "" is given.
* Python doc generation includes this description 
* Python defined ops take the description as an argument.

* NULL check to image_ops.c, was crashing on exit when there was an image open.
This commit is contained in:
2009-02-12 03:39:56 +00:00
parent 12811a096c
commit b96180ec17
7 changed files with 23 additions and 5 deletions

View File

@@ -44,6 +44,7 @@ typedef struct PyOperatorType {
void *next, *prev;
char idname[OP_MAX_TYPENAME];
char name[OP_MAX_TYPENAME];
char description[OP_MAX_TYPENAME]; // XXX should be longer?
PyObject *py_invoke;
PyObject *py_exec;
} PyOperatorType;
@@ -276,6 +277,7 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata)
/* identifiers */
ot->name= pyot->name;
ot->idname= pyot->idname;
ot->description= pyot->description;
/* api callbacks */
if (pyot->py_invoke != Py_None)
@@ -342,10 +344,11 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *args)
char *idname= NULL;
char *name= NULL;
char *description= NULL;
PyObject *invoke= NULL;
PyObject *exec= NULL;
if (!PyArg_ParseTuple(args, "ssOO", &idname, &name, &invoke, &exec)) {
if (!PyArg_ParseTuple(args, "sssOO", &idname, &name, &description, &invoke, &exec)) {
PyErr_SetString( PyExc_AttributeError, "expected 2 strings and 2 function objects");
return NULL;
}
@@ -362,8 +365,9 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *args)
pyot= MEM_callocN(sizeof(PyOperatorType), "PyOperatorType");
strcpy(pyot->idname, idname);
strcpy(pyot->name, name);
strncpy(pyot->idname, idname, sizeof(pyot->idname));
strncpy(pyot->name, name, sizeof(pyot->name));
strncpy(pyot->description, description, sizeof(pyot->description));
pyot->py_invoke= invoke;
pyot->py_exec= exec;
Py_INCREF(invoke);