Stop ardour exiting in the case where you have a loaded session, then select New...
authorCarl Hetherington <carl@carlh.net>
Mon, 19 Oct 2009 18:12:20 +0000 (18:12 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 19 Oct 2009 18:12:20 +0000 (18:12 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5808 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/startup.cc
gtk2_ardour/startup.h

index 83a19ff37929feb8962517d2910067ad7bed4e8f..41281999ee8226c45a2486941e6f260b3817e4b0 100644 (file)
@@ -281,7 +281,8 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
        platform_setup ();
 }
 
-void
+/** @return true if a session was chosen and `apply' clicked, otherwise false if `cancel' was clicked */
+bool
 ARDOUR_UI::run_startup (bool should_be_new)
 {
        if (_startup == 0) {
@@ -296,6 +297,8 @@ ARDOUR_UI::run_startup (bool should_be_new)
        /* we don't return here until the startup assistant is finished */
 
        _startup->hide ();
+
+       return _startup->applying ();
 }
 
 int
@@ -654,7 +657,7 @@ ARDOUR_UI::startup ()
                _startup->engine_control()->set_state (*audio_setup);
        }
 
-       if (get_session_parameters (ARDOUR_COMMAND_LINE::new_session)) {
+       if (get_session_parameters (true, ARDOUR_COMMAND_LINE::new_session)) {
                exit (1);
        }
 
@@ -2261,8 +2264,9 @@ ARDOUR_UI::loading_message (const std::string& /*msg*/)
        flush_pending ();
 }
 
+/** @param quit_on_cancel true if exit() should be called if the user clicks `cancel' in the new session dialog */
 int
-ARDOUR_UI::get_session_parameters (bool should_be_new)
+ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new)
 {
        Glib::ustring session_name;
        Glib::ustring session_path;
@@ -2270,6 +2274,8 @@ ARDOUR_UI::get_session_parameters (bool should_be_new)
        int ret = -1;
        bool likely_new = false;
 
+       cout << "get_session_parameters\n";
+
        while (ret != 0) {
 
                if (!should_be_new && !ARDOUR_COMMAND_LINE::session_name.empty()) {
@@ -2289,7 +2295,14 @@ ARDOUR_UI::get_session_parameters (bool should_be_new)
 
                } else {
 
-                       run_startup (should_be_new);
+                       bool const apply = run_startup (should_be_new);
+                       if (!apply) {
+                               if (quit_on_cancel) {
+                                       exit (1);
+                               } else {
+                                       return ret;
+                               }
+                       }
 
                        /* if we run the startup dialog again, offer more than just "new session" */
 
@@ -2307,7 +2320,6 @@ ARDOUR_UI::get_session_parameters (bool should_be_new)
                                _session_is_new = true;
                        }
 
-
                        if (session_name[0] == '/' ||
                            (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
                            (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
@@ -2378,7 +2390,7 @@ ARDOUR_UI::close_session()
        unload_session (true);
 
        ARDOUR_COMMAND_LINE::session_name = "";
-       get_session_parameters (false);
+       get_session_parameters (true, false);
 }
 
 int
index eb161d8e2d35dbf475deee285e9fcb01ad049355..c71a4d7e679addc21df81668f1dd29ae60e31271 100644 (file)
@@ -104,7 +104,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
        ARDOUR_UI (int *argcp, char **argvp[]);
        ~ARDOUR_UI();
 
-       void run_startup (bool should_be_new);
+       bool run_startup (bool should_be_new);
 
        void show ();
        bool shown() { return shown_flag; }
@@ -140,7 +140,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
                _will_create_new_session_automatically = yn;
        }
 
-       int get_session_parameters (bool should_be_new = false);
+       int get_session_parameters (bool quit_on_cancel, bool should_be_new = false);
        void parse_cmdline_path (const Glib::ustring& cmdline_path, Glib::ustring& session_name, Glib::ustring& session_path, bool& existing_session);
        int  load_cmdline_session (const Glib::ustring& session_name, const Glib::ustring& session_path, bool& existing_session);
        int  build_session_from_nsd (const Glib::ustring& session_name, const Glib::ustring& session_path);
index d85f1c00c1cb527d7163cce0aa8ef844ee21d97e..c1ffb11dc3652659be0c8598a74225834cf253f2 100644 (file)
@@ -107,7 +107,7 @@ ARDOUR_UI::install_actions ()
 
        /* the real actions */
 
-       act = ActionManager::register_action (main_actions, X_("New"), _("New..."),  hide_return (bind (mem_fun(*this, &ARDOUR_UI::get_session_parameters), true)));
+       act = ActionManager::register_action (main_actions, X_("New"), _("New..."),  hide_return (bind (mem_fun(*this, &ARDOUR_UI::get_session_parameters), false, true)));
 
        ActionManager::register_action (main_actions, X_("Open"), _("Open..."),  mem_fun(*this, &ARDOUR_UI::open_session));
        ActionManager::register_action (main_actions, X_("Recent"), _("Recent..."),  mem_fun(*this, &ARDOUR_UI::open_recent_session));
index 4fc372b97627e84357735aca11426011397f67b5..962046165b1d9e2546c0966a4d077fbf20f51927 100644 (file)
@@ -38,7 +38,7 @@ static string poor_mans_glob (string path)
 
 
 ArdourStartup::ArdourStartup ()
-       : applying (false)
+       : _applying (false)
        , ic_new_session_button (_("Open a new session"))
        , ic_existing_session_button (_("Open an existing session"))
        , monitor_via_hardware_button (_("Use an external mixer or the hardware mixer of your audio interface.\n\
@@ -418,21 +418,19 @@ ArdourStartup::setup_final_page ()
 void
 ArdourStartup::on_cancel ()
 {
-       exit (1);
+       gtk_main_quit ();
 }
 
 void
 ArdourStartup::on_close ()
 {
-       if (!applying) {
-               exit (1);
-       }
+       gtk_main_quit ();
 }
 
 void
 ArdourStartup::on_apply ()
 {
-       applying = true;
+       _applying = true;
 
        // XXX do stuff and then ....
 
index 9a4202b3995d4595fbea95e81c09f7c0e26dc9c9..6b7e92a33bb2bf41ca1adf01bac02c16e3ab7f26 100644 (file)
@@ -54,10 +54,14 @@ class ArdourStartup : public Gtk::Assistant {
        int output_limit_count() const;
 
        bool connect_outs_to_master() const;
-       bool connect_outs_to_physical() const ;
+       bool connect_outs_to_physical() const;
+
+       bool applying () const {
+               return _applying;
+       }
 
   private:
-       bool applying;
+       bool _applying;
        bool config_modified;
        bool new_user;
        bool new_only;