[pybank] Make sure the wrapper class has been registered
- From: Johan Dahlin <johan src gnome org>
- To: svn-commits-list gnome org
- Subject: [pybank] Make sure the wrapper class has been registered
- Date: Tue, 2 Jun 2009 10:46:08 -0400 (EDT)
commit 9547149a9fa45deddde6215726c390fe3be78c48
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date: Thu May 21 17:27:21 2009 +0200
Make sure the wrapper class has been registered
---
bank/bank-argument.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/bank/bank-argument.c b/bank/bank-argument.c
index b9c55d5..76745d4 100644
--- a/bank/bank-argument.c
+++ b/bank/bank-argument.c
@@ -285,6 +285,25 @@ pyg_argument_to_pyobject(GArgument *arg, GITypeInfo *type_info)
GValue value;
GObject* obj = arg->v_pointer;
GType gtype = G_OBJECT_TYPE(obj);
+ GIRepository *repo = g_irepository_get_default();
+ GIBaseInfo *object_info = g_irepository_find_by_gtype(repo, gtype);
+ const gchar *module_name;
+ const gchar *type_name;
+
+ if (object_info == NULL) {
+ // TODO: can we do something smarter here?
+ g_warning("g_irepository_find_by_gtype failed to return an info for %s",
+ g_type_name(gtype));
+ } else {
+ module_name = g_base_info_get_namespace(object_info);
+ type_name = g_base_info_get_name(object_info);
+
+ // This will make sure the wrapper class is registered.
+ char buf[250];
+ snprintf(buf, sizeof(buf), "%s.%s", module_name, type_name);
+ PyRun_SimpleString(buf);
+ }
+
value.g_type = gtype;
value.data[0].v_pointer = obj;
return pyg_value_as_pyobject(&value, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]