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"
This commit is contained in:
Robin Gareus 2020-02-27 23:27:42 +01:00
parent e5c819956a
commit 8710a2d943
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
10 changed files with 70 additions and 58 deletions

View File

@ -104,7 +104,6 @@ ARDOUR_UI::audioengine_became_silent ()
exit (EXIT_SUCCESS);
break;
case Gtk::RESPONSE_CANCEL:
default:
/* don't reset, save session and exit */
break;

View File

@ -857,10 +857,10 @@ If you still wish to proceed, please use the\n\n\
save_as_dialog->hide ();
switch (response) {
case Gtk::RESPONSE_OK:
break;
default:
return;
case Gtk::RESPONSE_OK:
break;
default:
return;
}
@ -1055,8 +1055,11 @@ ARDOUR_UI::open_session ()
int response = open_session_selector.run();
open_session_selector.hide ();
if (response == Gtk::RESPONSE_CANCEL) {
return;
switch (response) {
case Gtk::RESPONSE_ACCEPT:
break;
default:
return;
}
string session_path = open_session_selector.get_filename();

View File

@ -77,8 +77,11 @@ ARDOUR_UI::stop_video_server (bool ask_confirm)
confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
confirm.add_button (_("Yes, Stop It"), Gtk::RESPONSE_ACCEPT);
confirm.show_all ();
if (confirm.run() == RESPONSE_CANCEL) {
return;
switch (confirm.run()) {
case RESPONSE_ACCEPT:
break;
default:
return;
}
}
delete video_server_process;

View File

@ -4017,10 +4017,10 @@ Editor::freeze_route ()
int response = d.run ();
switch (response) {
case Gtk::RESPONSE_CANCEL:
return;
default:
break;
case Gtk::RESPONSE_OK:
break;
default:
return;
}
}
@ -5759,8 +5759,11 @@ Editor::insert_patch_change (bool from_context)
Evoral::PatchChange<Temporal::Beats> empty (Temporal::Beats(), 0, 0, 0);
PatchChangeDialog d (0, _session, empty, first->instrument_info(), Gtk::Stock::ADD);
if (d.run() == RESPONSE_CANCEL) {
return;
switch (d.run()) {
case Gtk::RESPONSE_ACCEPT:
break;
default:
return;
}
for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) {
@ -7324,8 +7327,12 @@ Editor::close_region_gaps ()
dialog.add_button (_("Ok"), RESPONSE_ACCEPT);
dialog.show_all ();
if (dialog.run () == RESPONSE_CANCEL) {
return;
switch (dialog.run ()) {
case Gtk::RESPONSE_ACCEPT:
case Gtk::RESPONSE_OK:
break;
default:
return;
}
samplepos_t crossfade_len = spin_crossfade.get_value();

View File

@ -87,39 +87,33 @@ Editor::external_pt_dialog ()
PTImportSelector dialog (import_ptf);
dialog.set_session (_session);
while (true) {
int result = dialog.run ();
if (dialog.run () != Gtk::RESPONSE_ACCEPT) {
return;
}
if (result == Gtk::RESPONSE_ACCEPT) {
import_pt_status.all_done = false;
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);
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();
ipw.show();
while (!import_pt_status.all_done) {
gtk_main_iteration ();
}
while (!import_pt_status.all_done) {
gtk_main_iteration ();
}
// wait for thread to terminate
while (!import_pt_status.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 (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 ();
}
}

View File

@ -273,16 +273,13 @@ EditorRouteGroups::button_press_event (GdkEventButton* ev)
color_dialog.get_colorsel()->set_current_color (c);
switch (color_dialog.run()) {
case RESPONSE_CANCEL:
break;
case RESPONSE_ACCEPT:
c = color_dialog.get_colorsel()->get_current_color();
GroupTabs::set_group_color (group, gdk_color_to_rgba (c));
break;
default:
break;
case RESPONSE_ACCEPT:
c = color_dialog.get_colorsel()->get_current_color();
GroupTabs::set_group_color (group, gdk_color_to_rgba (c));
break;
default:
break;
}
color_dialog.hide ();

View File

@ -349,6 +349,7 @@ ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::Select
_plugin_preset_pointer->_preset.valid = false;
switch (d.run ()) {
default:
case Gtk::RESPONSE_CANCEL:
data.set (data.get_target(), 8, NULL, 0);
return true;

View File

@ -236,9 +236,13 @@ SessionImportDialog::update (string path)
// Prompt user for verification
string txt = _("This will select all elements of this type!");
ArdourMessageDialog msg (txt, false, MESSAGE_QUESTION, BUTTONS_OK_CANCEL, true);
if (msg.run() == RESPONSE_CANCEL) {
(*cell)[sb_cols.queued] = false;
return;
switch (msg.run()) {
case Gtk::RESPONSE_ACCEPT:
case Gtk::RESPONSE_OK:
break;
default:
(*cell)[sb_cols.queued] = false;
return;
}
}

View File

@ -853,7 +853,6 @@ ARDOUR_UI_UTILS::overwrite_file_dialog (Gtk::Window& parent, string title, strin
switch (dialog.run()) {
case RESPONSE_ACCEPT:
return true;
case RESPONSE_CANCEL:
default:
return false;
}

View File

@ -70,7 +70,12 @@ VideoUtils::confirm_video_outfn (Gtk::Window& parent, std::string outfn, std::st
confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
confirm.add_button (_("Continue"), Gtk::RESPONSE_ACCEPT);
confirm.show_all ();
if (confirm.run() == RESPONSE_CANCEL) { return false; }
switch (confirm.run ()) {
case Gtk::RESPONSE_ACCEPT:
break;
default:
return false;
}
}
if (Glib::file_test(outfn, Glib::FILE_TEST_EXISTS)) {