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
     {