diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-12-31 11:40:42 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-12-31 11:40:42 (GMT) |
commit | 8965133f188c817cbdf4fcf9d1f1b60462bbfe7d (patch) | |
tree | 96193fdbcb692790bb2ffe4de7b2020b0dbf528d /plugins/pychrysalide/glibext | |
parent | 93e9ab125bced1374c7d4a03e5bd11a0dc1b2968 (diff) |
Offered a custom configuration facility to each plugin.
Diffstat (limited to 'plugins/pychrysalide/glibext')
-rw-r--r-- | plugins/pychrysalide/glibext/configuration.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/plugins/pychrysalide/glibext/configuration.c b/plugins/pychrysalide/glibext/configuration.c index b7d8f82..235662d 100644 --- a/plugins/pychrysalide/glibext/configuration.c +++ b/plugins/pychrysalide/glibext/configuration.c @@ -515,28 +515,27 @@ static PyObject *py_config_param_get_value(PyObject *self, void *closure) ) param = G_CFG_PARAM(pygobject_get(self)); + type = g_config_param_get_ptype(param); + g_config_param_get_value(param, &value); + switch (type) { case CPT_BOOLEAN: - g_config_param_get_value(param, &value.boolean); result = (value.boolean ? Py_True : Py_False); Py_INCREF(result); break; case CPT_INTEGER: - g_config_param_get_value(param, &value.integer); result = PyLong_FromLong(value.integer); break; case CPT_ULONG: - g_config_param_get_value(param, &value.ulong); result = PyLong_FromUnsignedLong(value.ulong); break; case CPT_STRING: - g_config_param_get_value(param, &value.string); if (value.string != NULL) result = PyUnicode_FromString(value.string); else @@ -547,7 +546,6 @@ static PyObject *py_config_param_get_value(PyObject *self, void *closure) break; case CPT_COLOR: - g_config_param_get_value(param, &value.color); result = create_gdk_rgba(&value.color); break; @@ -602,7 +600,8 @@ static int py_config_param_set_value(PyObject *self, PyObject *value, void *clos case CPT_BOOLEAN: if (PyBool_Check(value)) { - pvalue.boolean = (value == Py_True); + pvalue.integer = (value == Py_True); + g_config_param_set_value(param, pvalue.integer); result = 0; } break; @@ -611,6 +610,7 @@ static int py_config_param_set_value(PyObject *self, PyObject *value, void *clos if (PyLong_Check(value)) { pvalue.integer = PyLong_AsLong(value); + g_config_param_set_value(param, pvalue.integer); result = 0; } break; @@ -619,6 +619,7 @@ static int py_config_param_set_value(PyObject *self, PyObject *value, void *clos if (PyLong_Check(value)) { pvalue.ulong = PyLong_AsUnsignedLong(value); + g_config_param_set_value(param, pvalue.ulong); result = 0; } break; @@ -627,13 +628,17 @@ static int py_config_param_set_value(PyObject *self, PyObject *value, void *clos if (PyUnicode_Check(value)) { pvalue.string = PyUnicode_DATA(value); + g_config_param_set_value(param, pvalue.string); result = 0; } break; case CPT_COLOR: if (convert_to_gdk_rgba(value, &pvalue.color) == 1) + { + g_config_param_set_value(param, &pvalue.color); result = 0; + } break; default: @@ -642,9 +647,6 @@ static int py_config_param_set_value(PyObject *self, PyObject *value, void *clos } - if (result == 0) - g_config_param_set_value(param, &pvalue); - } return result; @@ -1303,7 +1305,7 @@ static PyObject *py_generic_config_search(PyObject *self, PyObject *args) else { result = pygobject_new(G_OBJECT(param)); - g_object_unref(G_OBJECT(param)); + //g_object_unref(G_OBJECT(param)); } return result; @@ -1359,6 +1361,7 @@ static PyObject *py_generic_config_add(PyObject *self, PyObject *args) config = G_GEN_CONFIG(pygobject_get(self)); + g_object_ref(G_OBJECT(param)); added = _g_generic_config_add_param(config, param, lock); if (added == NULL) @@ -1369,7 +1372,7 @@ static PyObject *py_generic_config_add(PyObject *self, PyObject *args) else { result = pygobject_new(G_OBJECT(added)); - g_object_unref(G_OBJECT(added)); + //g_object_unref(G_OBJECT(added)); } return result; |