1 /* Python scripting support
3 * Copyright (c) 2009 Sadrul Habib Chowdhury (sadrul@users.sf.net)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program (see the file COPYING); if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
20 ****************************************************************
22 #include <sys/types.h>
39 extern struct win
*windows
;
42 screen_windows(PyObject
*self
)
44 struct win
*w
= windows
;
46 for (; w
; w
= w
->w_next
)
48 PyObject
*tuple
= PyTuple_New(count
);
50 for (w
= windows
, count
= 0; w
; w
= w
->w_next
, ++count
)
52 PyObject
*name
= PyString_FromString(w
->w_title
);
53 PyTuple_SetItem(tuple
, count
, name
);
59 const PyMethodDef py_methods
[] = {
60 {"windows", (PyCFunction
)screen_windows
, METH_NOARGS
, NULL
},
68 Py_InitModule3 ("screen", py_methods
, NULL
);
80 SPySource(const char *file
, int async
)
82 FILE *f
= fopen(file
, "rb");
83 int ret
= PyRun_SimpleFile(f
, file
);
87 return 1; /* Success */
98 struct binding py_binding
=