summaryrefslogtreecommitdiff
path: root/community/medit/capsule.diff
blob: 7ce4edab822b8ac620f2f57086dcbe22627f7863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- medit-1.0.0.orig/moo/moopython/moopython-pygtkmod.h	2010-12-22 05:11:46.000000000 +0100
+++ medit-1.0.0/moo/moopython/moopython-pygtkmod.h	2011-02-08 16:14:10.000000000 +0100
@@ -20,7 +20,7 @@
 G_GNUC_UNUSED static void
 init_pygtk_mod (void)
 {
-    PyObject *gobject, *pygtk;
+    PyObject *gobject;
     PyObject *mdict;
     PyObject *cobject;
 
@@ -29,7 +29,7 @@
 
     mdict = PyModule_GetDict (gobject);
     cobject = PyDict_GetItemString (mdict, "_PyGObject_API");
-
+    
     if (!cobject || !PyCObject_Check (cobject))
     {
         PyErr_SetString (PyExc_RuntimeError,
@@ -38,21 +38,13 @@
     }
 
     _PyGObject_API = (struct _PyGObject_Functions *) PyCObject_AsVoidPtr (cobject);
-
-    if (!(pygtk = PyImport_ImportModule("gtk._gtk")))
-        return;
-
-    mdict = PyModule_GetDict (pygtk);
-    cobject = PyDict_GetItemString (mdict, "_PyGtk_API");
-
-    if (!cobject || !PyCObject_Check (cobject))
-    {
-        PyErr_SetString (PyExc_RuntimeError,
-                         "could not find _PyGtk_API object");
+    
+    void *capsule = PyCapsule_Import("gtk._gtk._PyGtk_API", 0);
+    if (!capsule) {
         return;
     }
-
-    _PyGtk_API = (struct _PyGtk_FunctionStruct*) PyCObject_AsVoidPtr (cobject);
+    
+    _PyGtk_API = (struct _PyGtk_FunctionStruct*) capsule;
 }