#include "audio_region_view.h"
#include "big_clock_window.h"
#include "bundle_manager.h"
+#include "duplicate_routes_dialog.h"
#include "engine_dialog.h"
#include "export_video_dialog.h"
#include "export_video_infobox.h"
ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
- : Gtkmm2ext::UI (PROGRAM_NAME, argcp, argvp)
+ : Gtkmm2ext::UI (X_("gui"), argcp, argvp)
, session_loaded (false)
, gui_object_state (new GUIObjectState)
, primary_clock (new MainClock (X_("primary"), X_("transport"), true ))
, _status_bar_visibility (X_("status-bar"))
, _feedback_exists (false)
, _log_not_acknowledged (LogLevelNone)
+ , duplicate_routes_dialog (0)
{
Gtkmm2ext::init (localedir);
void
ARDOUR_UI::engine_running ()
{
+ ENSURE_GUI_THREAD (*this, &ARDOUR_UI::engine_running)
if (first_time_engine_run) {
post_engine();
first_time_engine_run = false;
update_sample_rate (AudioEngine::instance()->sample_rate());
update_timecode_format ();
update_peak_thread_work ();
+ ActionManager::set_sensitive (ActionManager::engine_sensitive_actions, true);
+ ActionManager::set_sensitive (ActionManager::engine_opposite_sensitive_actions, false);
}
void
open_session_selector.set_current_folder(Config->get_default_session_parent_dir());
}
+ Gtkmm2ext::add_volume_shortcuts (open_session_selector);
try {
/* add_shortcut_folder throws an exception if the folder being added already has a shortcut */
-#ifdef GTKOSX
- open_session_selector.add_shortcut_folder_uri("file:///Volumes");
-#endif
string default_session_folder = Config->get_default_session_parent_dir();
open_session_selector.add_shortcut_folder (default_session_folder);
}
if (affect_transport) {
if (rolling) {
_session->request_stop (with_abort, true);
- } else {
+ } else if (!_session->config.get_external_sync()) {
if (UIConfiguration::instance().get_follow_edits() && ( editor->get_selection().time.front().start == _session->transport_frame() ) ) { //if playhead is exactly at the start of a range, we can assume it was placed there by follow_edits
_session->request_play_range (&editor->get_selection().time, true);
_session->set_requested_return_frame( editor->get_selection().time.front().start ); //force an auto-return here
void
ARDOUR_UI::toggle_session_auto_loop ()
{
+ if (!_session) {
+ return;
+ }
+
Location * looploc = _session->locations()->auto_loop_location();
- if (!_session || !looploc) {
+ if (!looploc) {
return;
}
{
float current_transport_speed;
- if (_session) {
+ if (_session) {
current_transport_speed = _session->transport_speed();
if (current_transport_speed >= 0.0f) {
auto_loop_button.set_active (false);
}
- if (UIConfiguration::instance().get_follow_edits()) {
+ if (UIConfiguration::instance().get_follow_edits() && !_session->config.get_external_sync()) {
/* light up both roll and play-selection if they are joined */
roll_button.set_active (true);
play_selection_button.set_active (true);
}
- Session::SaveAs sa;
+ Session::SaveAs sa;
sa.new_parent_folder = save_as_dialog->new_parent_folder ();
sa.new_name = save_as_dialog->new_name ();
}
}
+bool
+ARDOUR_UI::process_snapshot_session_prompter (ArdourPrompter& prompter, bool switch_to_it)
+{
+ string snapname;
+
+ prompter.get_result (snapname);
+
+ bool do_save = (snapname.length() != 0);
+
+ if (do_save) {
+ char illegal = Session::session_name_is_legal(snapname);
+ if (illegal) {
+ MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
+ "snapshot names may not contain a '%1' character"), illegal));
+ msg.run ();
+ return false;
+ }
+ }
+
+ vector<std::string> p;
+ get_state_files_in_directory (_session->session_directory().root_path(), p);
+ vector<string> n = get_file_names_no_extension (p);
+
+ if (find (n.begin(), n.end(), snapname) != n.end()) {
+
+ do_save = overwrite_file_dialog (prompter,
+ _("Confirm Snapshot Overwrite"),
+ _("A snapshot already exists with that name. Do you want to overwrite it?"));
+ }
+
+ if (do_save) {
+ save_state (snapname, switch_to_it);
+ }
+ else {
+ return false;
+ }
+
+ return true;
+}
+
+
/** Ask the user for the name of a new snapshot and then take it.
*/
ARDOUR_UI::snapshot_session (bool switch_to_it)
{
ArdourPrompter prompter (true);
- string snapname;
prompter.set_name ("Prompter");
prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
prompter.set_initial_text (timebuf);
}
- again:
- switch (prompter.run()) {
- case RESPONSE_ACCEPT:
- {
- prompter.get_result (snapname);
-
- bool do_save = (snapname.length() != 0);
-
- if (do_save) {
- char illegal = Session::session_name_is_legal(snapname);
- if (illegal) {
- MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
- "snapshot names may not contain a '%1' character"), illegal));
- msg.run ();
- goto again;
- }
- }
-
- vector<std::string> p;
- get_state_files_in_directory (_session->session_directory().root_path(), p);
- vector<string> n = get_file_names_no_extension (p);
- if (find (n.begin(), n.end(), snapname) != n.end()) {
-
- ArdourDialog confirm (_("Confirm Snapshot Overwrite"), true);
- Label m (_("A snapshot already exists with that name. Do you want to overwrite it?"));
- confirm.get_vbox()->pack_start (m, true, true);
- confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- confirm.add_button (_("Overwrite"), Gtk::RESPONSE_ACCEPT);
- confirm.show_all ();
- switch (confirm.run()) {
- case RESPONSE_CANCEL:
- do_save = false;
- }
+ bool finished = false;
+ while (!finished) {
+ switch (prompter.run()) {
+ case RESPONSE_ACCEPT:
+ {
+ finished = process_snapshot_session_prompter (prompter, switch_to_it);
+ break;
}
- if (do_save) {
- save_state (snapname, switch_to_it);
+ default:
+ finished = true;
+ break;
}
- break;
- }
-
- default:
- break;
}
}
if (_session) {
int ret;
- if (name.length() == 0) {
- name = _session->snap_name();
- }
-
if ((ret = _session->save_state (name, false, switch_to_it)) != 0) {
return ret;
}
}
}
+bool
+ARDOUR_UI::process_save_template_prompter (ArdourPrompter& prompter)
+{
+ string name;
+
+ prompter.get_result (name);
+
+ if (name.length()) {
+ int failed = _session->save_template (name);
+
+ if (failed == -2) { /* file already exists. */
+ bool overwrite = overwrite_file_dialog (prompter,
+ _("Confirm Template Overwrite"),
+ _("A template already exists with that name. Do you want to overwrite it?"));
+
+ if (overwrite) {
+ _session->save_template (name, true);
+ }
+ else {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
void
ARDOUR_UI::save_template ()
{
ArdourPrompter prompter (true);
- string name;
if (!check_audioengine(*editor)) {
return;
prompter.set_initial_text(_session->name() + _("-template"));
prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
- switch (prompter.run()) {
- case RESPONSE_ACCEPT:
- prompter.get_result (name);
+ bool finished = false;
+ while (!finished) {
+ switch (prompter.run()) {
+ case RESPONSE_ACCEPT:
+ finished = process_save_template_prompter (prompter);
+ break;
- if (name.length()) {
- _session->save_template (name);
+ default:
+ finished = true;
+ break;
}
- break;
-
- default:
- break;
}
}
void
ARDOUR_UI::load_from_application_api (const std::string& path)
{
+ printf("ARDOUR_UI::load_from_application_api\n");
ARDOUR_COMMAND_LINE::session_name = path;
+ /* Cancel SessionDialog if it's visible to make OSX delegates work.
+ *
+ * ARDOUR_UI::starting connects app->ShouldLoad signal and then shows a SessionDialog
+ * race-condition:
+ * - ShouldLoad does not arrive in time, ARDOUR_COMMAND_LINE::session_name is empty:
+ * -> ARDOUR_UI::get_session_parameters starts a SessionDialog.
+ * - ShouldLoad signal arrives, this function is called and sets ARDOUR_COMMAND_LINE::session_name
+ * -> SessionDialog is not displayed
+ */
+
+ if (_session_dialog) {
+ std::string session_name = basename_nosuffix (ARDOUR_COMMAND_LINE::session_name);
+ std::string session_path = path;
+ if (Glib::file_test (session_path, Glib::FILE_TEST_IS_REGULAR)) {
+ session_path = Glib::path_get_dirname (session_path);
+ }
+ // signal the existing dialog in ARDOUR_UI::get_session_parameters()
+ _session_dialog->set_provided_session (session_name, session_path);
+ _session_dialog->response (RESPONSE_NONE);
+ _session_dialog->hide();
+ return;
+ }
+ int rv;
if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
/* /path/to/foo => /path/to/foo, foo */
- load_session (path, basename_nosuffix (path));
+ rv = load_session (path, basename_nosuffix (path));
} else {
/* /path/to/foo/foo.ardour => /path/to/foo, foo */
- load_session (Glib::path_get_dirname (path), basename_nosuffix (path));
+ rv =load_session (Glib::path_get_dirname (path), basename_nosuffix (path));
+ }
+
+ // if load_session fails -> pop up SessionDialog.
+ if (rv) {
+ ARDOUR_COMMAND_LINE::session_name = "";
+
+ if (get_session_parameters (true, false)) {
+ exit (1);
+ }
+
+ goto_editor_window ();
}
}
SessionDialog session_dialog (should_be_new, session_name, session_path, load_template, cancel_not_quit);
+ _session_dialog = &session_dialog;
while (ret != 0) {
if (!ARDOUR_COMMAND_LINE::session_name.empty()) {
switch (session_dialog.run()) {
case RESPONSE_ACCEPT:
break;
+ case RESPONSE_NONE:
+ /* this is used for async * app->ShouldLoad(). */
+ continue; // while loop
+ break;
default:
if (quit_on_cancel) {
// JE - Currently (July 2014) this section can only get reached if the
}
}
+ _session_dialog = NULL;
+
return ret;
}
fst_stop_threading();
#endif
- flush_pending ();
+ {
+ Timers::TimerSuspender t;
+ flush_pending ();
+ }
#ifdef WINDOWS_VST_SUPPORT
fst_start_threading();
void
ARDOUR_UI::launch_chat ()
{
+ MessageDialog dialog(_("<b>Just ask and wait for an answer.\nIt may take from minutes to hours.</b>"), true);
+
+ dialog.set_title (_("About the Chat"));
+ dialog.set_secondary_text (_("When you're inside the chat just ask your question and wait for an answer. The chat is occupied by real people with real lives so many of them are passively online and might not read your question before minutes or hours later.\nSo please be patient and wait for an answer.\n\nYou should just leave the chat window open and check back regularly until someone has answered your question."));
+
+ switch (dialog.run()) {
+ case RESPONSE_OK:
#ifdef __APPLE__
- open_uri("http://webchat.freenode.net/?channels=ardour-osx");
+ open_uri("http://webchat.freenode.net/?channels=ardour-osx");
#elif defined PLATFORM_WINDOWS
- open_uri("http://webchat.freenode.net/?channels=ardour-windows");
+ open_uri("http://webchat.freenode.net/?channels=ardour-windows");
#else
- open_uri("http://webchat.freenode.net/?channels=ardour");
+ open_uri("http://webchat.freenode.net/?channels=ardour");
#endif
+ break;
+ default:
+ break;
+ }
}
void
void
ARDOUR_UI::launch_tracker ()
{
- PBD::open_uri ("http://tracker.ardour.org/bug_report_page.php");
+ PBD::open_uri ("http://tracker.ardour.org");
}
void
}
}
+void
+ARDOUR_UI::start_duplicate_routes ()
+{
+ if (!duplicate_routes_dialog) {
+ duplicate_routes_dialog = new DuplicateRouteDialog;
+ }
+
+ if (duplicate_routes_dialog->restart (_session)) {
+ return;
+ }
+
+ duplicate_routes_dialog->present ();
+}
+
void
ARDOUR_UI::add_route (Gtk::Window* /* ignored */)
{
int
ARDOUR_UI::sr_mismatch_dialog (framecnt_t desired, framecnt_t actual)
{
- HBox* hbox = new HBox();
+ HBox* hbox = new HBox();
Image* image = new Image (Stock::DIALOG_WARNING, ICON_SIZE_DIALOG);
ArdourDialog dialog (_("Sample Rate Mismatch"), true);
Label message (string_compose (_("\
dialog.present ();
dialog.run ();
+
return dialog.get_which ();
}
_pending_locate_num = _pending_locate_num*10 + num;
} else {
switch (num) {
- case 0: toggle_roll(false, false); break;
- case 1: transport_rewind(1); break;
- case 2: transport_forward(1); break;
- case 3: transport_record(true); break;
+ case 0: toggle_roll(false, false); break;
+ case 1: transport_rewind(1); break;
+ case 2: transport_forward(1); break;
+ case 3: transport_record(true); break;
case 4: toggle_session_auto_loop(); break;
- case 5: transport_record(false); toggle_session_auto_loop(); break;
- case 6: toggle_punch(); break;
- case 7: toggle_click(); break;
+ case 5: transport_record(false); toggle_session_auto_loop(); break;
+ case 6: toggle_punch(); break;
+ case 7: toggle_click(); break;
case 8: toggle_auto_return(); break;
case 9: toggle_follow_edits(); break;
}