add an unregister_all for python callbacks
This commit is contained in:
parent
2c908c308d
commit
c645416035
4 changed files with 34 additions and 0 deletions
|
@ -55,6 +55,7 @@
|
|||
%rename(register) ob::python_register;
|
||||
%rename(preregister) ob::python_preregister;
|
||||
%rename(unregister) ob::python_unregister;
|
||||
%rename(unregister_all) ob::python_unregister_all;
|
||||
|
||||
%ignore ob::OBScreen::clients;
|
||||
%{
|
||||
|
|
|
@ -2513,6 +2513,21 @@ static PyObject *_wrap_unregister(PyObject *self, PyObject *args) {
|
|||
}
|
||||
|
||||
|
||||
static PyObject *_wrap_unregister_all(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
int arg1 ;
|
||||
bool result;
|
||||
|
||||
if(!PyArg_ParseTuple(args,(char *)"i:unregister_all",&arg1)) goto fail;
|
||||
result = (bool)ob::python_unregister_all(arg1);
|
||||
|
||||
resultobj = PyInt_FromLong((long)result);
|
||||
return resultobj;
|
||||
fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef SwigMethods[] = {
|
||||
{ (char *)"Openbox_instance", _wrap_Openbox_instance, METH_VARARGS },
|
||||
{ (char *)"Cursors_session_set", _wrap_Cursors_session_set, METH_VARARGS },
|
||||
|
@ -2609,6 +2624,7 @@ static PyMethodDef SwigMethods[] = {
|
|||
{ (char *)"register", _wrap_register, METH_VARARGS },
|
||||
{ (char *)"preregister", _wrap_preregister, METH_VARARGS },
|
||||
{ (char *)"unregister", _wrap_unregister, METH_VARARGS },
|
||||
{ (char *)"unregister_all", _wrap_unregister_all, METH_VARARGS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -74,6 +74,20 @@ bool python_unregister(int action, PyObject *callback)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool python_unregister_all(int action)
|
||||
{
|
||||
if (action < 0 || action >= OBActions::NUM_ACTIONS) {
|
||||
PyErr_SetString(PyExc_AssertionError, "Invalid action type.");
|
||||
return false;
|
||||
}
|
||||
|
||||
while (!callbacks[action].empty()) {
|
||||
Py_XDECREF(callbacks[action].back());
|
||||
callbacks[action].pop_back();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void python_callback(OBActions::ActionType action, Window window,
|
||||
OBWidget::WidgetType type, unsigned int state,
|
||||
long d1, long d2, long d3, long d4)
|
||||
|
|
|
@ -22,6 +22,9 @@ bool python_preregister(int action, PyObject *callback);
|
|||
//! Remove a python callback function from the hook list
|
||||
bool python_unregister(int action, PyObject *callback);
|
||||
|
||||
//! Removes all python callback functions from the hook list
|
||||
bool python_unregister_all(int action);
|
||||
|
||||
//! Fire a python callback function
|
||||
void python_callback(OBActions::ActionType action, Window window,
|
||||
OBWidget::WidgetType type, unsigned int state,
|
||||
|
|
Loading…
Reference in a new issue