From: Dan Breslau Date: Wed, 17 Aug 2016 22:18:07 +0000 (-0400) Subject: Intercept window close attempts, and ask user to confirm if selection is in progress X-Git-Url: http://www.project-moonshot.org/gitweb/?p=moonshot-ui.git;a=commitdiff_plain;h=7ef2862128043325316a1494bfc23687fb30421f;hp=7b7af6b7a02f69c6c6526a303b5532cb3d796f78 Intercept window close attempts, and ask user to confirm if selection is in progress --- diff --git a/src/moonshot-identity-management-view.vala b/src/moonshot-identity-management-view.vala index aebaec9..2b0a4ba 100644 --- a/src/moonshot-identity-management-view.vala +++ b/src/moonshot-identity-management-view.vala @@ -881,7 +881,31 @@ SUCH DAMAGE. private void connect_signals() { - this.destroy.connect(Gtk.main_quit); + this.destroy.connect(() => { + logger.trace("Destroy event; calling Gtk.main_quit()"); + Gtk.main_quit(); + }); this.identities_manager.card_list_changed.connect(this.on_card_list_changed); + this.delete_event.connect(() => {return confirm_quit();}); + } + + private bool confirm_quit() { + logger.trace("delete_event intercepted; selection_in_progress()=" + selection_in_progress().to_string()); + + if (selection_in_progress()) { + var result = WarningDialog.confirm(this, + Markup.printf_escaped( + _("Do you wish to use the %s service?"), + this.request_queue.peek_head().service) + + _("\n\nSelect Yes to select an ID for this service, or No to cancel"), + "close_moonshot_window"); + if (result) { + // Prevent other handlers from handling this event; this keeps the window open. + return true; + } + } + + // Allow the window deletion to proceed. + return false; } }