From 5f58582a4a9aebb3c223e7132d24a278ce29e1cb Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 7 Jan 2010 04:23:22 +0000 Subject: Quit cleanly from connect dialog when not connected to engine. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2357 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/ConnectWindow.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/gui/ConnectWindow.cpp') diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index d2783c30..281fa274 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -66,6 +66,7 @@ ConnectWindow::ConnectWindow(BaseObjectType* cobject, const Glib::RefPtrsignal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::disconnect)); _connect_button->signal_clicked().connect(sigc::bind( sigc::mem_fun(this, &ConnectWindow::connect), false)); - _quit_button->signal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::quit)); + _quit_button->signal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::quit_clicked)); _progress_bar->set_pulse_step(0.01); _widgets_loaded = true; @@ -351,24 +352,15 @@ ConnectWindow::on_hide() { Gtk::Dialog::on_hide(); if (!_attached) - Gtk::Main::quit(); + quit(); } void -ConnectWindow::quit() +ConnectWindow::quit_clicked() { - if (_attached) { - Gtk::MessageDialog d(*this, "This will exit the GUI, but the engine will " - "remain running (if it is remote).\n\nAre you sure you want to quit?", - true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE, true); - d.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - d.add_button(Gtk::Stock::QUIT, Gtk::RESPONSE_CLOSE); - if (d.run() == Gtk::RESPONSE_CLOSE) - Gtk::Main::quit(); - } else { - Gtk::Main::quit(); - } + if (App::instance().quit(*this)) + _quit_flag = true; } @@ -404,6 +396,9 @@ ConnectWindow::gtk_callback() { /* If I call this a "state machine" it's not ugly code any more */ + if (_quit_flag) + return false; // deregister this callback + // Timing stuff for repeated attach attempts timeval now; gettimeofday(&now, NULL); @@ -495,5 +490,13 @@ ConnectWindow::gtk_callback() } +void +ConnectWindow::quit() +{ + _quit_flag = true; + Gtk::Main::quit(); +} + + } // namespace GUI } // namespace Ingen -- cgit v1.2.1