[pygobject] [API add] Add ObjectInfo.get_abstract method
- From: Simon Feltman <sfeltman src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] [API add] Add ObjectInfo.get_abstract method
- Date: Mon, 17 Sep 2012 10:27:57 +0000 (UTC)
commit be4a0682bdd189ee908ab1961001f759a80e133c
Author: Simon Feltman <s feltman gmail com>
Date: Sun Sep 16 17:27:25 2012 -0700
[API add] Add ObjectInfo.get_abstract method
Adds exposure of g_object_info_get_abstract to python for
helping with analysis of non-constructable objects from
within python.
https://bugzilla.gnome.org/show_bug.cgi?id=675581
gi/pygi-info.c | 8 ++++++++
tests/test_gi.py | 12 ++++++++++++
2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index a4570ed..dfcaf55 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -1069,6 +1069,13 @@ _wrap_g_object_info_get_vfuncs (PyGIBaseInfo *self)
return _get_vfuncs (self, GI_INFO_TYPE_OBJECT);
}
+static PyObject *
+_wrap_g_object_info_get_abstract (PyGIBaseInfo *self)
+{
+ gboolean is_abstract = g_object_info_get_abstract ( (GIObjectInfo*) self->info);
+ return PyBool_FromLong (is_abstract);
+}
+
static PyMethodDef _PyGIObjectInfo_methods[] = {
{ "get_parent", (PyCFunction) _wrap_g_object_info_get_parent, METH_NOARGS },
{ "get_methods", (PyCFunction) _wrap_g_object_info_get_methods, METH_NOARGS },
@@ -1076,6 +1083,7 @@ static PyMethodDef _PyGIObjectInfo_methods[] = {
{ "get_interfaces", (PyCFunction) _wrap_g_object_info_get_interfaces, METH_NOARGS },
{ "get_constants", (PyCFunction) _wrap_g_object_info_get_constants, METH_NOARGS },
{ "get_vfuncs", (PyCFunction) _wrap_g_object_info_get_vfuncs, METH_NOARGS },
+ { "get_abstract", (PyCFunction) _wrap_g_object_info_get_abstract, METH_NOARGS },
{ NULL, NULL, 0 }
};
diff --git a/tests/test_gi.py b/tests/test_gi.py
index a4e09a2..ea58547 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2394,3 +2394,15 @@ class TestProjectVersion(unittest.TestCase):
self.assertRaises(ValueError, gi.check_version, "99.0.0")
gi.check_version((3, 3, 5))
gi.check_version("3.3.5")
+
+
+class TestObjectInfo(unittest.TestCase):
+ def test_get_abstract_with_abstract(self):
+ repo = gi.gi.Repository.get_default()
+ info = repo.find_by_name('GObject', 'TypeModule')
+ self.assertTrue(info.get_abstract())
+
+ def test_get_abstract_with_concrete(self):
+ repo = gi.gi.Repository.get_default()
+ info = repo.find_by_name('GObject', 'Object')
+ self.assertFalse(info.get_abstract())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]