#include "ardour/session_state_utils.h"
#include "ardour/session_directory.h"
+#include "ardour_message.h"
#include "ardour_ui.h"
#include "engine_dialog.h"
#include "missing_plugin_dialog.h"
{
std::string str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
- MessageDialog msg (str,
- false,
- Gtk::MESSAGE_WARNING,
- Gtk::BUTTONS_YES_NO,
- true);
-
+ ArdourMessageDialog msg (str,
+ false,
+ Gtk::MESSAGE_WARNING,
+ Gtk::BUTTONS_YES_NO,
+ true);
msg.set_name (X_("OpenExistingDialog"));
msg.set_title (_("Open Existing Session"));
msg.set_wmclass (X_("existing_session"), PROGRAM_NAME);
msg.set_position (Gtk::WIN_POS_CENTER);
- pop_back_splash (msg);
switch (msg.run()) {
case RESPONSE_YES:
* loaded. The startup case is handled by StartupFSM
*/
void
-ARDOUR_UI::start_session_load ()
+ARDOUR_UI::start_session_load (bool create_new)
{
/* deal with any existing DIRTY session now, rather than later. don't
* treat a non-dirty session this way, so that it stays visible
}
}
- SessionDialog* session_dialog = new SessionDialog (false, string(), Config->get_default_session_parent_dir(), string(), true);
+ SessionDialog* session_dialog = new SessionDialog (create_new, string(), Config->get_default_session_parent_dir(), string(), true);
session_dialog->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::session_dialog_response_handler), session_dialog));
session_dialog->present ();
}
int rv = ARDOUR::inflate_session (session_name, Config->get_default_session_parent_dir(), session_path, session_name);
if (rv < 0) {
- MessageDialog msg (*session_dialog, string_compose (_("Extracting session-archive failed: %1"), inflate_error (rv)));
+ ArdourMessageDialog msg (*session_dialog, string_compose (_("Extracting session-archive failed: %1"), inflate_error (rv)));
msg.run ();
return; /* back to main event loop */
} else if (rv == 0) {
char illegal = Session::session_name_is_legal (session_name);
if (illegal) {
- MessageDialog msg (*session_dialog,
- string_compose (_("To ensure compatibility with various systems\n"
- "session names may not contain a '%1' character"),
- illegal));
+ ArdourMessageDialog msg (*session_dialog,
+ string_compose (_("To ensure compatibility with various systems\n"
+ "session names may not contain a '%1' character"),
+ illegal));
msg.run ();
return; /* back to main event loop */
}
} else {
if (!likely_new) {
- pop_back_splash (*session_dialog);
- MessageDialog msg (string_compose (_("There is no existing session at \"%1\""), session_path));
+ ArdourMessageDialog msg (string_compose (_("There is no existing session at \"%1\""), session_path));
msg.run ();
return; /* back to main event loop */
}
char illegal = Session::session_name_is_legal(session_name);
if (illegal) {
- pop_back_splash (*session_dialog);
- MessageDialog msg (*session_dialog, string_compose(_("To ensure compatibility with various systems\n"
- "session names may not contain a '%1' character"), illegal));
+ ArdourMessageDialog msg (*session_dialog, string_compose(_("To ensure compatibility with various systems\n"
+ "session names may not contain a '%1' character"), illegal));
msg.run ();
return; /* back to main event loop */
return;
}
- start_session_load ();
+ start_session_load (false);
}
}
PBD::Unwinder<bool> lsu (session_load_in_progress, true);
- Session *new_session;
int unload_status;
- int retval = -1;
+ bool had_session = false;
if (_session) {
+ had_session = true;
+
unload_status = unload_session ();
- if (unload_status < 0) {
- goto out;
- } else if (unload_status > 0) {
- retval = 0;
- goto out;
+ if (unload_status != 0) {
+ hide_splash ();
+ return -1;
+ }
+ }
+
+ if (had_session) {
+ float sr;
+ SampleFormat sf;
+ string pv;
+
+ Session::get_info_from_path (Glib::build_filename (path, snap_name + statefile_suffix), sr, sf, pv);
+
+ /* this will stop the engine if the SR is different */
+
+ audio_midi_setup->set_desired_sample_rate (sr);
+
+ if (!AudioEngine::instance()->running()) {
+ audio_midi_setup->set_position (WIN_POS_CENTER);
+ audio_midi_setup->present ();
+ audio_midi_setup->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::audio_midi_setup_reconfigure_done), path, snap_name, mix_template));
+ /* not done yet, but we're avoiding modal dialogs */
+ return 0;
+ }
+ }
+
+ return load_session_stage_two (path, snap_name, mix_template);
+}
+
+void
+ARDOUR_UI::audio_midi_setup_reconfigure_done (int response, std::string path, std::string snap_name, std::string mix_template)
+{
+ switch (response) {
+ case Gtk::RESPONSE_DELETE_EVENT:
+ break;
+ default:
+ if (!AudioEngine::instance()->running()) {
+ return; // keep dialog visible, maybe try again
}
}
+ audio_midi_setup->hide();
+
+ (void) load_session_stage_two (path, snap_name, mix_template);
+}
+
+int
+ARDOUR_UI::load_session_stage_two (const std::string& path, const std::string& snap_name, std::string mix_template)
+{
+ Session *new_session;
+ int retval = -1;
+
BootMessage (string_compose (_("Please wait while %1 loads your session"), PROGRAM_NAME));
try {
catch (AudioEngine::PortRegistrationFailure const& err) {
- MessageDialog msg (err.what(),
- true,
- Gtk::MESSAGE_INFO,
- Gtk::BUTTONS_CLOSE);
+ ArdourMessageDialog msg (err.what(),
+ true,
+ Gtk::MESSAGE_INFO,
+ Gtk::BUTTONS_CLOSE);
msg.set_title (_("Port Registration Error"));
msg.set_secondary_text (_("Click the Close button to try again."));
msg.set_position (Gtk::WIN_POS_CENTER);
- pop_back_splash (msg);
- msg.present ();
int response = msg.run ();
-
msg.hide ();
switch (response) {
goto out;
}
catch (SessionException const& e) {
- MessageDialog msg (string_compose(
- _("Session \"%1 (snapshot %2)\" did not load successfully:\n%3"),
- path, snap_name, e.what()),
- true,
- Gtk::MESSAGE_INFO,
- BUTTONS_OK);
+ ArdourMessageDialog msg (string_compose(
+ _("Session \"%1 (snapshot %2)\" did not load successfully:\n%3"),
+ path, snap_name, e.what()),
+ true,
+ Gtk::MESSAGE_INFO,
+ BUTTONS_OK);
msg.set_title (_("Loading Error"));
msg.set_position (Gtk::WIN_POS_CENTER);
- pop_back_splash (msg);
- msg.present ();
dump_errors (cerr);
}
catch (...) {
- MessageDialog msg (string_compose(
+ ArdourMessageDialog msg (string_compose(
_("Session \"%1 (snapshot %2)\" did not load successfully."),
path, snap_name),
- true,
- Gtk::MESSAGE_INFO,
- BUTTONS_OK);
+ true,
+ Gtk::MESSAGE_INFO,
+ BUTTONS_OK);
msg.set_title (_("Loading Error"));
msg.set_position (Gtk::WIN_POS_CENTER);
- pop_back_splash (msg);
- msg.present ();
dump_errors (cerr);
}
if (!new_session->writable()) {
- MessageDialog msg (_("This session has been opened in read-only mode.\n\nYou will not be able to record or save."),
- true,
- Gtk::MESSAGE_INFO,
- BUTTONS_OK);
+ ArdourMessageDialog msg (_("This session has been opened in read-only mode.\n\nYou will not be able to record or save."),
+ true,
+ Gtk::MESSAGE_INFO,
+ BUTTONS_OK);
msg.set_title (_("Read-only Session"));
msg.set_position (Gtk::WIN_POS_CENTER);
- pop_back_splash (msg);
- msg.present ();
(void) msg.run ();
msg.hide ();
}
cerr << "Here are the errors associated with this failed session:\n";
dump_errors (cerr);
cerr << "---------\n";
- MessageDialog msg (string_compose(_("Could not create session in \"%1\": %2"), path, e.what()));
+ ArdourMessageDialog msg (string_compose(_("Could not create session in \"%1\": %2"), path, e.what()));
msg.set_title (_("Loading Error"));
msg.set_position (Gtk::WIN_POS_CENTER);
- pop_back_splash (msg);
msg.run ();
return -1;
}
cerr << "Here are the errors associated with this failed session:\n";
dump_errors (cerr);
cerr << "---------\n";
- MessageDialog msg (string_compose(_("Could not create session in \"%1\""), path));
+ ArdourMessageDialog msg (string_compose(_("Could not create session in \"%1\""), path));
msg.set_title (_("Loading Error"));
msg.set_position (Gtk::WIN_POS_CENTER);
- pop_back_splash (msg);
msg.run ();
return -1;
}
break;
case 1:
if (save_state_canfail ("")) {
- MessageDialog msg (_main_window,
+ ArdourMessageDialog msg (_main_window,
string_compose (_("\
%1 was unable to save your session.\n\n\
If you still wish to proceed, please use the\n\n\
\"Don't save now\" option."), PROGRAM_NAME));
- pop_back_splash(msg);
msg.run ();
return;
}
char illegal = Session::session_name_is_legal (name);
if (illegal) {
- MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
+ ArdourMessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
"session names may not contain a '%1' character"), illegal));
msg.run ();
goto again;
switch (_session->rename (name)) {
case -1: {
- MessageDialog msg (_("That name is already in use by another directory/folder. Please try again."));
- msg.set_position (WIN_POS_MOUSE);
+ ArdourMessageDialog msg (_("That name is already in use by another directory/folder. Please try again."));
msg.run ();
goto again;
break;
case 0:
break;
default: {
- MessageDialog msg (_("Renaming this session failed.\nThings could be seriously messed up at this point"));
- msg.set_position (WIN_POS_MOUSE);
+ ArdourMessageDialog msg (_("Renaming this session failed.\nThings could be seriously messed up at this point"));
msg.run ();
break;
}
break;
case 1:
if (save_state_canfail ("")) {
- MessageDialog msg (_main_window,
+ ArdourMessageDialog msg (_main_window,
string_compose (_("\
%1 was unable to save your session.\n\n\
If you still wish to proceed, please use the\n\n\
\"Don't save now\" option."), PROGRAM_NAME));
- pop_back_splash(msg);
msg.run ();
return;
}
if (_session->save_as (sa)) {
/* ERROR MESSAGE */
- MessageDialog msg (string_compose (_("Save As failed: %1"), sa.failure_message));
+ ArdourMessageDialog msg (string_compose (_("Save As failed: %1"), sa.failure_message));
msg.run ();
}
}
if (_session->archive_session (sad.target_folder(), sad.name(), sad.encode_option (), sad.compression_level (), sad.only_used_sources (), &sad)) {
- MessageDialog msg (_("Session Archiving failed."));
+ ArdourMessageDialog msg (_("Session Archiving failed."));
msg.run ();
}
}
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));
+ ArdourMessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
+ "snapshot names may not contain a '%1' character"), illegal));
msg.run ();
return false;
}
load_session (path, name);
}
else if (rv < 0) {
- MessageDialog msg (_main_window,
- string_compose (_("Extracting session-archive failed: %1"), inflate_error (rv)));
+ ArdourMessageDialog msg (_main_window,
+ string_compose (_("Extracting session-archive failed: %1"), inflate_error (rv)));
msg.run ();
}
else if (ARDOUR::find_session (session_path, path, name, isnew) == 0) {