diff options
author | Robin Gareus <robin@gareus.org> | 2020-02-27 23:27:42 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-02-27 23:27:42 +0100 |
commit | 8710a2d9432469909eb51d0644f2f25133240dbb (patch) | |
tree | 5f0c9e1663df050249152ec48f75dfa554ce56f2 /gtk2_ardour/editor_pt_import.cc | |
parent | e5c819956a95a1dc9dee8f805dc55757dc51233d (diff) |
Dialog default to cancel (#7915)
There are various ways to cancel a dialog. Only checking for
RESPONSE_CANCEL is not sufficient. e.g. Esc causes a delete-event.
* Gtk::RESPONSE_CLOSE
* Gtk::RESPONSE_REJECT
* Gtk::RESPONSE_DELETE_EVENT
* Gtk::RESPONSE_CANCEL
* Gtk::RESPONSE_NO
Among others this fixes "Clicking session > open,
then hitting ESC opens the currently selected folder and session"
Diffstat (limited to 'gtk2_ardour/editor_pt_import.cc')
-rw-r--r-- | gtk2_ardour/editor_pt_import.cc | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/gtk2_ardour/editor_pt_import.cc b/gtk2_ardour/editor_pt_import.cc index a6d635aaf2..befa5488af 100644 --- a/gtk2_ardour/editor_pt_import.cc +++ b/gtk2_ardour/editor_pt_import.cc @@ -87,39 +87,33 @@ Editor::external_pt_dialog () PTImportSelector dialog (import_ptf); dialog.set_session (_session); - while (true) { - int result = dialog.run (); - - if (result == Gtk::RESPONSE_ACCEPT) { - - import_pt_status.all_done = false; - - ImportProgressWindow ipw (&import_pt_status, _("PT Import"), _("Cancel Import")); - pthread_create_and_store ("import_pt", &import_pt_status.thread, _import_pt_thread, this); - pthread_detach (import_pt_status.thread); - - ipw.show(); - - while (!import_pt_status.all_done) { - gtk_main_iteration (); - } - - // wait for thread to terminate - while (!import_pt_status.done) { - gtk_main_iteration (); - } - - if (import_pt_status.cancel) { - MessageDialog msg (_("PT import may have missing files, check session log for details")); - msg.run (); - } else { - MessageDialog msg (_("PT import complete!")); - msg.run (); - } - break; - } else if (result == Gtk::RESPONSE_CANCEL) { - break; - } + if (dialog.run () != Gtk::RESPONSE_ACCEPT) { + return; + } + + import_pt_status.all_done = false; + + ImportProgressWindow ipw (&import_pt_status, _("PT Import"), _("Cancel Import")); + pthread_create_and_store ("import_pt", &import_pt_status.thread, _import_pt_thread, this); + pthread_detach (import_pt_status.thread); + + ipw.show(); + + while (!import_pt_status.all_done) { + gtk_main_iteration (); + } + + // wait for thread to terminate + while (!import_pt_status.done) { + gtk_main_iteration (); + } + + if (import_pt_status.cancel) { + MessageDialog msg (_("PT import may have missing files, check session log for details")); + msg.run (); + } else { + MessageDialog msg (_("PT import complete!")); + msg.run (); } } |