#include "ardour/audioengine.h"
#include "ardour/audiofilesource.h"
#include "ardour/automation_watch.h"
-#include "ardour/diskstream.h"
+#include "ardour/disk_reader.h"
+#include "ardour/disk_writer.h"
#include "ardour/filename_extensions.h"
#include "ardour/filesystem_paths.h"
#include "ardour/ltc_file_reader.h"
#include "route_time_axis.h"
#include "route_params_ui.h"
#include "save_as_dialog.h"
+#include "save_template_dialog.h"
#include "script_selector.h"
#include "session_archive_dialog.h"
#include "session_dialog.h"
rec_button.set_name ("transport recenable button");
midi_panic_button.set_name ("transport button");
- ARDOUR::Diskstream::DiskOverrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_overrun_handler, this), gui_context());
- ARDOUR::Diskstream::DiskUnderrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_underrun_handler, this), gui_context());
+ ARDOUR::DiskWriter::Overrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_overrun_handler, this), gui_context());
+ ARDOUR::DiskReader::Underrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_underrun_handler, this), gui_context());
ARDOUR::Session::VersionMismatch.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_format_mismatch, this, _1, _2), gui_context());
}
}
-bool
-ARDOUR_UI::process_save_template_prompter (Prompter& prompter)
+void
+ARDOUR_UI::save_template_dialog_response (int response, SaveTemplateDialog* d)
{
- string name;
+ if (response == RESPONSE_ACCEPT) {
+ const string name = d->get_template_name ();
+ const string desc = d->get_description ();
- prompter.get_result (name);
-
- if (name.length()) {
- int failed = _session->save_template (name);
+ int failed = _session->save_template (name, desc);
if (failed == -2) { /* file already exists. */
- bool overwrite = overwrite_file_dialog (prompter,
+ bool overwrite = overwrite_file_dialog (*d,
_("Confirm Template Overwrite"),
_("A template already exists with that name. Do you want to overwrite it?"));
if (overwrite) {
- _session->save_template (name, true);
+ _session->save_template (name, desc, true);
}
else {
- return false;
+ d->show ();
+ return;
}
}
}
-
- return true;
+ delete d;
}
void
ARDOUR_UI::save_template ()
{
- Prompter prompter (true);
-
if (!check_audioengine (_main_window)) {
return;
}
- prompter.set_name (X_("Prompter"));
- prompter.set_title (_("Save Template"));
- prompter.set_prompt (_("Name for template:"));
- prompter.set_initial_text(_session->name() + _("-template"));
- prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
-
- bool finished = false;
- while (!finished) {
- switch (prompter.run()) {
- case RESPONSE_ACCEPT:
- finished = process_save_template_prompter (prompter);
- break;
-
- default:
- finished = true;
- break;
- }
- }
+ const std::string desc = SessionMetadata::Metadata()->description ();
+ SaveTemplateDialog* d = new SaveTemplateDialog (_session->name (), desc);
+ d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::save_template_dialog_response), d));
+ d->show ();
}
void ARDOUR_UI::manage_templates ()
PBD::info << "LuaInstance: " << s << endmsg;
}
+std::map<std::string, std::string>
+ARDOUR_UI::route_setup_info (const std::string& script_path)
+{
+ std::map<std::string, std::string> rv;
+
+ if (!Glib::file_test (script_path, Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR)) {
+ return rv;
+ }
+
+ LuaState lua;
+ lua.Print.connect (&_lua_print);
+ lua.sandbox (true);
+
+ lua_State* L = lua.getState();
+ LuaInstance::register_classes (L);
+ LuaBindings::set_session (L, _session);
+ luabridge::push <PublicEditor *> (L, &PublicEditor::instance());
+ lua_setglobal (L, "Editor");
+
+ lua.do_command ("function ardour () end");
+ lua.do_file (script_path);
+
+ try {
+ luabridge::LuaRef fn = luabridge::getGlobal (L, "route_setup");
+ if (!fn.isFunction ()) {
+ return rv;
+ }
+ luabridge::LuaRef rs = fn ();
+ if (!rs.isTable ()) {
+ return rv;
+ }
+ for (luabridge::Iterator i(rs); !i.isNil (); ++i) {
+ if (!i.key().isString()) {
+ continue;
+ }
+ std::string key = i.key().tostring();
+ if (i.value().isString() || i.value().isNumber() || i.value().isBoolean()) {
+ rv[key] = i.value().tostring();
+ }
+ }
+ } catch (luabridge::LuaException const& e) {
+ cerr << "LuaException:" << e.what () << endl;
+ } catch (...) { }
+ return rv;
+}
+
+void
+ARDOUR_UI::meta_route_setup (const std::string& script_path)
+{
+ if (!Glib::file_test (script_path, Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR)) {
+ return;
+ }
+ assert (add_route_dialog);
+
+ int count;
+ if ((count = add_route_dialog->count()) <= 0) {
+ return;
+ }
+
+ LuaState lua;
+ lua.Print.connect (&_lua_print);
+ lua.sandbox (true);
+
+ lua_State* L = lua.getState();
+ LuaInstance::register_classes (L);
+ LuaBindings::set_session (L, _session);
+ luabridge::push <PublicEditor *> (L, &PublicEditor::instance());
+ lua_setglobal (L, "Editor");
+
+ lua.do_command ("function ardour () end");
+ lua.do_file (script_path);
+
+ luabridge::LuaRef args (luabridge::newTable (L));
+
+ args["name"] = add_route_dialog->name_template ();
+ args["insert_at"] = translate_order (add_route_dialog->insert_at());
+ args["group"] = add_route_dialog->route_group ();
+ args["strict_io"] = add_route_dialog->use_strict_io ();
+ args["instrument"] = add_route_dialog->requested_instrument ();
+ args["track_mode"] = add_route_dialog->mode ();
+ args["channels"] = add_route_dialog->channel_count ();
+ args["how_many"] = count;
+
+ try {
+ luabridge::LuaRef fn = luabridge::getGlobal (L, "factory");
+ if (fn.isFunction()) {
+ fn (args)();
+ }
+ } catch (luabridge::LuaException const& e) {
+ cerr << "LuaException:" << e.what () << endl;
+ } catch (...) {
+ display_insufficient_ports_message ();
+ }
+}
+
void
ARDOUR_UI::meta_session_setup (const std::string& script_path)
{
lua.do_file (script_path);
try {
- luabridge::LuaRef fn = luabridge::getGlobal (L, "session_setup");
+ luabridge::LuaRef fn = luabridge::getGlobal (L, "factory");
if (fn.isFunction()) {
- fn ();
+ fn ()();
}
} catch (luabridge::LuaException const& e) {
cerr << "LuaException:" << e.what () << endl;
+ } catch (...) {
+ display_insufficient_ports_message ();
}
}
switch (r) {
case AddRouteDialog::Add:
+ add_route_dialog->reset_name_edited ();
break;
case AddRouteDialog::AddAndClose:
add_route_dialog->ArdourDialog::on_response (r);
return;
}
- std::string template_name = add_route_dialog->get_template_path();
- if (!template_name.empty() && template_name.substr (0, 11) == "urn:ardour:") {
- meta_session_setup (template_name.substr (11));
+ std::string template_path = add_route_dialog->get_template_path();
+ if (!template_path.empty() && template_path.substr (0, 11) == "urn:ardour:") {
+ meta_route_setup (template_path.substr (11));
return;
}
}
PresentationInfo::order_t order = translate_order (add_route_dialog->insert_at());
- string template_path = add_route_dialog->track_template();
+ const string name_template = add_route_dialog->name_template ();
DisplaySuspender ds;
- if (!template_path.empty()) {
- if (add_route_dialog->name_template_is_default()) {
- _session->new_route_from_template (count, order, template_path, string());
+ if (!template_path.empty ()) {
+ if (add_route_dialog->name_template_is_default ()) {
+ _session->new_route_from_template (count, order, template_path, string ());
} else {
- _session->new_route_from_template (count, order, template_path, add_route_dialog->name_template());
+ _session->new_route_from_template (count, order, template_path, name_template);
}
return;
}
ChanCount input_chan= add_route_dialog->channels ();
ChanCount output_chan;
- string name_template = add_route_dialog->name_template ();
PluginInfoPtr instrument = add_route_dialog->requested_instrument ();
RouteGroup* route_group = add_route_dialog->route_group ();
AutoConnectOption oac = Config->get_output_auto_connect();