Optimize automation-event process splitting
[ardour.git] / libs / ardour / template_utils.cc
index d355231115f13beebceeb44292f8435018bda47f..4b8d5b2b7816b12f2e0f75ad11045ef1a9e3abc1 100644 (file)
@@ -33,6 +33,8 @@
 #include "ardour/search_paths.h"
 #include "ardour/io.h"
 
+#include "pbd/i18n.h"
+
 using namespace std;
 using namespace PBD;
 
@@ -99,16 +101,37 @@ find_session_templates (vector<TemplateInfo>& template_names, bool read_xml)
                rti.path = *i;
 
                if (read_xml) {
+
                        XMLTree tree;
                        if (!tree.read (file.c_str())) {
+                               cerr << "Failed to parse Route-template XML file: " << file;
                                continue;
                        }
-                       // TODO extract description,
-                       // compare to Session::get_info_from_path
+
+                       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);
        }
+       std::sort(template_names.begin(), template_names.end());
 }
 
 void
@@ -128,6 +151,7 @@ find_route_templates (vector<TemplateInfo>& template_names)
                XMLTree tree;
 
                if (!tree.read (fullpath.c_str())) {
+                       cerr << "Failed to parse Route-template XML file: " << fullpath;
                        continue;
                }
 
@@ -135,6 +159,24 @@ find_route_templates (vector<TemplateInfo>& 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;