diff options
author | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2021-10-07 16:12:10 +0200 |
---|---|---|
committer | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2021-10-07 16:12:10 +0200 |
commit | 45ee5d246b838240fce51e3735188ea8f88acf27 (patch) | |
tree | d3b48fd7eb44ee6d59551e5312aae7f797bc2900 /preset_xml.c | |
parent | 314596035337348abbc934d96e4d83d4398f64f1 (diff) |
Import Upstream version 0.4.0
Diffstat (limited to 'preset_xml.c')
-rw-r--r-- | preset_xml.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/preset_xml.c b/preset_xml.c index a5bd749..991d8d5 100644 --- a/preset_xml.c +++ b/preset_xml.c @@ -30,6 +30,7 @@ extern XmlSettings xml_settings[]; extern guint n_xml_settings; extern EffectValues values_on_off; + /** * \param id modifier ID * \param position modifier position @@ -52,16 +53,18 @@ XmlSettings *get_xml_settings (guint id, guint position) } gchar * -map_xml_value(XmlSettings *xml, gint value) +map_xml_value (XmlSettings *xml, EffectValues *values, gint value) { - switch (xml->values->type) { + switch (values->type) { case VALUE_TYPE_LABEL: - if ((xml->values == &values_on_off) && (value > 1)) { - g_message("Skipping modifier->label %s\n", xml->label); + if ((values == &values_on_off) && (value > 1)) { + g_warning("Skipping modifier->label %s\n", xml->label); return NULL; } - if (value > xml->values->max || value < xml->values->min) { - g_message("%s value %d out of range %0.1f %0.1f", xml->label, value, xml->values->min, xml->values->max); + + if (value > values->max || value < values->min) { + g_warning("%s value %d out of range %0.1f %0.1f", + xml->label, value, xml->values->min, xml->values->max); } { XmlLabel *labels = xml->xml_labels; @@ -83,10 +86,9 @@ map_xml_value(XmlSettings *xml, gint value) return NULL; } - -gboolean value_is_extra (EffectValues *val, SettingParam *param) +gboolean value_is_extra (EffectValues *val, int value) { - if ((param->value < val->min) || (param->value > val->max)) { + if ((value < val->min) || (value > val->max)) { return TRUE; } return FALSE; @@ -111,7 +113,7 @@ write_preset_to_xml(Preset *preset, gchar *filename) return; } - /* + /* * Start the document with the xml default for the version, * encoding and the default for the standalone declaration. */ @@ -130,7 +132,7 @@ write_preset_to_xml(Preset *preset, gchar *filename) rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "SchemaVersion", BAD_CAST "1.2"); - + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xmlns", BAD_CAST "http://www.digitech.com/xml/preset"); @@ -142,9 +144,9 @@ write_preset_to_xml(Preset *preset, gchar *filename) while (iter_params) { XmlSettings *xml; SettingParam *param = (SettingParam *) iter_params->data; - + if (param->id == last_id && param->position == last_position) { - g_message("Skipping duplicate parameter id %d position %d", + g_warning("Skipping duplicate parameter id %d position %d", last_id, last_position); iter_params = iter_params->next; continue; @@ -177,7 +179,7 @@ write_preset_to_xml(Preset *preset, gchar *filename) BAD_CAST xml->label); values = xml->values; type = values->type; - while ((type & VALUE_TYPE_EXTRA) && value_is_extra(values, param)) { + while ((type & VALUE_TYPE_EXTRA) && value_is_extra(values, param->value)) { values = values->extra; type = values->type; } @@ -206,10 +208,11 @@ write_preset_to_xml(Preset *preset, gchar *filename) switch (type) { case VALUE_TYPE_LABEL: { - char *textp = map_xml_value(xml, param->value); + char *textp = map_xml_value(xml, values, param->value); if (!textp) { - g_message("Unable to map %s value %d for id %d position %d", - xml->label, param->value, param->id, param->position); + g_warning("Unable to map %s value %d for id %d position %d", + xml->label, param->value, param->id, + param->position); textp = ""; } rc = xmlTextWriterWriteElement(writer, BAD_CAST "Text", @@ -223,7 +226,7 @@ write_preset_to_xml(Preset *preset, gchar *filename) double value = (param->value + offset) * step; rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "Text", "%0.2f%s", value, suffix); - } else { + } else { gint value = (param->value + offset) * step; rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "Text", "%d%s", value, suffix); @@ -237,20 +240,16 @@ write_preset_to_xml(Preset *preset, gchar *filename) break; default: - g_message("Unhandled value type %d", type); + g_warning("Unhandled value type %d", type); break; } } - + rc = xmlTextWriterEndElement(writer); iter_params = iter_params->next; } - - /* Here we could close the elements ORDER and EXAMPLE using the - * function xmlTextWriterEndElement, but since we do not want to - * write any other elements, we simply call xmlTextWriterEndDocument, - * which will do all the work. */ + rc = xmlTextWriterEndDocument(writer); if (rc < 0) { printf("testXmlwriterFilename: Error at xmlTextWriterEndDocument\n"); |