summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2020-03-24 18:26:12 -0600
committerPaul Davis <paul@linuxaudiosystems.com>2020-03-24 18:26:12 -0600
commit4d91637b45644de2923ca6163d6c926dd5fe0e4e (patch)
tree9918c4453999728ec8330a36ad00059d8d47eae5
parent75fec524d21c80f31f6c25188078229fe80eeba0 (diff)
handle scratch session when quitting
-rw-r--r--gtk2_ardour/ardour_ui.cc58
1 files changed, 54 insertions, 4 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 52da9f9615..d4fa0855ab 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -976,19 +976,32 @@ ARDOUR_UI::idle_finish ()
void
ARDOUR_UI::finish()
{
+ bool delete_unnamed_session = false;
+ const bool unnamed = _session->unnamed();
+
if (_session) {
ARDOUR_UI::instance()->video_timeline->sync_session_state();
- if (_session->dirty()) {
+ if (_session->dirty() || unnamed) {
vector<string> actions;
actions.push_back (_("Don't quit"));
- actions.push_back (_("Just quit"));
- actions.push_back (_("Save and quit"));
- switch (ask_about_saving_session(actions)) {
+
+ if (_session->unnamed()) {
+ actions.push_back (_("Discard session"));
+ actions.push_back (_("Name session and quit"));
+ } else {
+ actions.push_back (_("Just quit"));
+ actions.push_back (_("Save and quit"));
+ }
+
+ switch (ask_about_saving_session (actions)) {
case -1:
return;
break;
case 1:
+ if (unnamed) {
+ rename_session (true);
+ }
/* use the default name */
if (save_state_canfail ("")) {
/* failed - don't quit */
@@ -1002,6 +1015,9 @@ If you still wish to quit, please use the\n\n\
}
break;
case 0:
+ if (unnamed) {
+ delete_unnamed_session = true;
+ }
break;
}
}
@@ -1029,9 +1045,43 @@ If you still wish to quit, please use the\n\n\
close_all_dialogs ();
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);
+ }
+ }
+
_session->set_clean ();
delete _session;
_session = 0;
+
}
halt_connection.disconnect ();