Connecting/Disconnecting/Reconnecting to the engine without restarting.

git-svn-id: http://svn.drobilla.net/lad@115 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
dave 2006-09-06 21:08:52 +00:00
parent 8367cf3848
commit f0e8fd23e1
8 changed files with 65 additions and 4 deletions

View File

@ -48,6 +48,15 @@ Store::Store(SigClientInterface& emitter)
}
void
Store::clear()
{
m_objects.clear();
m_plugins.clear();
}
void
Store::add_object(CountedPtr<ObjectModel> object)
{

View File

@ -47,6 +47,8 @@ public:
CountedPtr<NodeModel> node(const string& path);
CountedPtr<PortModel> port(const string& path);*/
void clear();
size_t num_objects() { return m_objects.size(); }
const map<string, CountedPtr<PluginModel> >& plugins() const { return m_plugins; }

View File

@ -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<PatchWindow*> windows = m_windows; // make a copy
for (list<PatchWindow*>::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()
{

View File

@ -69,6 +69,7 @@ public:
void error_message(const string& msg);
void disconnect();
void quit();
void add_patch_window(PatchWindow* pw);

View File

@ -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<Ingen::Shared::ClientInterface> 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;

View File

@ -47,6 +47,7 @@ private:
void launch_toggled();
void internal_toggled();
void init();
void disconnect();
void connect();
void quit();

View File

@ -26,6 +26,11 @@ GtkObjectController::GtkObjectController(CountedPtr<ObjectModel> 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

View File

@ -45,7 +45,7 @@ class GtkObjectController : public ObjectController
{
public:
GtkObjectController(CountedPtr<ObjectModel> model);
virtual ~GtkObjectController() {}
virtual ~GtkObjectController();
/** Destroy object.
*