commit 4c94b229454fc50aada030922807eb6c616e6a67
parent 6485c26de2ee8e935cfde0af28e57f8d14fc41b4
Author: Holger Berndt <hb@claws-mail.org>
Date: Sat, 27 Jul 2013 17:25:54 +0200
Python plugin: Let Account objects compare equal if they refer to the same account
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c
@@ -52,6 +52,16 @@ static void Account_dealloc(clawsmail_AccountObject* self)
self->ob_type->tp_free((PyObject*)self);
}
+static int Account_compare(clawsmail_AccountObject *obj1, clawsmail_AccountObject *obj2)
+{
+ if(obj1->account->account_id < obj2->account->account_id)
+ return -1;
+ else if(obj1->account->account_id > obj2->account->account_id)
+ return 1;
+ else
+ return 0;
+}
+
static PyObject* Account_str(PyObject *self)
{
PyObject *str;
@@ -106,7 +116,7 @@ static PyTypeObject clawsmail_AccountType = {
0, /* tp_print*/
0, /* tp_getattr*/
0, /* tp_setattr*/
- 0, /* tp_compare*/
+ (cmpfunc)Account_compare, /* tp_compare*/
0, /* tp_repr*/
0, /* tp_as_number*/
0, /* tp_as_sequence*/