adjusting region fade in/out lengths makes the fade in/out active; new font sizes...
[ardour.git] / gtk2_ardour / ardour_ui.cc
index 93d69cc6269b87507e563a2774b04d98b9fe3709..ee110c435aa82c927c500f71257e6d8232e4724b 100644 (file)
@@ -231,6 +231,10 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
 
        ARDOUR::Session::AskAboutPendingState.connect (mem_fun(*this, &ARDOUR_UI::pending_state_dialog));
 
+       /* handle sr mismatch with a dialog */
+
+       ARDOUR::Session::AskAboutSampleRateMismatch.connect (mem_fun(*this, &ARDOUR_UI::sr_mismatch_dialog));
+
        /* lets get this party started */
 
        try {
@@ -388,6 +392,15 @@ ARDOUR_UI::~ARDOUR_UI ()
        }
 }
 
+void
+ARDOUR_UI::pop_back_splash ()
+{
+       if (Splash::instance()) {
+               // Splash::instance()->pop_back();
+               Splash::instance()->hide ();
+       }
+}
+
 gint
 ARDOUR_UI::configure_timeout ()
 {
@@ -599,6 +612,7 @@ Please consider the possibilities, and perhaps (re)start JACK."));
        
        win.show_all ();
        win.set_position (Gtk::WIN_POS_CENTER);
+       pop_back_splash ();
 
        /* we just don't care about the result, but we want to block */
 
@@ -679,6 +693,8 @@ ARDOUR_UI::check_memory_locking ()
                                hbox.pack_start (cb, true, false);
                                vbox->pack_start (hbox);
                                hbox.show_all ();
+
+                               pop_back_splash ();
                                
                                msg.run ();
                        }
@@ -712,6 +728,7 @@ ARDOUR_UI::finish()
 Ardour was unable to save your session.\n\n\
 If you still wish to quit, please use the\n\n\
 \"Just quit\" option."));
+                                       pop_back_splash();
                                        msg.run ();
                                        return;
                                }
@@ -984,6 +1001,13 @@ ARDOUR_UI::redisplay_recent_sessions ()
                        fullpath = fullpath.substr (0, fullpath.length()-1);
                }
 
+               /* check whether session still exists */
+               if (!Glib::file_test(fullpath.c_str(), Glib::FILE_TEST_EXISTS)) {
+                       /* session doesn't exist */
+                       cerr << "skipping non-existent session " << fullpath << endl;
+                       continue;
+               }               
+               
                /* now get available states for this session */
 
                if ((states = Session::possible_states (fullpath)) == 0) {
@@ -1138,6 +1162,7 @@ ARDOUR_UI::check_audioengine ()
                if (!engine->connected()) {
                        MessageDialog msg (_("Ardour is not connected to JACK\n"
                                             "You cannot open or close sessions in this condition"));
+                       pop_back_splash ();
                        msg.run ();
                        return false;
                }
@@ -1259,6 +1284,7 @@ ARDOUR_UI::session_add_audio_route (bool track, int32_t input_channels, int32_t
 to create a new track or bus.\n\
 You should save Ardour, exit and\n\
 restart JACK with more ports."));
+               pop_back_splash ();
                msg.run ();
        }
 }
@@ -1635,6 +1661,7 @@ JACK has either been shutdown or it\n\
 disconnected Ardour because Ardour\n\
 was not fast enough. You can save the\n\
 session and/or try to reconnect to JACK ."));
+       pop_back_splash ();
        msg.run ();
 }
 
@@ -1982,6 +2009,7 @@ ARDOUR_UI::fontconfig_dialog ()
                                   true,
                                   Gtk::MESSAGE_INFO,
                                   Gtk::BUTTONS_OK);
+               pop_back_splash ();
                msg.show_all ();
                msg.present ();
                msg.run ();
