summaryrefslogtreecommitdiff
path: root/gi/pygi-info.c
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2013-10-04 13:36:11 -0700
committerSimon Feltman <sfeltman@src.gnome.org>2013-10-07 14:38:15 -0700
commite7b758badd0ab0b147117859f7871c39fb5399c1 (patch)
treebc6b4f38dcee697b32e3f28e28e4a2535eb0bf84 /gi/pygi-info.c
parentd2aef364de778da966bc1cfffe184d649f9ebb21 (diff)
downloadpygobject-e7b758badd0ab0b147117859f7871c39fb5399c1.tar.gz
Move info string retrieval into generic function
Add get_info_string for sharing binding of simple string retrieval on GIBaseInfo objects. https://bugzilla.gnome.org/show_bug.cgi?id=709008
Diffstat (limited to 'gi/pygi-info.c')
-rw-r--r--gi/pygi-info.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 636b16d6..db963a07 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -54,6 +54,17 @@ _generate_doc_string(PyGIBaseInfo *self)
}
static PyObject *
+_get_info_string (PyGIBaseInfo *self,
+ const gchar* (*get_info_string)(GIBaseInfo*))
+{
+ const gchar *value = get_info_string ((GIBaseInfo*)self->info);
+ if (value == NULL) {
+ Py_RETURN_NONE;
+ }
+ return PYGLIB_PyUnicode_FromString (value);
+}
+
+static PyObject *
_get_child_info (PyGIBaseInfo *self,
GIBaseInfo* (*get_child_info)(GIBaseInfo*))
{
@@ -227,13 +238,13 @@ _wrap_g_base_info_get_name (PyGIBaseInfo *self)
static PyObject *
_wrap_g_base_info_get_name_unescaped (PyGIBaseInfo *self)
{
- return PYGLIB_PyUnicode_FromString (g_base_info_get_name (self->info));
+ return _get_info_string (self, g_base_info_get_name);
}
static PyObject *
_wrap_g_base_info_get_namespace (PyGIBaseInfo *self)
{
- return PYGLIB_PyUnicode_FromString (g_base_info_get_namespace (self->info));
+ return _get_info_string (self, g_base_info_get_namespace);
}
static PyObject *