[nautilus-python/nautilus-3.0] Fixes bug #660348. Add pygobject3 compatibility and break pygobject2 compatibility



commit 44eb623b1c43917d710ed144d172f30b6cfb245e
Author: Adam Plumb <adamplumb gmail com>
Date:   Wed Oct 5 13:21:36 2011 -0400

    Fixes bug #660348. Add pygobject3 compatibility and break pygobject2 compatibility

 configure.in          |    8 ++++----
 src/nautilus-python.c |   34 +++++-----------------------------
 2 files changed, 9 insertions(+), 33 deletions(-)
---
diff --git a/configure.in b/configure.in
index 407b0c5..1428a0e 100644
--- a/configure.in
+++ b/configure.in
@@ -40,16 +40,16 @@ AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
 AM_CHECK_PYTHON_LIBS(,[AC_MSG_ERROR(could not find Python lib)])
 
 
-PKG_CHECK_MODULES(NAUTILUS_PYTHON, [pygobject-2.0 >= $PYGOBJECT_REQUIRED
+PKG_CHECK_MODULES(NAUTILUS_PYTHON, [pygobject-3.0 >= $PYGOBJECT_REQUIRED
                                    libnautilus-extension >= $NAUTILUS_REQUIRED])
 
-PYGOBJECT_DATADIR=`$PKG_CONFIG --variable=datadir pygobject-2.0`
+PYGOBJECT_DATADIR=`$PKG_CONFIG --variable=datadir pygobject-3.0`
 AC_SUBST(PYGOBJECT_DATADIR)
 
-PYGOBJECT_PYGDOCS="`$PKG_CONFIG --variable=pygdocs pygobject-2.0`"
+PYGOBJECT_PYGDOCS="`$PKG_CONFIG --variable=pygdocs pygobject-3.0`"
 AC_SUBST(PYGOBJECT_PYGDOCS)
 
-PYGOBJECT_FIXXREF="$PYTHON `$PKG_CONFIG --variable=fixxref pygobject-2.0`"
+PYGOBJECT_FIXXREF="$PYTHON `$PKG_CONFIG --variable=fixxref pygobject-3.0`"
 AC_SUBST(PYGOBJECT_FIXXREF)
 
 NAUTILUS_LIBDIR=`$PKG_CONFIG --variable=libdir libnautilus-extension`
diff --git a/src/nautilus-python.c b/src/nautilus-python.c
index 0e00285..ef89e3e 100644
--- a/src/nautilus-python.c
+++ b/src/nautilus-python.c
@@ -45,37 +45,13 @@ static GArray *all_types = NULL;
 static inline gboolean 
 np_init_pygobject(void)
 {
-#ifdef Py_CAPSULE_H
-		void *capsule = PyCapsule_Import("gobject._PyGObject_API", 0);
-		if (capsule)
-		{
-			_PyGObject_API = (struct _PyGObject_Functions*)capsule;
-			return TRUE;
-		}
-#endif
-    PyObject *gobject = PyImport_ImportModule("gobject");
-    if (gobject != NULL)
-    {
-        PyObject *mdict = PyModule_GetDict(gobject);
-        PyObject *cobject = PyDict_GetItemString(mdict, "_PyGObject_API");
-        if (PyCObject_Check(cobject))
-        {
-            _PyGObject_API = (struct _PyGObject_Functions *)PyCObject_AsVoidPtr(cobject);
-        }
-        else
-        {
-            PyErr_SetString(PyExc_RuntimeError,
-                            "could not find _PyGObject_API object");
-			PyErr_Print();
-			return FALSE;
-        }
-    }
-    else
-    {
-        PyErr_Print();
-        g_warning("could not import gobject");
+    PyObject *gobject = pygobject_init (3, 0, 0);
+
+    if (gobject == NULL) {
+        PyErr_Print ();
         return FALSE;
     }
+
 	return TRUE;
 }
 



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