static PyObject* py_categories(PyObject *self, PyObject *args) { PyObject *newlist = NULL; VMDApp *app; int i, num; if (!(app = get_vmdapp())) return NULL; num = app->num_color_categories(); if (!(newlist = PyList_New(num))) goto failure; for (i = 0; i < num; i++) { PyList_SET_ITEM(newlist, i, as_pystring(app->color_category(i))); if (PyErr_Occurred()) goto failure; } return newlist; failure: PyErr_SetString(PyExc_RuntimeError, "Problem listing color categories"); Py_XDECREF(newlist); return NULL; }
static PyObject *categories(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, (char *)"")) return NULL; VMDApp *app = get_vmdapp(); int num = app->num_color_categories(); PyObject *newlist = PyList_New(num); for (int i=0; i<num; i++) { PyList_SET_ITEM(newlist, i, PyString_FromString(app->color_category(i)) ); } return newlist; }