]> icculus.org git repositories - mikachu/openbox.git/blob - src/python_client.cc
python interface is working!
[mikachu/openbox.git] / src / python_client.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif
6
7 #include "python_client.hh"
8 #include "openbox.hh"
9
10 namespace ob {
11
12 extern "C" {
13
14 PyObject *getWindow(PyObject* self, PyObject* args)
15 {
16   if (!PyArg_ParseTuple(args, ":getWindow"))
17     return NULL;
18   return PyLong_FromLong(((PyClientObject*)self)->client->window());
19 }
20
21
22
23 static PyMethodDef attr_methods[] = {
24   {"getWindow", (PyCFunction)getWindow, METH_VARARGS,
25    "Return the window id."},
26   {NULL, NULL, 0, NULL}           /* sentinel */
27 };
28
29 static PyObject *getattr(PyObject *obj, char *name)
30 {
31   return Py_FindMethod(attr_methods, obj, name);
32 }
33
34
35
36 static void client_dealloc(PyObject* self)
37 {
38   PyObject_Del(self);
39 }
40
41 PyTypeObject PyClient_Type = {
42   PyObject_HEAD_INIT(NULL)
43   0,
44   "Client",
45   sizeof(PyClientObject),
46   0,
47   client_dealloc, /*tp_dealloc*/
48   0,          /*tp_print*/
49   getattr,    /*tp_getattr*/
50   0,          /*tp_setattr*/
51   0,          /*tp_compare*/
52   0,          /*tp_repr*/
53   0,          /*tp_as_number*/
54   0,          /*tp_as_sequence*/
55   0,          /*tp_as_mapping*/
56   0,          /*tp_hash */
57 };
58
59 }
60 }