- (void)e;
- doCallback(Action_CloseWindow, e.window, (OBWidget::WidgetType)-1,
- 0, 0, 0, 0, 0);
-}
-
-void OBActions::doCallback(ActionType action, Window window,
- OBWidget::WidgetType type, unsigned int state,
- unsigned int button, int xroot, int yroot,
- Time time)
-{
- std::pair<CallbackMap::iterator, CallbackMap::iterator> it_pair =
- _callbacks.equal_range(action);
-
- CallbackMap::iterator it;
-// for (it = it_pair.first; it != it_pair.second; ++it)
-// python_callback(it->second, action, window, type, state,
-// button, xroot, yroot, time);
- // XXX do a callback
-}
-
-bool OBActions::registerCallback(ActionType action, PyObject *func,
- bool atfront)
-{
- if (action < 0 || action >= OBActions::NUM_ACTIONS) {
- return false;
- }
- if (!func)
- return false;
-
- std::pair<CallbackMap::iterator, CallbackMap::iterator> it_pair =
- _callbacks.equal_range(action);
-
- CallbackMap::iterator it;
- for (it = it_pair.first; it != it_pair.second; ++it)
- if (it->second == func)
- return true; // already in there
- if (atfront)
- _callbacks.insert(_callbacks.begin(), CallbackMapPair(action, func));
- else
- _callbacks.insert(CallbackMapPair(action, func));
- Py_INCREF(func);
- return true;
-}
-
-bool OBActions::unregisterCallback(ActionType action, PyObject *func)
-{
- if (action < 0 || action >= OBActions::NUM_ACTIONS) {
- return false;
- }
- if (!func)
- return false;
-
- std::pair<CallbackMap::iterator, CallbackMap::iterator> it_pair =
- _callbacks.equal_range(action);
-
- CallbackMap::iterator it;
- for (it = it_pair.first; it != it_pair.second; ++it)
- if (it->second == func)
- break;
- if (it != it_pair.second) { // its been registered before
- Py_DECREF(func);
- _callbacks.erase(it);
- }
- return true;
-}
-
-bool OBActions::unregisterAllCallbacks(ActionType action)
-{
- if (action < 0 || action >= OBActions::NUM_ACTIONS) {
- return false;
- }
-
- while (!_callbacks.empty()) {
- CallbackMap::iterator it = _callbacks.begin();
- Py_DECREF(it->second);
- _callbacks.erase(it);
- }
- return true;