From: Sadrul Habib Chowdhury Date: Fri, 12 Jun 2009 20:55:07 +0000 (-0400) Subject: Function to compare windows. X-Git-Url: https://repo.or.cz/w/screen-lua.git/commitdiff_plain/df5b7de831fd8b7ba65117cc8c4073abf607d01c Function to compare windows. --- diff --git a/src/python.c b/src/python.c index ce59f39..358abc9 100644 --- a/src/python.c +++ b/src/python.c @@ -64,6 +64,10 @@ typedef struct PyObject * (*conv)(void *); } SPyClosure; + +#define compare_display NULL +#define compare_callback NULL + #define REGISTER_TYPE(type, Type, closures, methods) \ static int \ register_##type(PyObject *module) \ @@ -80,6 +84,7 @@ register_##type(PyObject *module) \ } \ PyType##Type.tp_getset = getsets; \ PyType##Type.tp_methods = methods; \ + PyType##Type.tp_compare = compare_##type; \ PyType_Ready(&PyType##Type); \ Py_INCREF(&PyType##Type); \ PyModule_AddObject(module, #Type, (PyObject *)&PyType##Type); \ @@ -151,6 +156,15 @@ static PyMethodDef wmethods[] = { {NULL}, }; +static int +compare_window(PyWindow *one, PyWindow *two) +{ + struct win *wone = one->_obj; + struct win *wtwo = two->_obj; + + return wtwo->w_number - wone->w_number; +} + REGISTER_TYPE(window, Window, wclosures, wmethods) #undef SPY_CLOSURE /** }}} */