Function to compare windows.
authorSadrul Habib Chowdhury <sadrul@users.sourceforge.net>
Fri, 12 Jun 2009 20:55:07 +0000 (12 16:55 -0400)
committerSadrul Habib Chowdhury <sadrul@users.sourceforge.net>
Fri, 12 Jun 2009 20:55:07 +0000 (12 16:55 -0400)
src/python.c

index ce59f39..358abc9 100644 (file)
@@ -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
 /** }}} */