diff options
Diffstat (limited to 'plugins/pychrysalide/gtkext')
-rw-r--r-- | plugins/pychrysalide/gtkext/dockable.c | 32 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/graph/cluster.c | 6 |
2 files changed, 5 insertions, 33 deletions
diff --git a/plugins/pychrysalide/gtkext/dockable.c b/plugins/pychrysalide/gtkext/dockable.c index 8bb26b7..1412589 100644 --- a/plugins/pychrysalide/gtkext/dockable.c +++ b/plugins/pychrysalide/gtkext/dockable.c @@ -299,8 +299,6 @@ static GtkWidget *py_dockable_get_widget_wrapper(const GtkDockable *dockable) PyGILState_STATE gstate; /* Sauvegarde d'environnement */ PyObject *pyobj; /* Objet Python concerné */ PyObject *pyret; /* Bilan de consultation */ - PyObject *gtk_mod; /* Module Python Gtk */ - PyObject *widget_type; /* Module "GtkWidget" */ int ret; /* Bilan d'une conversion */ #define DOCKABLE_GET_WIDGET_WRAPPER PYTHON_WRAPPER_DEF \ @@ -312,6 +310,8 @@ static GtkWidget *py_dockable_get_widget_wrapper(const GtkDockable *dockable) "The result has to be a Gtk.Widget instance." \ ) + result = NULL; + gstate = PyGILState_Ensure(); pyobj = pygobject_new(G_OBJECT(dockable)); @@ -322,32 +322,10 @@ static GtkWidget *py_dockable_get_widget_wrapper(const GtkDockable *dockable) if (pyret != NULL) { - gtk_mod = PyImport_ImportModule("gi.repository.Gtk"); - - if (gtk_mod == NULL) - { - PyErr_SetString(PyExc_TypeError, "unable to find the Gtk Python module"); - goto done; - } - - widget_type = PyObject_GetAttrString(gtk_mod, "Widget"); - - Py_DECREF(gtk_mod); - - ret = PyObject_TypeCheck(pyret, (PyTypeObject *)widget_type); - - Py_DECREF(widget_type); - - if (!ret) - { - PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to GTK widget"); - goto done; - } - - result = GTK_WIDGET(pygobject_get(pyret)); - g_object_ref(G_OBJECT(result)); + ret = convert_to_gtk_widget(pyret, &result); - done: + if (ret == 1) + g_object_ref(G_OBJECT(result)); Py_DECREF(pyret); diff --git a/plugins/pychrysalide/gtkext/graph/cluster.c b/plugins/pychrysalide/gtkext/graph/cluster.c index c87655a..fc73276 100644 --- a/plugins/pychrysalide/gtkext/graph/cluster.c +++ b/plugins/pychrysalide/gtkext/graph/cluster.c @@ -161,12 +161,6 @@ static PyObject *py_graph_cluster_find_by_widget(PyObject *self, PyObject *args) if (!ret) return NULL; - if (!GTK_IS_WIDGET(pygobject_get(widget_obj))) - { - PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to GTK widget"); - return NULL; - } - cluster = G_GRAPH_CLUSTER(pygobject_get(self)); widget = GTK_WIDGET(pygobject_get(widget_obj)); |