diff options
| author | Dana Jansens <danakj@orodu.net> | 2002-12-19 23:54:41 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2002-12-19 23:54:41 +0000 |
| commit | 700984bd150d98a6876c117c2e1b1b3c72cffce1 (patch) | |
| tree | a4e89a9a84b4e1c76d83f1764404c3598f505789 /src/python_client.cc | |
| parent | 977ecf1f1e82f385a542648b545a0d0877febaf0 (diff) | |
python has begun!
Diffstat (limited to 'src/python_client.cc')
| -rw-r--r-- | src/python_client.cc | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/python_client.cc b/src/python_client.cc new file mode 100644 index 00000000..3758e427 --- /dev/null +++ b/src/python_client.cc @@ -0,0 +1,69 @@ +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- + +#ifdef HAVE_CONFIG_H +# include "../config.h" +#endif + +#include "python_client.hh" +#include "openbox.hh" + +namespace ob { + +extern "C" { + +PyObject *get_client_dict(PyObject* self, PyObject* args) +{ + if (!PyArg_ParseTuple(args, ":get_client_dict")) + return NULL; + return PyDictProxy_New(Openbox::instance->pyclients()); +} + + + +PyObject *getWindow(PyObject* self, PyObject* args) +{ + if (!PyArg_ParseTuple(args, ":getWindow")) + return NULL; + return PyLong_FromLong(((PyClientObject*)self)->window); +} + + + +static PyMethodDef attr_methods[] = { + {"getWindow", getWindow, METH_VARARGS, + "Return the window id."}, + {NULL, NULL, 0, NULL} /* sentinel */ +}; + +static PyObject *getattr(PyObject *obj, char *name) +{ + return Py_FindMethod(attr_methods, obj, name); +} + + + +static void client_dealloc(PyObject* self) +{ + PyObject_Del(self); +} + +PyTypeObject PyClient_Type = { + PyObject_HEAD_INIT(NULL) + 0, + "Client", + sizeof(PyClientObject), + 0, + client_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + getattr, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ +}; + +} +} |
