summaryrefslogtreecommitdiff
path: root/gtk2_ardour/session_dialog.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-07-18 16:30:08 +0200
committerRobin Gareus <robin@gareus.org>2019-07-18 16:30:08 +0200
commit473fd45ca2886682ad28c389c16704dabe6fc3d1 (patch)
tree5e8bc24c18efb1654c8e0c677be645de44ad33da /gtk2_ardour/session_dialog.cc
parentaebdf5f00b22e4cecc384ebd1aff7617f6b7e703 (diff)
Allow to use session-init/setup scripts from the commandline
Diffstat (limited to 'gtk2_ardour/session_dialog.cc')
-rw-r--r--gtk2_ardour/session_dialog.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/gtk2_ardour/session_dialog.cc b/gtk2_ardour/session_dialog.cc
index 8dcb0b5a23..6cb7c59c5d 100644
--- a/gtk2_ardour/session_dialog.cc
+++ b/gtk2_ardour/session_dialog.cc
@@ -285,6 +285,35 @@ std::string
SessionDialog::session_template_name ()
{
if (!load_template_override.empty()) {
+ /* compare to SessionDialog::populate_session_templates */
+
+ /* compare by name (path may or may not be UTF-8) */
+ vector<TemplateInfo> templates;
+ find_session_templates (templates, false);
+ for (vector<TemplateInfo>::iterator x = templates.begin(); x != templates.end(); ++x) {
+ if ((*x).name == load_template_override) {
+ return (*x).path;
+ }
+ }
+
+ /* look up script by name */
+ LuaScriptList scripts (LuaScripting::instance ().scripts (LuaScriptInfo::SessionInit));
+ LuaScriptList& as (LuaScripting::instance ().scripts (LuaScriptInfo::EditorAction));
+ for (LuaScriptList::const_iterator s = as.begin(); s != as.end(); ++s) {
+ if ((*s)->subtype & LuaScriptInfo::SessionSetup) {
+ scripts.push_back (*s);
+ }
+ }
+ std::sort (scripts.begin(), scripts.end(), LuaScripting::Sorter());
+ for (LuaScriptList::const_iterator s = scripts.begin(); s != scripts.end(); ++s) {
+ if ((*s)->name == load_template_override) {
+ return "urn:ardour:" + (*s)->path;
+ }
+ }
+
+ /* this will produce a more or less meaninful error later:
+ * "ERROR: Could not open session template [abs-path to user-config dir]"
+ */
return Glib::build_filename (ARDOUR::user_template_directory (), load_template_override);
}