+
+bool OBBindings::addEvent(EventAction action, PyObject *callback)
+{
+ if (action < 0 || action >= NUM_EVENTS) {
+ return false;
+ }
+
+ Py_XDECREF(_events[action]);
+ _events[action] = callback;
+ Py_INCREF(callback);
+ return true;
+}
+
+bool OBBindings::removeEvent(EventAction action)
+{
+ if (action < 0 || action >= NUM_EVENTS) {
+ return false;
+ }
+
+ Py_XDECREF(_events[action]);
+ _events[action] = 0;
+ return true;
+}
+
+void OBBindings::removeAllEvents()
+{
+ for (int i = 0; i < NUM_EVENTS; ++i) {
+ Py_XDECREF(_events[i]);
+ _events[i] = 0;
+ }
+}
+
+void OBBindings::fireEvent(EventData *data)
+{
+ if (_events[data->action])
+ python_callback(_events[data->action], (PyObject*)data);
+}
+