Fix thinkos in cubasish theme
[ardour.git] / gtk2_ardour / ardour_ui.cc
index ecc76e6dfb44ff537f97089b3570fc118d06463c..83609a6d70ff8695cb8c75a19fa270ff55c4fc66 100644 (file)
@@ -151,6 +151,7 @@ typedef uint64_t microseconds_t;
 #include "actions.h"
 #include "add_route_dialog.h"
 #include "ambiguous_file_dialog.h"
+#include "ardour_message.h"
 #include "ardour_ui.h"
 #include "audio_clock.h"
 #include "audio_region_view.h"
@@ -228,14 +229,15 @@ sigc::signal<void> ARDOUR_UI::CloseAllDialogs;
 static bool
 ask_about_configuration_copy (string const & old_dir, string const & new_dir, int version)
 {
-       MessageDialog msg (string_compose (_("%1 %2.x has discovered configuration files from %1 %3.x.\n\n"
-                                            "Would you like these files to be copied and used for %1 %2.x?\n\n"
-                                            "(This will require you to restart %1.)"),
-                                          PROGRAM_NAME, PROGRAM_VERSION, version),
-                          false, /* no markup */
-                          Gtk::MESSAGE_INFO,
-                          Gtk::BUTTONS_YES_NO,
-                          true /* modal, though it hardly matters since it is the only window */
+       ArdourMessageDialog msg (string_compose (
+                                 _("%1 %2.x has discovered configuration files from %1 %3.x.\n\n"
+                                   "Would you like these files to be copied and used for %1 %2.x?\n\n"
+                                   "(This will require you to restart %1.)"),
+                                    PROGRAM_NAME, PROGRAM_VERSION, version),
+                                false, /* no markup */
+                                Gtk::MESSAGE_INFO,
+                                Gtk::BUTTONS_YES_NO,
+                                true /* modal, though it hardly matters since it is the only window */
        );
 
        msg.set_default_response (Gtk::RESPONSE_YES);
@@ -363,7 +365,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
                        /* "touch" the been-here-before path now that config has been migrated */
                        PBD::ScopedFileDescriptor fout (g_open (been_here_before_path ().c_str(), O_CREAT|O_TRUNC|O_RDWR, 0666));
                }
-               MessageDialog msg (string_compose (_("Your configuration files were copied. You can now restart %1."), PROGRAM_NAME), true);
+               ArdourMessageDialog msg (string_compose (_("Your configuration files were copied. You can now restart %1."), PROGRAM_NAME), true);
                msg.run ();
                /* configuration was modified, exit immediately */
                _exit (EXIT_SUCCESS);
@@ -615,8 +617,7 @@ was not fast enough. Try to restart\n\
 the audio backend and save the session."), PROGRAM_NAME);
        }
 
-       MessageDialog msg (_main_window, msgstr);
-       pop_back_splash (msg);
+       ArdourMessageDialog msg (_main_window, msgstr);
        msg.run ();
 
        if (free_reason) {
@@ -856,14 +857,6 @@ ARDOUR_UI::~ARDOUR_UI ()
 #endif
 }
 
