[Xfce4-commits] <thunarx-python:master> Add support for importing pygtk as a PyCapsule. Some distributions with python 2.7+ will require this
Adam Plumb
noreply at xfce.org
Sat Mar 12 16:44:03 CET 2011
Updating branch refs/heads/master
to d458474c1ab9da75e2bdb9029fbb7c5456714a8d (commit)
from e72abc48093bcbae4807846ff5c89db0ba4dbe88 (commit)
commit d458474c1ab9da75e2bdb9029fbb7c5456714a8d
Author: Adam Plumb <adamplumb at gmail.com>
Date: Sat Mar 12 10:43:02 2011 -0500
Add support for importing pygtk as a PyCapsule. Some distributions with python 2.7+ will require this
src/thunarx-python.c | 32 +++++++++++++++++++++-----------
1 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/src/thunarx-python.c b/src/thunarx-python.c
index e9b35a2..3133511 100644
--- a/src/thunarx-python.c
+++ b/src/thunarx-python.c
@@ -82,20 +82,30 @@ thunarx_python_init_pygtk(void)
PyObject *pygtk = PyImport_ImportModule("gtk._gtk");
if (pygtk != NULL)
{
- PyObject *module_dict = PyModule_GetDict(pygtk);
- PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API");
- if (PyCObject_Check(cobject))
+#ifdef Py_CAPSULE_H
+ void *capsule = PyCapsule_Import("gtk._gtk._PyGtk_API", 0);
+ if (capsule)
{
- _PyGtk_API = (struct _PyGtk_FunctionStruct*)
- PyCObject_AsVoidPtr(cobject);
+ _PyGtk_API = (struct _PyGtk_FunctionStruct*)capsule;
}
- else
+#endif
+ if (!_PyGtk_API)
{
- PyErr_SetString(PyExc_RuntimeError,
- "could not find _PyGtk_API object");
- PyErr_Print();
- return FALSE;
- }
+ PyObject *module_dict = PyModule_GetDict(pygtk);
+ PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API");
+ if (PyCObject_Check(cobject))
+ {
+ _PyGtk_API = (struct _PyGtk_FunctionStruct*)
+ PyCObject_AsVoidPtr(cobject);
+ }
+ else
+ {
+ PyErr_SetString(PyExc_RuntimeError,
+ "could not find _PyGtk_API object");
+ PyErr_Print();
+ return FALSE;
+ }
+ }
}
else
{
More information about the Xfce4-commits
mailing list