13
0

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

@ -1055,7 +1055,10 @@ ARDOUR_UI::open_session ()
int response = open_session_selector.run();
open_session_selector.hide ();
if (response == Gtk::RESPONSE_CANCEL) {
switch (response) {
case Gtk::RESPONSE_ACCEPT:
break;
default:
return;
}

View File

@ -77,7 +77,10 @@ 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) {
switch (confirm.run()) {
case RESPONSE_ACCEPT:
break;
default:
return;
}
}

View File

@ -4017,10 +4017,10 @@ Editor::freeze_route ()
int response = d.run ();
switch (response) {
case Gtk::RESPONSE_CANCEL:
return;
default:
case Gtk::RESPONSE_OK:
break;
default:
return;
}
}
@ -5759,7 +5759,10 @@ 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) {
switch (d.run()) {
case Gtk::RESPONSE_ACCEPT:
break;
default:
return;
}
@ -7324,7 +7327,11 @@ Editor::close_region_gaps ()
dialog.add_button (_("Ok"), RESPONSE_ACCEPT);
dialog.show_all ();
if (dialog.run () == RESPONSE_CANCEL) {
switch (dialog.run ()) {
case Gtk::RESPONSE_ACCEPT:
case Gtk::RESPONSE_OK:
break;
default:
return;
}

View File

@ -87,10 +87,9 @@ Editor::external_pt_dialog ()
PTImportSelector dialog (import_ptf);
dialog.set_session (_session);
while (true) {
int result = dialog.run ();
if (result == Gtk::RESPONSE_ACCEPT) {
if (dialog.run () != Gtk::RESPONSE_ACCEPT) {
return;
}
import_pt_status.all_done = false;
@ -116,11 +115,6 @@ Editor::external_pt_dialog ()
MessageDialog msg (_("PT import complete!"));
msg.run ();
}
break;
} else if (result == Gtk::RESPONSE_CANCEL) {
break;
}
}
}
void *

View File

@ -273,8 +273,6 @@ 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));
@ -282,7 +280,6 @@ EditorRouteGroups::button_press_event (GdkEventButton* ev)
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,7 +236,11 @@ 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) {
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)) {