-void
-ARDOUR_UI::pop_back_splash (Gtk::Window& win)
-{
-       if (Splash::exists()) {
-               Splash::instance()->pop_back_for (win);
-       }
-}
-
 gint
 ARDOUR_UI::configure_timeout ()
 {
@@ -1002,12 +995,11 @@ ARDOUR_UI::finish()
                                /* use the default name */
                                if (save_state_canfail ("")) {
                                        /* failed - don't quit */
-                                       MessageDialog msg (_main_window,
+                                       ArdourMessageDialog msg (_main_window,
                                                           string_compose (_("\
 %1 was unable to save your session.\n\n\
 If you still wish to quit, please use the\n\n\
 \"Just quit\" option."), PROGRAM_NAME));
-                                       pop_back_splash(msg);
                                        msg.run ();
                                        return;
                                }
@@ -1329,13 +1321,13 @@ ARDOUR_UI::update_disk_space()
        if (!opt_samples) {
                /* Available space is unknown */
                format_disk_space_label (-1);
-       } else if (opt_samples.get_value_or (0) == max_samplecnt) {
+       } else if (opt_samples.value_or (0) == max_samplecnt) {
                format_disk_space_label (max_samplecnt);
        } else {
                rec_enabled_streams = 0;
                _session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams, false);
 
-               samplecnt_t samples = opt_samples.get_value_or (0);
+               samplecnt_t samples = opt_samples.value_or (0);
 
                if (rec_enabled_streams) {
                        samples /= rec_enabled_streams;
@@ -1356,12 +1348,13 @@ ARDOUR_UI::update_timecode_format ()
                boost::shared_ptr<TimecodeTransportMaster> tcmaster;
                boost::shared_ptr<TransportMaster> tm = TransportMasterManager::instance().current();
 
-               if ((tm->type() == LTC || tm->type() == MTC) && (tcmaster = boost::dynamic_pointer_cast<TimecodeTransportMaster>(tm)) != 0) {
+               if ((tm->type() == LTC || tm->type() == MTC) && (tcmaster = boost::dynamic_pointer_cast<TimecodeTransportMaster>(tm)) != 0 && tm->locked()) {
                        matching = (tcmaster->apparent_timecode_format() == _session->config.get_timecode_format());
                } else {
                        matching = true;
                }
 
+
                snprintf (buf, sizeof (buf), S_("Timecode|TC: <span foreground=\"%s\">%s</span>"),
                          matching ? X_("green") : X_("red"),
                          Timecode::timecode_format_name (_session->config.get_timecode_format()).c_str());
@@ -1555,12 +1548,11 @@ ARDOUR_UI::session_add_foldback_bus (int32_t channels, uint32_t how_many, string
 void
 ARDOUR_UI::display_insufficient_ports_message ()
 {
-       MessageDialog msg (_main_window,
+       ArdourMessageDialog msg (_main_window,
                        string_compose (_("There are insufficient ports available\n\
 to create a new track or bus.\n\
 You should save %1, exit and\n\
 restart with more ports."), PROGRAM_NAME));
-       pop_back_splash (msg);
        msg.run ();
 }
 
@@ -1700,7 +1692,7 @@ ARDOUR_UI::transport_record (bool roll)
                switch (_session->record_status()) {
                case Session::Disabled:
                        if (_session->ntracks() == 0) {
-                               MessageDialog msg (_main_window, _("Please create one or more tracks before trying to record.\nYou can do this with the \"Add Track or Bus\" option in the Session menu."));
+                               ArdourMessageDialog msg (_main_window, _("Please create one or more tracks before trying to record.\nYou can do this with the \"Add Track or Bus\" option in the Session menu."));
                                msg.run ();
                                return;
                        }
@@ -1718,7 +1710,11 @@ ARDOUR_UI::transport_record (bool roll)
                        break;
 
                case Session::Enabled:
-                       _session->disable_record (false, true);
+                       if (roll) {
+                               transport_roll();
+                       } else {
+                               _session->disable_record (false, true);
+                       }
                }
        }
 }
@@ -1754,16 +1750,8 @@ ARDOUR_UI::transport_roll ()
                */
 
                if (!Config->get_loop_is_mode()) {
-                       /* XXX it is not possible to just leave seamless loop and keep
-                          playing at present (nov 4th 2009)
-                       */
-                       if (!Config->get_seamless_loop()) {
-                               /* stop loop playback and stop rolling */
-                               _session->request_play_loop (false, true);
-                       } else if (rolling) {
-                               /* stop loop playback but keep rolling */
-                               _session->request_play_loop (false, false);
-                       }
+                       /* stop loop playback but keep transport state */
+                       _session->request_play_loop (false, false);
                }
 
        } else if (_session->get_play_range () ) {
@@ -1806,54 +1794,49 @@ ARDOUR_UI::toggle_roll (bool with_abort, bool roll_out_of_bounded_mode)
        }
 
        bool rolling = _session->transport_rolling();
-       bool affect_transport = true;
 
-       if (rolling && roll_out_of_bounded_mode) {
-               /* drop out of loop/range playback but leave transport rolling */
-               if (_session->get_play_loop()) {
-                       if (_session->actively_recording()) {
+       if (rolling) {
 
-                               /* just stop using the loop, then actually stop
-                                * below
-                                */
-                               _session->request_play_loop (false, affect_transport);
+               if (roll_out_of_bounded_mode) {
+                       /* drop out of loop/range playback but leave transport rolling */
 
-                       } else {
-                               if (Config->get_seamless_loop()) {
-                                       /* the disk buffers contain copies of the loop - we can't
-                                          just keep playing, so stop the transport. the user
-                                          can restart as they wish.
+                       if (_session->get_play_loop()) {
+
+                               if (_session->actively_recording()) {
+                                       /* actually stop transport because
+                                          otherwise the captured data will make
+                                          no sense.
                                        */
-                                       affect_transport = true;
+                                       _session->request_play_loop (false, true);
+
                                } else {
-                                       /* disk buffers are normal, so we can keep playing */
-                                       affect_transport = false;
+                                       _session->request_play_loop (false, false);
                                }
-                               _session->request_play_loop (false, affect_transport);
+
+                       } else if (_session->get_play_range ()) {
+
+                               _session->request_cancel_play_range ();
                        }
-               } else if (_session->get_play_range ()) {
-                       affect_transport = false;
-                       _session->request_play_range (0, true);
-               }
-       }
 
-       if (affect_transport) {
-               if (rolling) {
+               } else {
                        _session->request_stop (with_abort, true);
+               }
 
-               } else if (!with_abort) { /* with_abort == true means the
-                                          * command was intended to stop
-                                          * transport, not start.
-                                          */
+       } else { /* not rolling */
 
-                       /* the only external sync condition we can be in here
-                        * would be Engine (JACK) sync, in which case we still
-                        * want to do this.
-                        */
+               if (with_abort) { /* with_abort == true means the command was intended to stop transport, not start. */
+                       return;
+               }
 
-                       if (UIConfiguration::instance().get_follow_edits() && ( editor->get_selection().time.front().start == _session->transport_sample() ) ) {  //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_sample( editor->get_selection().time.front().start );  //force an auto-return here
+               if (_session->get_play_loop() && Config->get_loop_is_mode()) {
+                       _session->request_locate (_session->locations()->auto_loop_location()->start(), true);
+               } else {
+                       if (UIConfiguration::instance().get_follow_edits()) {
+                               list<AudioRange>& range = editor->get_selection().time;
+                               if (range.front().start == _session->transport_sample()) { // if playhead is exactly at the start of a range, we assume it was placed there by follow_edits
+                                       _session->request_play_range (&range, true);
+                                       _session->set_requested_return_sample (range.front().start);  //force an auto-return here
+                               }
                        }
                        _session->request_transport_speed (1.0f);
                }
@@ -2013,6 +1996,9 @@ ARDOUR_UI::map_transport_state ()
 {
        if (!_session) {
                layered_button.set_sensitive (false);
+               if (UIConfiguration::instance().get_screen_saver_mode () == InhibitWhileRecording) {
+                       inhibit_screensaver (false);
+               }
                return;
        }
 
@@ -2335,11 +2321,11 @@ ARDOUR_UI::display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* lis
        removed = rep.paths.size();
 
        if (removed == 0) {
-               MessageDialog msgd (_main_window,
-                                   _("No files were ready for clean-up"),
-                                   true,
-                                   Gtk::MESSAGE_INFO,
-                                   Gtk::BUTTONS_OK);
+               ArdourMessageDialog msgd (_main_window,
+                                         _("No files were ready for clean-up"),
+                                         true,
+                                         Gtk::MESSAGE_INFO,
+                                         Gtk::BUTTONS_OK);
                msgd.set_title (_("Clean-up"));
                msgd.set_secondary_text (_("If this seems surprising, \n\
 check for any existing snapshots.\n\
@@ -2478,10 +2464,10 @@ ARDOUR_UI::cleanup ()
        }
 
 
-       MessageDialog checker (_("Are you sure you want to clean-up?"),
-                               true,
-                               Gtk::MESSAGE_QUESTION,
-                               Gtk::BUTTONS_NONE);
+       ArdourMessageDialog checker (_("Are you sure you want to clean-up?"),
+                                    true,
+                                    Gtk::MESSAGE_QUESTION,
+                                    Gtk::BUTTONS_NONE);
 
        checker.set_title (_("Clean-up"));
 
@@ -2757,7 +2743,7 @@ ARDOUR_UI::disk_overrun_handler ()
 
        if (!have_disk_speed_dialog_displayed) {
                have_disk_speed_dialog_displayed = true;
-               MessageDialog* msg = new MessageDialog (_main_window, string_compose (_("\
+               ArdourMessageDialog* msg = new ArdourMessageDialog (_main_window, string_compose (_("\
 The disk system on your computer\n\
 was not able to keep up with %1.\n\
 \n\
@@ -2785,7 +2771,7 @@ ARDOUR_UI::disk_underrun_handler ()
 
        if (!have_disk_speed_dialog_displayed) {
                have_disk_speed_dialog_displayed = true;
-               MessageDialog* msg = new MessageDialog (
+               ArdourMessageDialog* msg = new ArdourMessageDialog (
                        _main_window, string_compose (_("The disk system on your computer\n\
 was not able to keep up with %1.\n\
 \n\
@@ -2807,13 +2793,8 @@ void
 ARDOUR_UI::session_dialog (std::string msg)
 {
        ENSURE_GUI_THREAD (*this, &ARDOUR_UI::session_dialog, msg)
-
-       MessageDialog* d;
-
-       d = new MessageDialog (msg, false, MESSAGE_INFO, BUTTONS_OK, true);
-       d->show_all ();
-       d->run ();
-       delete d;
+       ArdourMessageDialog d (msg, false, MESSAGE_INFO, BUTTONS_OK, true);
+       d.run ();
 }
 
 int
@@ -2853,6 +2834,11 @@ what you would like to do.\n"), PROGRAM_NAME));
 void
 ARDOUR_UI::store_clock_modes ()
 {
+       if (session_load_in_progress) {
+               /* Do not overwrite clock modes while loading them (with a session) */
+               return;
+       }
+
        XMLNode* node = new XMLNode(X_("ClockModes"));
 
        for (vector<AudioClock*>::iterator x = AudioClock::clocks.begin(); x != AudioClock::clocks.end(); ++x) {