]> Dogcows Code - chaz/openbox/commitdiff
add an unregister_all for python callbacks
authorDana Jansens <danakj@orodu.net>
Fri, 27 Dec 2002 08:39:53 +0000 (08:39 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 27 Dec 2002 08:39:53 +0000 (08:39 +0000)
src/openbox.i
src/openbox_wrap.cc
src/python.cc
src/python.hh

index 20c8ea06ce2cdbd0133564b174d199ad7ca38cdb..4d11507c388ede9a631b0fe274c20680c837793d 100644 (file)
@@ -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;
 %{
index 5cf5d8ea62a4298d55c4acedaba6c9cf8dd334d8..7f0d015f49e097d3ed7b4a246b7a422ebaa94cd6 100644 (file)
@@ -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 }
 };
 
index 97a3a4d2f38ba39a96d9f8d7f67ad57a9de24d4a..ed171f9cc4880659e2f3642dd310b606964751d4 100644 (file)
@@ -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)
index 30cd752d19c96c33bd1305093db89c0794843beb..496b459de27682ba46879d170be490dcba4d9448 100644 (file)
@@ -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,
This page took 0.0283 seconds and 4 git commands to generate.