From b96180ec1763b29bdda4acd6cf79275058bcbde3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Feb 2009 03:39:56 +0000 Subject: * 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. --- source/blender/python/intern/bpy_opwrapper.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/python/intern') diff --git a/source/blender/python/intern/bpy_opwrapper.c b/source/blender/python/intern/bpy_opwrapper.c index 8a644f51b24..ca6104d087f 100644 --- a/source/blender/python/intern/bpy_opwrapper.c +++ b/source/blender/python/intern/bpy_opwrapper.c @@ -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); -- cgit v1.2.3