From f0751ff3c51d2aac3c074b5e8a96e80ce06040e3 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Fri, 12 Jun 2009 02:35:58 -0400 Subject: screen.displays() returns a list(?) of displays. --- src/python.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/python.c b/src/python.c index 4e4449a..5f54940 100644 --- a/src/python.c +++ b/src/python.c @@ -38,7 +38,7 @@ #include extern struct win *windows; -extern struct display *display; +extern struct display *display, *displays; static PyObject * SPy_Get(PyObject *obj, void *closure); static PyObject * SPy_Set(PyObject *obj, PyObject *value, void *closure); @@ -196,6 +196,21 @@ screen_display(PyObject *self) return PyObject_FromDisplay(display); } +static PyObject * +screen_displays(PyObject *self) +{ + struct display *d = displays; + int count = 0; + for (; d; d = d->d_next) + ++count; + PyObject *tuple = PyTuple_New(count); + + for (d = displays, count = 0; d; d = d->d_next, ++count) + PyTuple_SetItem(tuple, count, PyObject_FromDisplay(d)); + + return tuple; +} + static PyObject * screen_windows(PyObject *self) { @@ -213,6 +228,7 @@ screen_windows(PyObject *self) const PyMethodDef py_methods[] = { {"display", (PyCFunction)screen_display, METH_NOARGS, NULL}, + {"displays", (PyCFunction)screen_displays, METH_NOARGS, NULL}, {"windows", (PyCFunction)screen_windows, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL} }; -- cgit v1.2.1