@@ -2072,7 +2100,8 @@ ARDOUR_UI::ask_about_loading_existing_session (const Glib::ustring& session_path
        msg.set_name (X_("CleanupDialog"));
        msg.set_wmclass (X_("existing_session"), "Ardour");
        msg.set_position (Gtk::WIN_POS_MOUSE);
-       
+       pop_back_splash ();
+
        switch (msg.run()) {
        case RESPONSE_YES:
                return true;
@@ -2162,7 +2191,6 @@ ARDOUR_UI::end_loading_messages ()
 void
 ARDOUR_UI::loading_message (const std::string& msg)
 {
-       cerr << "say: " << msg << endl;
        show_splash ();
        splash->message (msg);
        flush_pending ();
@@ -2280,6 +2308,7 @@ ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be
                                session_path = new_session_dialog->session_folder();
                        }
 
+                       template_name = Glib::ustring();                        
                        switch (new_session_dialog->which_page()) {
 
                        case NewSessionDialog::OpenPage: 
@@ -2329,7 +2358,7 @@ ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be
                  loadit:
                        new_session_dialog->hide ();
                        
-                       if (load_session (session_path, session_name)) {
+                       if (load_session (session_path, session_name, template_name)) {
                                /* force a retry */
                                response = Gtk::RESPONSE_NONE;
                        }
@@ -2390,6 +2419,7 @@ ARDOUR_UI::load_session (const Glib::ustring& path, const Glib::ustring& snap_na
        if (Glib::file_test (path.c_str(), Glib::FILE_TEST_EXISTS) && ::access (path.c_str(), W_OK)) {
                MessageDialog msg (*editor, _("You do not have write access to this session.\n"
                                              "This prevents the session from being loaded."));
+               pop_back_splash ();
                msg.run ();
                goto out;
        }
@@ -2413,6 +2443,7 @@ ARDOUR_UI::load_session (const Glib::ustring& path, const Glib::ustring& snap_na
                msg.set_title (_("Loading Error"));
                msg.set_secondary_text (_("Click the OK button to try again."));
                msg.set_position (Gtk::WIN_POS_CENTER);
+               pop_back_splash ();
                msg.present ();
 
                int response = msg.run ();
@@ -2438,6 +2469,7 @@ ARDOUR_UI::load_session (const Glib::ustring& path, const Glib::ustring& snap_na
                msg.set_title (_("Loading Error"));
                msg.set_secondary_text (_("Click the OK button to try again."));
                msg.set_position (Gtk::WIN_POS_CENTER);
+               pop_back_splash ();
                msg.present ();
 
                int response = msg.run ();
@@ -2510,6 +2542,7 @@ ARDOUR_UI::build_session (const Glib::ustring& path, const Glib::ustring& snap_n
        catch (...) {
 
                MessageDialog msg (string_compose(_("Could not create session in \"%1\""), path));
+               pop_back_splash ();
                msg.run ();
                return -1;
        }
@@ -2963,6 +2996,38 @@ what you would like to do.\n"));
                return 0;
        }
 }
+
+int
+ARDOUR_UI::sr_mismatch_dialog (nframes_t desired, nframes_t actual)
+{
+       HBox* hbox = new HBox();
+       Image* image = new Image (Stock::DIALOG_QUESTION, ICON_SIZE_DIALOG);
+       ArdourDialog dialog (_("Sample Rate Mismatch"), true);
+       Label  message (string_compose (_("\
+This session was created with a sample rate of %1 Hz\n\
+\n\
+The audioengine is currently running at %2 Hz\n"), desired, actual));
+
+       image->set_alignment(ALIGN_CENTER, ALIGN_TOP);
+       hbox->pack_start (*image, PACK_EXPAND_WIDGET, 12);
+       hbox->pack_end (message, PACK_EXPAND_PADDING, 12);
+       dialog.get_vbox()->pack_start(*hbox, PACK_EXPAND_PADDING, 6);
+       dialog.add_button (_("Load session anyway"), RESPONSE_ACCEPT);
+       dialog.add_button (_("Do not load session"), RESPONSE_REJECT);
+       dialog.set_default_response (RESPONSE_ACCEPT);
+       dialog.set_position (WIN_POS_CENTER);
+       message.show();
+       image->show();
+       hbox->show();
+
+       switch (dialog.run ()) {
+       case RESPONSE_ACCEPT:
+               return 0;
+       default:
+               return 1;
+       }
+}
+
        
 void
 ARDOUR_UI::disconnect_from_jack ()