summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/gtkext
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/gtkext')
-rw-r--r--plugins/pychrysalide/gtkext/easygtk.c40
1 files changed, 5 insertions, 35 deletions
diff --git a/plugins/pychrysalide/gtkext/easygtk.c b/plugins/pychrysalide/gtkext/easygtk.c
index a489cd1..34b917f 100644
--- a/plugins/pychrysalide/gtkext/easygtk.c
+++ b/plugins/pychrysalide/gtkext/easygtk.c
@@ -67,19 +67,16 @@ static PyObject *py_easygtk_get_nth_contained_child(PyObject *, PyObject *);
static PyObject *py_easygtk_get_color_from_style(PyObject *self, PyObject *args)
{
- PyObject *result; /* Désignation à retourner */
+ PyObject *result; /* Coloration à retourner */
const char *class; /* Classe de style GTK */
int background; /* Nature du traitement */
int ret; /* Bilan de lecture des args. */
GdkRGBA color; /* Couleur obtenue */
bool status; /* Bilan de la récupération */
- PyObject *gdk_mod; /* Module Python Gdk */
- PyObject *rgba_type; /* Classe "GtkRGBA" */
- PyObject *rgba_args; /* Arguments pour l'appel */
-#define EASYGTK_GET_COLOR_FROM_STYLE_METHOD PYTHON_METHOD_DEF \
+#define EASYGTK_GET_COLOR_FROM_STYLE_METHOD PYTHON_METHOD_DEF \
( \
- get_color_from_style, "cls, background, /", \
+ get_color_from_style, "cls, background, /", \
METH_VARARGS | METH_STATIC, py_easygtk, \
"Find the index of a given child widget inside a GTK container" \
" children.\n" \
@@ -96,37 +93,10 @@ static PyObject *py_easygtk_get_color_from_style(PyObject *self, PyObject *args)
status = get_color_from_style(class, background, &color);
if (status)
- {
- gdk_mod = PyImport_ImportModule("gi.repository.Gdk");
-
- if (gdk_mod == NULL)
- {
- PyErr_SetString(PyExc_TypeError, "unable to find the Gtk Python module");
- goto done;
- }
-
- rgba_type = PyObject_GetAttrString(gdk_mod, "RGBA");
-
- Py_DECREF(gdk_mod);
-
- rgba_args = PyTuple_New(4);
- PyTuple_SetItem(rgba_args, 0, PyFloat_FromDouble(color.red));
- PyTuple_SetItem(rgba_args, 1, PyFloat_FromDouble(color.green));
- PyTuple_SetItem(rgba_args, 2, PyFloat_FromDouble(color.blue));
- PyTuple_SetItem(rgba_args, 3, PyFloat_FromDouble(color.alpha));
-
- result = PyObject_CallObject(rgba_type, rgba_args);
-
- Py_DECREF(rgba_args);
-
- }
+ result = create_gdk_rgba(&color);
else
- {
- done:
- result = Py_None;
- Py_INCREF(result);
- }
+ result = NULL;
return result;