X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Ftemplate_utils.cc;h=f6b6c59fbce1967c74046c0677082a8802e937ea;hb=fb01698450e5cb88c7e58fb3a5ebe6294731fdfe;hp=7797440f0e0a1720e52108e221196ccbcf313422;hpb=22b07e0233a29d9633ffa825a79503befaf2e16e;p=ardour.git diff --git a/libs/ardour/template_utils.cc b/libs/ardour/template_utils.cc index 7797440f0e..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; @@ -79,7 +80,7 @@ session_template_dir_to_file (string const & dir) void -find_session_templates (vector& template_names) +find_session_templates (vector& template_names, bool read_xml) { vector templates; @@ -95,17 +96,39 @@ find_session_templates (vector& template_names) for (vector::iterator i = templates.begin(); i != templates.end(); ++i) { string file = session_template_dir_to_file (*i); - XMLTree tree; - - if (!tree.read (file.c_str())) { - continue; - } - TemplateInfo rti; - - rti.name = basename_nosuffix (*i); + 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; + } + + 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); } } @@ -127,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; } @@ -134,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;