From 157fcc2665301c168dabc02eec9105db3d860b53 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 23 Feb 2005 20:45:52 +0000 Subject: * apt_pkg.GetCache() supports a progress callback now too --- python/progress.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 python/progress.h (limited to 'python/progress.h') diff --git a/python/progress.h b/python/progress.h new file mode 100644 index 00000000..d653b42d --- /dev/null +++ b/python/progress.h @@ -0,0 +1,29 @@ +#ifndef PROGRESS_H +#define PROGRESS_H + +struct PyOpProgressStruct : public OpProgress +{ + + PyObject *py_update_callback_func; + PyObject *py_update_callback_args; + + virtual void Update() { + if(py_update_callback_func == 0) + return; + + // Build up the argument list... + PyObject *arglist = Py_BuildValue("(fO)", Percent, py_update_callback_args); + + // ...for calling the Python compare function. + PyObject *result = PyEval_CallObject(py_update_callback_func,arglist); + + Py_XDECREF(result); + Py_DECREF(arglist); + + return; + }; + + PyOpProgressStruct() : OpProgress(), py_update_callback_func(0) {}; +}; + +#endif -- cgit v1.2.3