[gegl] gegl: handle UINT properties in gegl-xml and gegl-serialize
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl: handle UINT properties in gegl-xml and gegl-serialize
- Date: Thu, 26 Apr 2018 19:29:21 +0000 (UTC)
commit 2e6f34798918167797e7287d9501d0cd6cd1dd0d
Author: Ell <ell_se yahoo com>
Date: Thu Apr 26 15:23:58 2018 -0400
gegl: handle UINT properties in gegl-xml and gegl-serialize
Commit 1d6e841d78b3634fa186e6dde87b6fec126fed9f changed the type of
seed properties from INT to UINT, so we need to add UINT handling
in XML and chain strings.
gegl/gegl-serialize.c | 41 +++++++++++++++++++++++++++++++++++------
gegl/gegl-xml.c | 12 ++++++++++++
2 files changed, 47 insertions(+), 6 deletions(-)
---
diff --git a/gegl/gegl-serialize.c b/gegl/gegl-serialize.c
index ce79fe7..29119f1 100644
--- a/gegl/gegl-serialize.c
+++ b/gegl/gegl-serialize.c
@@ -432,8 +432,9 @@ gegl_create_chain_argv (char **ops,
}
else
if (g_type_is_a (target_type, G_TYPE_DOUBLE) ||
- g_type_is_a (target_type, G_TYPE_FLOAT) ||
- g_type_is_a (target_type, G_TYPE_INT))
+ g_type_is_a (target_type, G_TYPE_FLOAT) ||
+ g_type_is_a (target_type, G_TYPE_INT) ||
+ g_type_is_a (target_type, G_TYPE_UINT))
{
if (strstr (value, "rel"))
{
@@ -451,6 +452,9 @@ gegl_create_chain_argv (char **ops,
if (g_type_is_a (target_type, G_TYPE_INT))
gegl_node_set (iter[level], key,
(int)make_rel (value), NULL);
+ else if (g_type_is_a (target_type, G_TYPE_UINT))
+ gegl_node_set (iter[level], key,
+ (guint)make_rel (value), NULL);
else
gegl_node_set (iter[level], key, make_rel (
value), NULL);
@@ -460,10 +464,9 @@ gegl_create_chain_argv (char **ops,
if (g_type_is_a (target_type, G_TYPE_INT))
gegl_node_set (iter[level], key,
(int)g_strtod (value, NULL), NULL);
-
-
-
-
+ else if (g_type_is_a (target_type, G_TYPE_UINT))
+ gegl_node_set (iter[level], key,
+ (guint)g_strtod (value, NULL), NULL);
else
gegl_node_set (iter[level], key,
g_strtod (value, NULL), NULL);
@@ -895,6 +898,32 @@ gegl_serialize2 (GeglNode *start, GeglNode *end, const char *basepath,
printed = TRUE;
}
}
+ else if (property_type == G_TYPE_UINT)
+ {
+ guint defval = g_value_get_uint (default_value);
+ guint value;
+ gchar str[64];
+ gegl_node_get (iter, properties[i]->name, &value, NULL);
+
+ if (path)
+ {
+ g_string_append_printf (s2, " %s={ ", property_name);
+ if (rel_orig)
+ gegl_path_foreach (path, each_knot_rel, s2);
+ else
+ gegl_path_foreach (path, each_knot, s2);
+ g_string_append_printf (s2, " } ");
+ }
+ else if (value != defval || (!trim_defaults))
+ {
+ if (flags & GEGL_SERIALIZE_INDENT)
+ g_string_append_printf (s2, " ");
+ g_snprintf (str, sizeof (str), "%u", value);
+ g_string_append_printf (s2, " %s=%s%s", property_name,
+ str, rel_orig?"rel":"");
+ printed = TRUE;
+ }
+ }
else if (property_type == G_TYPE_BOOLEAN)
{
gboolean value;
diff --git a/gegl/gegl-xml.c b/gegl/gegl-xml.c
index e0eb05c..3f63874 100644
--- a/gegl/gegl-xml.c
+++ b/gegl/gegl-xml.c
@@ -157,6 +157,10 @@ set_clone_prop_as_well:
{
gegl_node_set (new, param_name, atoi (param_value), NULL);
}
+ else if (paramspec->value_type == G_TYPE_UINT)
+ {
+ gegl_node_set (new, param_name, (guint) strtoul (param_value, NULL, 10), NULL);
+ }
else if (paramspec->value_type == G_TYPE_FLOAT ||
paramspec->value_type == G_TYPE_DOUBLE)
{
@@ -855,6 +859,14 @@ serialize_properties (SerializeState *ss,
g_snprintf (str, sizeof (str), "%i", value);
xml_param (ss, indent + 2, properties[i]->name, str);
}
+ else if (properties[i]->value_type == G_TYPE_UINT)
+ {
+ guint value;
+ gchar str[64];
+ gegl_node_get (node, properties[i]->name, &value, NULL);
+ g_snprintf (str, sizeof (str), "%u", value);
+ xml_param (ss, indent + 2, properties[i]->name, str);
+ }
else if (properties[i]->value_type == G_TYPE_BOOLEAN)
{
gboolean value;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]