X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fpython.cc;h=c463fdc824d0edca37e2465a09f9cdc31757fa64;hb=40449e199dfeab57e8d147e07989aef339a7da59;hp=e5224921a1ee327e36efea20899c3e7f81912460;hpb=a9a5f0d7510be5dbf8ae1db99e6c1c01035503d9;p=chaz%2Fopenbox diff --git a/src/python.cc b/src/python.cc index e5224921..c463fdc8 100644 --- a/src/python.cc +++ b/src/python.cc @@ -352,6 +352,11 @@ void python_init(char *argv0) PyRun_SimpleString("from _otk import *; from _openbox import *;"); PyRun_SimpleString("openbox = Openbox_instance()"); + /* XXX + sys.path.append('stuff') + install the .py wrappers, and include their path with this, then import em + */ + // set up access to the python global variables PyObject *obmodule = PyImport_AddModule("__main__"); obdict = PyModule_GetDict(obmodule); @@ -491,13 +496,17 @@ PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func) Py_INCREF(Py_None); return Py_None; } -PyObject *kunbind(PyObject *keylist) +PyObject *kunbind(PyObject *keylist, PyObject *func) { if (!PyList_Check(keylist)) { PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list."); return NULL; } - + if (!PyCallable_Check(func)) { + PyErr_SetString(PyExc_TypeError, "Invalid callback function."); + return NULL; + } + ob::OBBindings::StringVect vectkeylist; for (int i = 0, end = PyList_Size(keylist); i < end; ++i) { PyObject *str = PyList_GetItem(keylist, i); @@ -509,7 +518,10 @@ PyObject *kunbind(PyObject *keylist) vectkeylist.push_back(PyString_AsString(str)); } - ob::Openbox::instance->bindings()->removeKey(vectkeylist); + if (!ob::Openbox::instance->bindings()->removeKey(vectkeylist, func)) { + PyErr_SetString(PyExc_RuntimeError, "Could not remove callback."); + return NULL; + } Py_INCREF(Py_None); return Py_None; }