pygobject r941 - in trunk: . gio tests
- From: paulp svn gnome org
- To: svn-commits-list gnome org
- Subject: pygobject r941 - in trunk: . gio tests
- Date: Mon, 11 Aug 2008 20:17:12 +0000 (UTC)
Author: paulp
Date: Mon Aug 11 20:17:12 2008
New Revision: 941
URL: http://svn.gnome.org/viewvc/pygobject?rev=941&view=rev
Log:
2008-08-11 Paul Pogonyshev <pogonyshev gmx net>
Bug 547104 â improve type wrapper creation
* gio/gappinfo.override (_wrap_g_app_info_tp_richcompare)
(_wrap_g_app_info_tp_repr): New functions.
* tests/test_gio.py (TestAppInfo.test_eq): New test.
Modified:
trunk/ChangeLog
trunk/gio/gappinfo.override
trunk/tests/test_gio.py
Modified: trunk/gio/gappinfo.override
==============================================================================
--- trunk/gio/gappinfo.override (original)
+++ trunk/gio/gappinfo.override Mon Aug 11 20:17:12 2008
@@ -158,3 +158,51 @@
return PyBool_FromLong(ret);
}
+%%
+override-slot GAppInfo.tp_richcompare
+static PyObject *
+_wrap_g_app_info_tp_richcompare(PyGObject *self, PyGObject *other, int op)
+{
+ PyObject *result;
+
+ if (PyObject_TypeCheck(self, &PyGAppInfo_Type)
+ && PyObject_TypeCheck(other, &PyGAppInfo_Type)) {
+ GAppInfo *info1 = G_APP_INFO(self->obj);
+ GAppInfo *info2 = G_APP_INFO(other->obj);
+
+ switch (op) {
+ case Py_EQ:
+ result = (g_app_info_equal(info1, info2)
+ ? Py_True : Py_False);
+ break;
+ case Py_NE:
+ result = (!g_app_info_equal(info1, info2)
+ ? Py_True : Py_False);
+ break;
+ default:
+ result = Py_NotImplemented;
+ }
+ }
+ else
+ result = Py_NotImplemented;
+
+ Py_INCREF(result);
+ return result;
+}
+%%
+override-slot GAppInfo.tp_repr
+static PyObject *
+_wrap_g_app_info_tp_repr(PyGObject *self)
+{
+ const char *name = g_app_info_get_name(G_APP_INFO(self->obj));
+ gchar *representation;
+ PyObject *result;
+
+ representation = g_strdup_printf("<%s at %p: %s>",
+ self->ob_type->tp_name, self,
+ name ? name : "UNKNOWN NAME");
+
+ result = PyString_FromString(representation);
+ g_free(representation);
+ return result;
+}
Modified: trunk/tests/test_gio.py
==============================================================================
--- trunk/tests/test_gio.py (original)
+++ trunk/tests/test_gio.py Mon Aug 11 20:17:12 2008
@@ -678,6 +678,14 @@
self.assertEquals(self.appinfo.get_description(),
"Custom definition for does-not-exist")
+ def test_eq(self):
+ info1 = gio.app_info_get_all()[0]
+ info2 = info1.dup()
+ self.assert_(info1 is not info2)
+ self.assertEquals(info1, info2)
+
+ self.assertNotEqual(gio.app_info_get_all()[0], gio.app_info_get_all()[1])
+
class TestVfs(unittest.TestCase):
def setUp(self):
self.vfs = gio.vfs_get_default()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]