[pygobject/gsoc2009: 121/160] Make gobject aware of gi.repository when creating object wrappers



commit 0b4e55e4cbd4889ab7c441675c77a8e8b94447b2
Author: Simon van der Linden <svdlinden src gnome org>
Date:   Thu Aug 6 16:47:18 2009 +0200

    Make gobject aware of gi.repository when creating object wrappers

 gobject/pygobject.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gobject/pygobject.c b/gobject/pygobject.c
index 17f6886..3572f71 100644
--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -25,6 +25,9 @@
 #endif
 
 #include <pyglib.h>
+#if HAVE_GIREPOSITORY_H
+#   include <pygi.h>
+#endif
 #include "pygobject-private.h"
 #include "pyginterface.h"
 #include "pygparamspec.h"
@@ -957,10 +960,29 @@ pygobject_new_full(GObject *obj, gboolean sink, gpointer g_class)
         if (inst_data)
             tp = inst_data->type;
         else {
+#if HAVE_GIREPOSITORY_H
+            GIRepository *repository;
+            GType g_type;
+            GIBaseInfo *info;
+
+            repository = g_irepository_get_default();
+
+            g_type = G_OBJECT_TYPE(obj);
+            info = g_irepository_find_by_gtype(repository, g_type);
+
+            if (info != NULL) {
+                pygi_import();
+                tp = (PyTypeObject *)pygi_type_find_by_info(info);
+                g_base_info_unref(info);
+            } else {
+#endif
             if (g_class)
                 tp = pygobject_lookup_class(G_OBJECT_CLASS_TYPE(g_class));
             else
                 tp = pygobject_lookup_class(G_OBJECT_TYPE(obj));
+#if HAVE_GIREPOSITORY_H
+            }
+#endif
         }
         g_assert(tp != NULL);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]