From 900bab7271f833139ef37e88e9f739c867cef423 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 24 Mar 2020 20:58:38 -0600 Subject: [PATCH] basic pass at deleting scratch sessions --- gtk2_ardour/ardour_ui.cc | 63 ++++++++++++++++++-------------- gtk2_ardour/ardour_ui.h | 2 + gtk2_ardour/ardour_ui_dialogs.cc | 5 ++- gtk2_ardour/audio_clock.cc | 1 + 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index f1bcf52f89..04985c85b5 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -1047,36 +1047,9 @@ If you still wish to quit, please use the\n\n\ if (_session) { - string path; - if (delete_unnamed_session) { - - path = _session->path(); - - ArdourMessageDialog msg (_main_window, - _("DANGER!"), - true, - Gtk::MESSAGE_WARNING, - Gtk::BUTTONS_NONE, true); - - msg.set_secondary_text (string_compose (_("You have not named this session yet.\n" - "You can continue to use it as\n\n" - "%1\n\n" - "or it will be deleted.\n\n" - "Deletion is permanent and irreversible."), _session->name())); - - msg.set_title (_("SCRATCH SESSION - DANGER!")); - msg.add_button (_("Delete this session (IRREVERSIBLE!)"), RESPONSE_OK); - msg.add_button (_("Do not delete"), RESPONSE_CANCEL); - msg.set_default_response (RESPONSE_CANCEL); - msg.set_position (Gtk::WIN_POS_MOUSE); - - int r = msg.run (); - - if (r == Gtk::RESPONSE_OK) { - PBD::remove_directory (path); - } + ask_about_scratch_deletion (); } _session->set_clean (); @@ -1093,6 +1066,40 @@ If you still wish to quit, please use the\n\n\ quit (); } +void +ARDOUR_UI::ask_about_scratch_deletion () +{ + if (!_session) { + return; + } + + string path = _session->path(); + + ArdourMessageDialog msg (_main_window, + _("DANGER!"), + true, + Gtk::MESSAGE_WARNING, + Gtk::BUTTONS_NONE, true); + + msg.set_secondary_text (string_compose (_("You have not named this session yet.\n" + "You can continue to use it as\n\n" + "%1\n\n" + "or it will be deleted.\n\n" + "Deletion is permanent and irreversible."), _session->name())); + + msg.set_title (_("SCRATCH SESSION - DANGER!")); + msg.add_button (_("Delete this session (IRREVERSIBLE!)"), RESPONSE_OK); + msg.add_button (_("Do not delete"), RESPONSE_CANCEL); + msg.set_default_response (RESPONSE_CANCEL); + msg.set_position (Gtk::WIN_POS_MOUSE); + + int r = msg.run (); + + if (r == Gtk::RESPONSE_OK) { + PBD::remove_directory (path); + } +} + void ARDOUR_UI::every_second () { diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index e0e212feb0..19e7fc55dc 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -890,6 +890,8 @@ private: bool bind_lua_action_script (GdkEventButton*, int); void update_action_script_btn (int i, const std::string&); + + void ask_about_scratch_deletion (); }; #endif /* __ardour_gui_h__ */ diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index e826f9500a..51ffd894af 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -308,13 +308,16 @@ ARDOUR_UI::unload_session (bool hide_stuff) case -1: // cancel return 1; - case 1: + if (_session->unnamed()) { + rename_session (true); + } _session->save_state (""); break; } } + { // tear down session specific CPI (owned by rc_config_editor which can remain) ControlProtocolManager& m = ControlProtocolManager::instance (); diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 1dd8c7b86e..3908682686 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -916,6 +916,7 @@ AudioClock::set (samplepos_t when, bool force, samplecnt_t offset) break; case Samples: + std::cerr << this << " set (" << when << ")\n"; set_samples (when, force); break; }