+void python_callback_binding(int id, OBActions::ActionType action,
+ Window window, unsigned int state,
+ unsigned int keybutton, Time time)
+{
+ assert(action >= 0 && action < OBActions::NUM_ACTIONS);
+
+ if (!bindfuncs[id]) return; // the key was unbound
+
+ PyObject *arglist;
+ PyObject *result;
+
+ arglist = Py_BuildValue("ilisl", action, window, state,
+ XKeysymToString(
+ XKeycodeToKeysym(otk::OBDisplay::display,
+ keybutton, 0)),
+ time);
+
+ // call the callback
+ result = PyEval_CallObject(bindfuncs[id], arglist);
+ if (result) {
+ Py_DECREF(result);
+ } else {
+ // an exception occured in the script, display it
+ PyErr_Print();
+ }
+
+ Py_DECREF(arglist);
+}
+