]> Dogcows Code - chaz/openbox/commitdiff
supply the same interface with optional arguments as before. increment callback funct...
authorDana Jansens <danakj@orodu.net>
Wed, 5 Feb 2003 16:25:38 +0000 (16:25 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 5 Feb 2003 16:25:38 +0000 (16:25 +0000)
wrap/callback.i
wrap/ob.i

index c4bec25728362553df5655ea76c1ef47f96e8112..5a414b44dcd6165f9f9c7ba787e6f07a9c00432a 100644 (file)
@@ -6,18 +6,14 @@
  */
 static void PythonMouseCallback(ob::MouseData *data, void *pyfunc)
 {
-  PyObject *func, *arglist, *pdata;
-  PyObject *result;
-  double    dres = 0;
-
-  func = (PyObject*) pyfunc;
+  PyObject *arglist, *pdata, *result;
 
   pdata = SWIG_NewPointerObj((void *) data, SWIGTYPE_p_ob__MouseData, 0);
   arglist = Py_BuildValue("(O)", pdata);
   Py_DECREF(pdata);
 
   // call the callback
-  result = PyEval_CallObject(func, arglist);
+  result = PyEval_CallObject((PyObject*)pyfunc, arglist);
   if (!result || PyErr_Occurred()) {
     // an exception occured in the script, display it
     PyErr_Print();
@@ -32,18 +28,14 @@ static void PythonMouseCallback(ob::MouseData *data, void *pyfunc)
  */
 static void PythonKeyCallback(ob::KeyData *data, void *pyfunc)
 {
-  PyObject *func, *arglist, *pdata;
-  PyObject *result;
-  double    dres = 0;
-
-  func = (PyObject*) pyfunc;
+  PyObject *arglist, *pdata, *result;
 
   pdata = SWIG_NewPointerObj((void *) data, SWIGTYPE_p_ob__KeyData, 0);
   arglist = Py_BuildValue("(O)", pdata);
   Py_DECREF(pdata);
 
   // call the callback
-  result = PyEval_CallObject(func, arglist);
+  result = PyEval_CallObject((PyObject*)pyfunc, arglist);
   if (!result || PyErr_Occurred()) {
     // an exception occured in the script, display it
     PyErr_Print();
@@ -58,18 +50,14 @@ static void PythonKeyCallback(ob::KeyData *data, void *pyfunc)
  */
 static void PythonEventCallback(ob::EventData *data, void *pyfunc)
 {
-  PyObject *func, *arglist, *pdata;
-  PyObject *result;
-  double    dres = 0;
-
-  func = (PyObject*) pyfunc;
+  PyObject *arglist, *pdata, *result;
 
   pdata = SWIG_NewPointerObj((void *) data, SWIGTYPE_p_ob__EventData, 0);
   arglist = Py_BuildValue("(O)", pdata);
   Py_DECREF(pdata);
 
   // call the callback
-  result = PyEval_CallObject(func, arglist);
+  result = PyEval_CallObject((PyObject*)pyfunc, arglist);
   if (!result || PyErr_Occurred()) {
     // an exception occured in the script, display it
     PyErr_Print();
@@ -129,6 +117,7 @@ bool mbind(const std::string &button, ob::MouseContext::MC context,
     PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
     return false;
   }
+  Py_INCREF(func);
   return true;
 }
 
@@ -143,6 +132,7 @@ bool ebind(ob::EventAction::EA action, PyObject *func)
     PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
     return false;
   }
+  Py_INCREF(func);
   return true;
 }
 
@@ -153,6 +143,7 @@ bool kgrab(int screen, PyObject *func)
     PyErr_SetString(PyExc_RuntimeError,"Unable to grab keybaord.");
     return false;
   }
+  Py_INCREF(func);
   return true;
 }
 
@@ -202,6 +193,7 @@ bool kbind(PyObject *keylist, ob::KeyContext::KC context, PyObject *func)
     PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
     return false;
   }
+  Py_INCREF(func);
   return true;
 }
 
index b4c94622c7f93d7058449b0e30b46d88e9f4bb46..19360a4308e3193507afc23fc44b5f1ee8b3a879 100644 (file)
--- a/wrap/ob.i
+++ b/wrap/ob.i
@@ -68,8 +68,8 @@ void set_reset_key(const std::string &key)
 }
 
 void send_client_msg(Window target, Atom type, Window about,
-                     long data, long data1, long data2,
-                     long data3, long data4)
+                     long data=0, long data1=0, long data2=0,
+                     long data3=0, long data4=0)
 {
   XEvent e;
   e.xclient.type = ClientMessage;
@@ -87,7 +87,7 @@ void send_client_msg(Window target, Atom type, Window about,
              &e);
 }
 
-void execute(const std::string &bin, int screen)
+void execute(const std::string &bin, int screen=0)
 {
   if (screen >= ScreenCount(**otk::display))
     screen = 0;
This page took 0.036637 seconds and 4 git commands to generate.