X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Ftemplate_utils.cc;h=f6b6c59fbce1967c74046c0677082a8802e937ea;hb=11b02e90ac9b084cd25741b7a6bdc91c59749c16;hp=b2fa703060b7ca56e3473dd51184d14d6f023ab1;hpb=e1ca4b28873a195c802d7d02b5bf420d778e3f35;p=ardour.git diff --git a/libs/ardour/template_utils.cc b/libs/ardour/template_utils.cc index b2fa703060..f6b6c59fbc 100644 --- a/libs/ardour/template_utils.cc +++ b/libs/ardour/template_utils.cc @@ -22,7 +22,6 @@ #include -#include "pbd/basename.h" #include "pbd/file_utils.h" #include "pbd/stl_delete.h" #include "pbd/xml++.h" @@ -34,6 +33,8 @@ #include "ardour/search_paths.h" #include "ardour/io.h" +#include "pbd/i18n.h" + using namespace std; using namespace PBD; @@ -95,17 +96,38 @@ find_session_templates (vector& template_names, bool read_xml) for (vector::iterator i = templates.begin(); i != templates.end(); ++i) { string file = session_template_dir_to_file (*i); + TemplateInfo rti; + rti.name = Glib::path_get_basename (*i); + rti.path = *i; + if (read_xml) { + XMLTree tree; if (!tree.read (file.c_str())) { + cerr << "Failed to parse Route-template XML file: " << file; continue; } - } - TemplateInfo rti; - - rti.name = basename_nosuffix (*i); - rti.path = *i; + XMLNode* root = tree.root(); + + rti.modified_with = _("(unknown)"); + try { + XMLNode *pv = root->child("ProgramVersion"); + string modified_with; + if (pv != 0) { + pv->get_property (X_("modified-with"), modified_with); + } + rti.modified_with = modified_with; + } catch (XMLException &e) {} + + rti.description = _("No Description"); + try { + XMLNode *desc = root->child("description"); + if (desc != 0) { + rti.description = desc->attribute_value(); + } + } catch (XMLException &e) {} + } template_names.push_back (rti); } @@ -128,6 +150,7 @@ find_route_templates (vector& template_names) XMLTree tree; if (!tree.read (fullpath.c_str())) { + cerr << "Failed to parse Route-template XML file: " << fullpath; continue; } @@ -135,6 +158,24 @@ find_route_templates (vector& template_names) TemplateInfo rti; + rti.modified_with = _("(unknown)"); + try { + XMLNode *pv = root->child("ProgramVersion"); + string modified_with; + if (pv != 0) { + pv->get_property (X_("modified-with"), modified_with); + } + rti.modified_with = modified_with; + } catch (XMLException &e) {} + + rti.description = _("No Description"); + try { + XMLNode *desc = root->child("description"); + if (desc != 0) { + rti.description = desc->attribute_value(); + } + } catch (XMLException &e) {} + rti.name = IO::name_from_state (*root->children().front()); rti.path = fullpath;