Commit e527b48c authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

Use new utility function to parse boolean values.

Fixes bug 790452 "Glade saves invalid GtkBuilder XML"
parent 7f9cfb30
......@@ -867,10 +867,12 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class
g_value_set_uint (value, g_utf8_get_char (string));
else if (G_IS_PARAM_SPEC_BOOLEAN (property_class->pspec))
{
if (strcmp (string, GLADE_TAG_TRUE) == 0)
g_value_set_boolean (value, TRUE);
else
gboolean val;
if (glade_utils_boolean_from_string (string, &val))
g_value_set_boolean (value, FALSE);
else
g_value_set_boolean (value, val);
}
else if (G_IS_PARAM_SPEC_OBJECT (property_class->pspec))
{
......
......@@ -41,6 +41,7 @@
#include "glade-xml-utils.h"
#include "glade-catalog.h"
#include "glade-utils.h"
#include <libxml/tree.h>
#include <libxml/parser.h>
......@@ -307,12 +308,6 @@ glade_xml_set_property (xmlNodePtr node,
xmlSetProp (node, BAD_CAST (name), BAD_CAST (value));
}
#define GLADE_TAG_TRUE "True"
#define GLADE_TAG_FALSE "False"
#define GLADE_TAG_TRUE2 "TRUE"
#define GLADE_TAG_FALSE2 "FALSE"
#define GLADE_TAG_TRUE3 "yes"
#define GLADE_TAG_FALSE3 "no"
/*
* Get a String value for a node either carried as an attibute or as
* the content of a child.
......@@ -330,21 +325,8 @@ glade_xml_get_boolean (GladeXmlNode *node_in,
if (value == NULL)
return _default;
if (strcmp (value, GLADE_TAG_FALSE) == 0)
ret = FALSE;
else if (strcmp (value, GLADE_TAG_FALSE2) == 0)
ret = FALSE;
else if (strcmp (value, GLADE_TAG_FALSE3) == 0)
ret = FALSE;
else if (strcmp (value, GLADE_TAG_TRUE) == 0)
ret = TRUE;
else if (strcmp (value, GLADE_TAG_TRUE2) == 0)
ret = TRUE;
else if (strcmp (value, GLADE_TAG_TRUE3) == 0)
ret = TRUE;
else
if (glade_utils_boolean_from_string (value, &ret))
g_warning ("Boolean tag unrecognized *%s*\n", value);
g_free (value);
return ret;
......@@ -367,21 +349,8 @@ glade_xml_get_property_boolean (GladeXmlNode *node_in,
if (value == NULL)
return _default;
if (strcmp (value, GLADE_TAG_FALSE) == 0)
ret = FALSE;
else if (strcmp (value, GLADE_TAG_FALSE2) == 0)
ret = FALSE;
else if (strcmp (value, GLADE_TAG_FALSE3) == 0)
ret = FALSE;
else if (strcmp (value, GLADE_TAG_TRUE) == 0)
ret = TRUE;
else if (strcmp (value, GLADE_TAG_TRUE2) == 0)
ret = TRUE;
else if (strcmp (value, GLADE_TAG_TRUE3) == 0)
ret = TRUE;
else
if (glade_utils_boolean_from_string (value, &ret))
g_warning ("Boolean tag unrecognized *%s*\n", value);
g_free (value);
return ret;
......@@ -442,18 +411,11 @@ glade_xml_node_set_property_boolean (GladeXmlNode *node_in,
xmlNodePtr node = (xmlNodePtr) node_in;
if (value)
glade_xml_set_property (node, name, GLADE_TAG_TRUE);
glade_xml_set_property (node, name, "True");
else
glade_xml_set_property (node, name, GLADE_TAG_FALSE);
glade_xml_set_property (node, name, "False");
}
#undef GLADE_TAG_TRUE
#undef GLADE_TAG_FALSE
#undef GLADE_TAG_TRUE2
#undef GLADE_TAG_FALSE2
#undef GLADE_TAG_TRUE3
#undef GLADE_TAG_FALSE3
gchar *
glade_xml_get_value_string_required (GladeXmlNode *node_in,
const gchar *name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment