/*
- Copyright (C) 2012 Paul Davis
+ Copyright (C) 2012 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <glibmm.h>
-#include "pbd/basename.h"
#include "pbd/file_utils.h"
#include "pbd/stl_delete.h"
#include "pbd/xml++.h"
#include "ardour/search_paths.h"
#include "ardour/io.h"
+#include "pbd/i18n.h"
+
using namespace std;
using namespace PBD;
if (!Glib::file_test (str, Glib::FILE_TEST_IS_DIR)) {
return false;
}
-
+
return true;
}
if (str.find (template_suffix) == str.length() - strlen (template_suffix)) {
return true;
}
-
+
return false;
}
void
-find_session_templates (vector<TemplateInfo>& template_names)
+find_session_templates (vector<TemplateInfo>& template_names, bool read_xml)
{
vector<string> templates;
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);
}
}
XMLTree tree;
if (!tree.read (fullpath.c_str())) {
+ cerr << "Failed to parse Route-template XML file: " << fullpath;
continue;
}
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;