From 59902bad90ed9192ad9b2def78f588cdefe1080c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Mar 2005 16:16:37 +0000 Subject: * Implemented OpProgress support --- python/progress.cc | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 python/progress.cc (limited to 'python/progress.cc') diff --git a/python/progress.cc b/python/progress.cc new file mode 100644 index 00000000..d414ca15 --- /dev/null +++ b/python/progress.cc @@ -0,0 +1,55 @@ +// Description /*{{{*/ +// $Id: progress.cc,v 1.5 2003/06/03 03:03:23 mdz Exp $ +/* ###################################################################### + + Progress - Wrapper for the progress related functions + + ##################################################################### */ + +#include "progress.h" + + +void PyOpProgress::Update() +{ + if(callbackInst == 0) + return; + + // Build up the argument list... + PyObject *arglist = Py_BuildValue("(f)", Percent); + + // ...for calling the Python compare function. + PyObject *method = PyObject_GetAttrString(callbackInst, "Update"); + if(method == NULL) { + // FIXME: make this silent + Py_DECREF(arglist); + return; + } + PyObject *result = PyEval_CallObject(method,arglist); + + Py_XDECREF(result); + Py_XDECREF(method); + Py_DECREF(arglist); + + return; +}; + +void PyOpProgress::Done() +{ + if(callbackInst == 0) + return; + + // Build up the argument list... + PyObject *arglist = Py_BuildValue("()", NULL); + + // ...for calling the Python compare function. + PyObject *method = PyObject_GetAttrString(callbackInst, "Done"); + if(method == NULL) { + Py_DECREF(arglist); + return; + } + PyObject *result = PyEval_CallObject(method,arglist); + + Py_XDECREF(result); + Py_XDECREF(method); + Py_DECREF(arglist); +} -- cgit v1.2.3