From 2ae2b257d39ea62640c2590f794e4275c6db1cd4 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 25 Dec 2002 22:02:34 +0000 Subject: might not compile... ob uses its own widgets now, which subclass only the base otk widget. working on compressing focus events and handling them etc. --- src/python.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/python.cc') diff --git a/src/python.cc b/src/python.cc index d44b2d48..97a3a4d2 100644 --- a/src/python.cc +++ b/src/python.cc @@ -32,6 +32,27 @@ bool python_register(int action, PyObject *callback) return true; } +bool python_preregister(int action, PyObject *callback) +{ + if (action < 0 || action >= OBActions::NUM_ACTIONS) { + PyErr_SetString(PyExc_AssertionError, "Invalid action type."); + return false; + } + if (!PyCallable_Check(callback)) { + PyErr_SetString(PyExc_AssertionError, "Invalid callback function."); + return false; + } + + FunctionList::iterator it = std::find(callbacks[action].begin(), + callbacks[action].end(), + callback); + if (it == callbacks[action].end()) { // not already in there + Py_XINCREF(callback); // Add a reference to new callback + callbacks[action].insert(callbacks[action].begin(), callback); + } + return true; +} + bool python_unregister(int action, PyObject *callback) { if (action < 0 || action >= OBActions::NUM_ACTIONS) { -- cgit v1.2.3