aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e-util/e-xml-utils.c22
-rw-r--r--e-util/e-xml-utils.h5
2 files changed, 25 insertions, 2 deletions
diff --git a/e-util/e-xml-utils.c b/e-util/e-xml-utils.c
index 7802d5daf8..db6be09ebc 100644
--- a/e-util/e-xml-utils.c
+++ b/e-util/e-xml-utils.c
@@ -148,6 +148,26 @@ e_xml_get_double_prop_by_name(const xmlNode *parent, const xmlChar *prop_name)
return ret_val;
}
+double
+e_xml_get_double_prop_by_name_with_default(const xmlNode *parent, const xmlChar *prop_name,
+ gdouble def)
+{
+ xmlChar *prop;
+ double ret_val = 0;
+
+ g_return_val_if_fail (parent != NULL, 0);
+ g_return_val_if_fail (prop_name != NULL, 0);
+
+ prop = xmlGetProp ((xmlNode *)parent, prop_name);
+ if (prop) {
+ sscanf (prop, "%lf", &ret_val);
+ xmlFree (prop);
+ } else {
+ ret_val = def;
+ }
+ return ret_val;
+}
+
void
e_xml_set_double_prop_by_name(xmlNode *parent, const xmlChar *prop_name, double value)
{
@@ -182,7 +202,7 @@ e_xml_get_string_prop_by_name(const xmlNode *parent, const xmlChar *prop_name)
}
void
-e_xml_set_string_prop_by_name(xmlNode *parent, const xmlChar *prop_name, char *value)
+e_xml_set_string_prop_by_name(xmlNode *parent, const xmlChar *prop_name, const char *value)
{
g_return_if_fail (parent != NULL);
g_return_if_fail (prop_name != NULL);
diff --git a/e-util/e-xml-utils.h b/e-util/e-xml-utils.h
index 6d857e4e1d..0a722112f0 100644
--- a/e-util/e-xml-utils.h
+++ b/e-util/e-xml-utils.h
@@ -47,6 +47,9 @@ void e_xml_set_bool_prop_by_name (xmlNode *parent,
double e_xml_get_double_prop_by_name (const xmlNode *parent,
const xmlChar *prop_name);
+double e_xml_get_double_prop_by_name_with_default(const xmlNode *parent,
+ const xmlChar *prop_name,
+ gdouble def);
void e_xml_set_double_prop_by_name (xmlNode *parent,
const xmlChar *prop_name,
double value);
@@ -55,7 +58,7 @@ char *e_xml_get_string_prop_by_name (const xmlNode *parent,
const xmlChar *prop_name);
void e_xml_set_string_prop_by_name (xmlNode *parent,
const xmlChar *prop_name,
- char *value);
+ const char *value);
char *e_xml_get_translated_string_prop_by_name (const xmlNode *parent,
const xmlChar *prop_name);