summaryrefslogtreecommitdiff
path: root/gtk2_ardour/ardour_ui_dependents.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-07-27 10:50:35 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-02-22 15:31:23 -0500
commit1be30e040169863006eb37d8ee2b8ad919febfa3 (patch)
treeca06e27b0c28d9a02d3f491f3c8fb6c1f6e6236e /gtk2_ardour/ardour_ui_dependents.cc
parent58757ebd387ca6f46c365025daf5b3b65455279a (diff)
handle main window delete events sensibly
Diffstat (limited to 'gtk2_ardour/ardour_ui_dependents.cc')
-rw-r--r--gtk2_ardour/ardour_ui_dependents.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/gtk2_ardour/ardour_ui_dependents.cc b/gtk2_ardour/ardour_ui_dependents.cc
index 97c81f187a..0d7b5a1353 100644
--- a/gtk2_ardour/ardour_ui_dependents.cc
+++ b/gtk2_ardour/ardour_ui_dependents.cc
@@ -155,3 +155,41 @@ ARDOUR_UI::tab_window_root_drop (GtkNotebook* src,
return 0; /* what was that? */
}
+
+bool
+ARDOUR_UI::idle_ask_about_quit ()
+{
+ if (_session && _session->dirty()) {
+ finish ();
+ } else {
+ /* no session or session not dirty, but still ask anyway */
+
+ Gtk::MessageDialog msg (string_compose ("Quit %1?", PROGRAM_NAME),
+ false, /* no markup */
+ Gtk::MESSAGE_INFO,
+ Gtk::BUTTONS_YES_NO,
+ true); /* modal */
+ msg.set_default_response (Gtk::RESPONSE_YES);
+
+ if (msg.run() == Gtk::RESPONSE_YES) {
+ finish ();
+ }
+ }
+
+ /* not reached but keep the compiler happy */
+
+ return false;
+}
+
+bool
+ARDOUR_UI::main_window_delete_event (GdkEventAny* ev)
+{
+ /* quit the application as soon as we go idle. If we call this here,
+ * the window manager/desktop can think we're taking too longer to
+ * handle the "delete" event
+ */
+
+ Glib::signal_idle().connect (sigc::mem_fun (*this, &ARDOUR_UI::idle_ask_about_quit));
+
+ return true;
+}