[gegl] gegl: try to make a proper enum nick out of an old value found in XML



commit be92654bd15930181538723d53d68d79bf7c7a86
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 24 18:42:01 2014 +0200

    gegl: try to make a proper enum nick out of an old value found in XML
    
    This is merely doing tolower() and s/ /-/, but covers quite some
    of the now broken strings.

 gegl/gegl-xml.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/gegl/gegl-xml.c b/gegl/gegl-xml.c
index 85a4b43..19e91cf 100644
--- a/gegl/gegl-xml.c
+++ b/gegl/gegl-xml.c
@@ -187,10 +187,26 @@ set_clone_prop_as_well:
             }
           else
             {
+              /* warn, but try to get a valid nick out of the old-style
+               * value name
+               */
+              gchar *nick;
+              gchar *c;
               g_printerr ("gegl-xml (param_set %s): enum %s has no value '%s'\n",
                           paramspec->name,
                           g_type_name (paramspec->value_type),
                           param_value);
+              nick = g_strdup (param_value);
+              for (c = nick; *c; c++)
+                {
+                  *c = g_ascii_tolower (*c);
+                  if (*c == ' ')
+                    *c = '-';
+                }
+              evalue = g_enum_get_value_by_nick (eclass, nick);
+              if (evalue)
+                gegl_node_set (new, param_name, evalue->value, NULL);
+              g_free (nick);
             }
         }
       else if (paramspec->value_type == GEGL_TYPE_COLOR)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]