From 80923fdb966c74263a723f2ac6a39ea44efb07b2 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 6 Sep 2006 21:08:52 +0000 Subject: Connecting/Disconnecting/Reconnecting to the engine without restarting. git-svn-id: http://svn.drobilla.net/lad/ingen@115 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/Store.cpp | 9 +++++++++ src/libs/client/Store.h | 2 ++ src/progs/ingenuity/App.cpp | 19 ++++++++++++++++++ src/progs/ingenuity/App.h | 1 + src/progs/ingenuity/ConnectWindow.cpp | 30 ++++++++++++++++++++++++++--- src/progs/ingenuity/ConnectWindow.h | 1 + src/progs/ingenuity/GtkObjectController.cpp | 5 +++++ src/progs/ingenuity/GtkObjectController.h | 2 +- 8 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index 0b25da2e..403264f2 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -48,6 +48,15 @@ Store::Store(SigClientInterface& emitter) } +void +Store::clear() +{ + m_objects.clear(); + m_plugins.clear(); + +} + + void Store::add_object(CountedPtr object) { diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h index ff3eea62..cb6c3206 100644 --- a/src/libs/client/Store.h +++ b/src/libs/client/Store.h @@ -47,6 +47,8 @@ public: CountedPtr node(const string& path); CountedPtr port(const string& path);*/ + void clear(); + size_t num_objects() { return m_objects.size(); } const map >& plugins() const { return m_plugins; } diff --git a/src/progs/ingenuity/App.cpp b/src/progs/ingenuity/App.cpp index 1ca2fec5..26bf50cd 100644 --- a/src/progs/ingenuity/App.cpp +++ b/src/progs/ingenuity/App.cpp @@ -43,6 +43,7 @@ #include "PatchTreeWindow.h" #include "Configuration.h" #include "ConnectWindow.h" +#include "Store.h" #ifdef HAVE_LASH #include "LashController.h" #endif @@ -214,6 +215,24 @@ App::num_open_patch_windows() return ret; } + +void +App::disconnect() +{ + // FIXME: this is pretty gross.. figure out the death situation better + + list windows = m_windows; // make a copy + + for (list::iterator i = windows.begin(); i != windows.end(); ++i) + delete (*i); + + Store::instance().clear(); + + // PatchWindow destructor removes them from the list + assert(m_windows.size() == 0); +} + + void App::quit() { diff --git a/src/progs/ingenuity/App.h b/src/progs/ingenuity/App.h index faabc115..1e64abe8 100644 --- a/src/progs/ingenuity/App.h +++ b/src/progs/ingenuity/App.h @@ -69,6 +69,7 @@ public: void error_message(const string& msg); + void disconnect(); void quit(); void add_patch_window(PatchWindow* pw); diff --git a/src/progs/ingenuity/ConnectWindow.cpp b/src/progs/ingenuity/ConnectWindow.cpp index 4cfb7a9c..6715c4ed 100644 --- a/src/progs/ingenuity/ConnectWindow.cpp +++ b/src/progs/ingenuity/ConnectWindow.cpp @@ -26,6 +26,7 @@ #include "Store.h" #include "PatchController.h" #include "PatchModel.h" +#include "App.h" namespace Ingenuity { @@ -63,10 +64,27 @@ ConnectWindow::start(CountedPtr client) show(); } +void +ConnectWindow::init() +{ + _icon->set(Gtk::Stock::DISCONNECT, Gtk::ICON_SIZE_LARGE_TOOLBAR); + _progress_bar->set_fraction(0.0); + _url_entry->set_sensitive(true); + _connect_button->set_sensitive(true); + _disconnect_button->set_sensitive(false); + _port_spinbutton->set_sensitive(false); + _launch_radio->set_sensitive(true); + _internal_radio->set_sensitive(false); + server_toggled(); + + _progress_label->set_text(string("Disconnected")); +} void ConnectWindow::connect() { + _connect_button->set_sensitive(false); + if (_server_radio->get_active()) { Controller::instance().set_engine_url(_url_entry->get_text()); Glib::signal_timeout().connect( @@ -88,15 +106,19 @@ ConnectWindow::connect() sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100); } } - - _connect_button->set_sensitive(false); } void ConnectWindow::disconnect() { - // Nope + _progress_bar->set_fraction(0.0); + _connect_button->set_sensitive(false); + _disconnect_button->set_sensitive(false); + + App::instance().disconnect(); + + init(); } @@ -247,9 +269,11 @@ ConnectWindow::gtk_callback() _progress_bar->set_fraction(1.0); _url_entry->set_sensitive(false); _connect_button->set_sensitive(false); + _disconnect_button->set_sensitive(true); _port_spinbutton->set_sensitive(false); _launch_radio->set_sensitive(false); _internal_radio->set_sensitive(false); + stage = 0; // set ourselves up for next time (if there is one) return false; // deregister this callback } else { return true; diff --git a/src/progs/ingenuity/ConnectWindow.h b/src/progs/ingenuity/ConnectWindow.h index 3609c5fc..b553c3da 100644 --- a/src/progs/ingenuity/ConnectWindow.h +++ b/src/progs/ingenuity/ConnectWindow.h @@ -47,6 +47,7 @@ private: void launch_toggled(); void internal_toggled(); + void init(); void disconnect(); void connect(); void quit(); diff --git a/src/progs/ingenuity/GtkObjectController.cpp b/src/progs/ingenuity/GtkObjectController.cpp index d5fb08a1..798dc1f4 100644 --- a/src/progs/ingenuity/GtkObjectController.cpp +++ b/src/progs/ingenuity/GtkObjectController.cpp @@ -26,6 +26,11 @@ GtkObjectController::GtkObjectController(CountedPtr model) model->metadata_update_sig.connect(sigc::mem_fun(this, &GtkObjectController::metadata_update)); } +GtkObjectController::~GtkObjectController() +{ + assert(m_model->controller() == this); + m_model->set_controller(NULL); +} } // namespace Ingenuity diff --git a/src/progs/ingenuity/GtkObjectController.h b/src/progs/ingenuity/GtkObjectController.h index 735e7b6b..6df13d02 100644 --- a/src/progs/ingenuity/GtkObjectController.h +++ b/src/progs/ingenuity/GtkObjectController.h @@ -45,7 +45,7 @@ class GtkObjectController : public ObjectController { public: GtkObjectController(CountedPtr model); - virtual ~GtkObjectController() {} + virtual ~GtkObjectController(); /** Destroy object. * -- cgit v1.2.1