summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2009-06-12 02:35:58 -0400
committerSadrul Habib Chowdhury <sadrul@users.sourceforge.net>2009-06-12 02:35:58 -0400
commitf0751ff3c51d2aac3c074b5e8a96e80ce06040e3 (patch)
tree9b8f84bdeaf9c87eb38e6a8368c390e6f07422a3
parentd7a0601fad197c1cfd6c3d11f454bff8a5c793c8 (diff)
downloadscreen-f0751ff3c51d2aac3c074b5e8a96e80ce06040e3.tar.gz
screen.displays() returns a list(?) of displays.
-rw-r--r--src/python.c18
1 files changed, 17 insertions, 1 deletions
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 <structmember.h>
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);
@@ -197,6 +197,21 @@ screen_display(PyObject *self)
}
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)
{
struct win *w = windows;
@@ -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}
};