Remove ambiguity of Gtk and Windows API
[ardour.git] / libs / ardour / template_utils.cc
index 7797440f0e0a1720e52108e221196ccbcf313422..f6b6c59fbce1967c74046c0677082a8802e937ea 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <glibmm.h>
 
-#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<TemplateInfo>& template_names)
+find_session_templates (vector<TemplateInfo>& template_names, bool read_xml)
 {
        vector<string> templates;
 
@@ -95,17 +96,39 @@ find_session_templates (vector<TemplateInfo>& template_names)
        for (vector<string>::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<TemplateInfo>& 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<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;