summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-01-07 04:23:22 +0000
committerDavid Robillard <d@drobilla.net>2010-01-07 04:23:22 +0000
commit5f58582a4a9aebb3c223e7132d24a278ce29e1cb (patch)
treeec33e676afc2f9285ddf14cdbcf7a107e8a24c0e
parent2d3e27ef80e4fc8704390ea7a878068b5ae6a370 (diff)
downloadingen-5f58582a4a9aebb3c223e7132d24a278ce29e1cb.tar.gz
ingen-5f58582a4a9aebb3c223e7132d24a278ce29e1cb.tar.bz2
ingen-5f58582a4a9aebb3c223e7132d24a278ce29e1cb.zip
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
-rw-r--r--src/gui/App.cpp28
-rw-r--r--src/gui/App.hpp2
-rw-r--r--src/gui/ConnectWindow.cpp31
-rw-r--r--src/gui/ConnectWindow.hpp7
-rw-r--r--src/gui/PatchWindow.cpp38
-rw-r--r--src/gui/WindowFactory.cpp16
6 files changed, 50 insertions, 72 deletions
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index 9391200d..c2cde0ed 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -143,7 +143,8 @@ App::init(Ingen::Shared::World* world)
// (otherwise with 'ingen -egl' we'll get a bunch of notifications about load immediately
// before even knowing about the root patch or plugins)
while (!App::instance().connect_window()->attached())
- _main->iteration();
+ if (_main->iteration())
+ break;
}
@@ -314,10 +315,29 @@ App::show_about()
}
-void
-App::quit()
+/** Prompt (if necessary) and quit application (if confirmed).
+ * @return true iff the application quit.
+ */
+bool
+App::quit(Gtk::Window& dialog_parent)
{
- Gtk::Main::quit();
+ bool quit = true;
+ if (App::instance().world()->local_engine) {
+ Gtk::MessageDialog d(dialog_parent,
+ "The engine is running in this process. Quitting will terminate Ingen."
+ "\n\n" "Are 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);
+ quit = (d.run() == Gtk::RESPONSE_CLOSE);
+ }
+
+ if (quit)
+ Gtk::Main::quit();
+
+ //App::instance().engine()->quit();
+
+ return quit;
}
diff --git a/src/gui/App.hpp b/src/gui/App.hpp
index 0ced5584..5153849b 100644
--- a/src/gui/App.hpp
+++ b/src/gui/App.hpp
@@ -84,7 +84,7 @@ public:
bool gtk_main_iteration();
void show_about();
- void quit();
+ bool quit(Gtk::Window& dialog_parent);
void port_activity(Port* port);
void activity_port_destroyed(Port* port);
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::RefPtr<Gnome::
, _finished_connecting(false)
, _widgets_loaded(false)
, _connect_stage(0)
+ , _quit_flag(false)
{
}
@@ -337,7 +338,7 @@ ConnectWindow::load_widgets()
_disconnect_button->signal_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
diff --git a/src/gui/ConnectWindow.hpp b/src/gui/ConnectWindow.hpp
index c94c287a..3c2136af 100644
--- a/src/gui/ConnectWindow.hpp
+++ b/src/gui/ConnectWindow.hpp
@@ -56,7 +56,8 @@ public:
void start(Ingen::Shared::World* world);
void on_response(int32_t id) { _attached = true; }
- bool attached() const { return _finished_connecting; }
+ bool attached() const { return _finished_connecting; }
+ bool quit_flag() const { return _quit_flag; }
private:
enum Mode { CONNECT_REMOTE, LAUNCH_REMOTE, INTERNAL };
@@ -69,7 +70,7 @@ private:
void connect(bool existing);
void activate();
void deactivate();
- void quit();
+ void quit_clicked();
void on_show();
void on_hide();
@@ -77,6 +78,7 @@ private:
void set_connecting_widget_states();
bool gtk_callback();
+ void quit();
const Glib::RefPtr<Gnome::Glade::Xml> _xml;
@@ -86,6 +88,7 @@ private:
bool _finished_connecting;
bool _widgets_loaded;
int _connect_stage;
+ bool _quit_flag;
Gtk::Image* _icon;
Gtk::ProgressBar* _progress_bar;
diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp
index c9ca705a..5450d815 100644
--- a/src/gui/PatchWindow.cpp
+++ b/src/gui/PatchWindow.cpp
@@ -644,43 +644,7 @@ PatchWindow::event_close()
void
PatchWindow::event_quit()
{
- Gtk::Widget* kill_img = Gtk::manage(
- new Gtk::Image(Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON));
-
- Gtk::Widget* close_img = Gtk::manage(
- new Gtk::Image(Gtk::Stock::QUIT, Gtk::ICON_SIZE_BUTTON));
-
- const char* msg = (App::instance().world()->local_engine)
- ? "This will kill the engine as well.\nAre you sure you want to quit?"
- : "Would you like to quit just the GUI,\nor kill the engine as well?";
-
- Gtk::MessageDialog d(*this, msg,
- true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true);
-
- d.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-
- if (!App::instance().world()->local_engine) {
- Gtk::Button* b = d.add_button(Gtk::Stock::REMOVE, 2);
- b->set_label("_Kill Engine");
- b->set_image(*kill_img);
- }
-
- Gtk::Button* b = d.add_button(Gtk::Stock::QUIT, 1);
- b->set_label("_Quit");
- b->set_image(*close_img);
- b->grab_default();
-
- switch (d.run()) {
- case 1:
- App::instance().quit();
- break;
- case 2:
- App::instance().engine()->quit();
- App::instance().quit();
- break;
- default:
- break;
- }
+ App::instance().quit(*this);
}
diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp
index 83173325..3131070f 100644
--- a/src/gui/WindowFactory.cpp
+++ b/src/gui/WindowFactory.cpp
@@ -189,20 +189,8 @@ WindowFactory::new_patch_window(SharedPtr<PatchModel> patch, SharedPtr<PatchView
bool
WindowFactory::remove_patch_window(PatchWindow* win, GdkEventAny* ignored)
{
- if (_patch_windows.size() <= 1) {
- Gtk::MessageDialog d(*win,
- "Closing the only open patch window will exit the GUI\n"
- "(If the engine is remote it will remain running)\n\n"
- "Are 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);
- int ret = d.run();
- if (ret == Gtk::RESPONSE_CLOSE)
- App::instance().quit();
- else
- return true;
- }
+ if (_patch_windows.size() <= 1)
+ return App::instance().quit(*win);
PatchWindowMap::iterator w = _patch_windows.find(win->patch()->path());