]> Dogcows Code - chaz/openbox/blob - src/python_client.cc
python has begun!
[chaz/openbox] / 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 *get_client_dict(PyObject* self, PyObject* args)
15 {
16 if (!PyArg_ParseTuple(args, ":get_client_dict"))
17 return NULL;
18 return PyDictProxy_New(Openbox::instance->pyclients());
19 }
20
21
22
23 PyObject *getWindow(PyObject* self, PyObject* args)
24 {
25 if (!PyArg_ParseTuple(args, ":getWindow"))
26 return NULL;
27 return PyLong_FromLong(((PyClientObject*)self)->window);
28 }
29
30
31
32 static PyMethodDef attr_methods[] = {
33 {"getWindow", getWindow, METH_VARARGS,
34 "Return the window id."},
35 {NULL, NULL, 0, NULL} /* sentinel */
36 };
37
38 static PyObject *getattr(PyObject *obj, char *name)
39 {
40 return Py_FindMethod(attr_methods, obj, name);
41 }
42
43
44
45 static void client_dealloc(PyObject* self)
46 {
47 PyObject_Del(self);
48 }
49
50 PyTypeObject PyClient_Type = {
51 PyObject_HEAD_INIT(NULL)
52 0,
53 "Client",
54 sizeof(PyClientObject),
55 0,
56 client_dealloc, /*tp_dealloc*/
57 0, /*tp_print*/
58 getattr, /*tp_getattr*/
59 0, /*tp_setattr*/
60 0, /*tp_compare*/
61 0, /*tp_repr*/
62 0, /*tp_as_number*/
63 0, /*tp_as_sequence*/
64 0, /*tp_as_mapping*/
65 0, /*tp_hash */
66 };
67
68 }
69 }
This page took 0.036817 seconds and 4 git commands to generate.