[nautilus-python] Fixes bug #633171. Get nautilus-python to compile under python 2.7 by using PyCapsule to load pygtk.



commit c2556161eff88ee42563d9e64a529c420d167b6a
Author: Adam Plumb <adamplumb gmail com>
Date:   Thu Jan 13 11:12:19 2011 -0500

    Fixes bug #633171.
    Get nautilus-python to compile under python 2.7 by using PyCapsule to load pygtk.

 src/nautilus-python.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-python.c b/src/nautilus-python.c
index aad10a1..f348edd 100644
--- a/src/nautilus-python.c
+++ b/src/nautilus-python.c
@@ -76,6 +76,15 @@ np_init_pygtk(void)
     PyObject *pygtk = PyImport_ImportModule("gtk._gtk");
     if (pygtk != NULL)
     {
+#ifdef Py_CAPSULE_H
+		void *capsule = PyCapsule_Import("gtk._gtk._PyGtk_API", 0);
+		if (capsule)
+		{
+			_PyGtk_API = (struct _PyGtk_FunctionStruct*)capsule;
+		}
+		else
+		{
+#else
 		PyObject *module_dict = PyModule_GetDict(pygtk);
 		PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API");
 		if (PyCObject_Check(cobject))
@@ -85,11 +94,12 @@ np_init_pygtk(void)
 		}
 		else
 		{
-            PyErr_SetString(PyExc_RuntimeError,
-                            "could not find _PyGtk_API object");
+#endif
+		    PyErr_SetString(PyExc_RuntimeError,
+		                    "could not find _PyGtk_API object");
 			PyErr_Print();
 			return FALSE;
-        }
+		}
     }
     else
     {



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