diff options
author | David Robillard <d@drobilla.net> | 2006-09-08 23:15:42 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-09-08 23:15:42 +0000 |
commit | b853b3dde1f7028dd275f78433a6ad9b5b9f61c7 (patch) | |
tree | 0a3fa37cedd2ba49158e11168974387d1e0c3a37 /src/progs | |
parent | 9028938008fa22ca2fe0c4ac7677471ac499b63f (diff) | |
download | ingen-b853b3dde1f7028dd275f78433a6ad9b5b9f61c7.tar.gz ingen-b853b3dde1f7028dd275f78433a6ad9b5b9f61c7.tar.bz2 ingen-b853b3dde1f7028dd275f78433a6ad9b5b9f61c7.zip |
More cleanups
git-svn-id: http://svn.drobilla.net/lad/ingen@122 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/progs')
-rw-r--r-- | src/progs/demolition/DemolitionClientInterface.h | 2 | ||||
-rw-r--r-- | src/progs/ingenuity/App.cpp | 62 | ||||
-rw-r--r-- | src/progs/ingenuity/App.h | 51 | ||||
-rw-r--r-- | src/progs/ingenuity/ConnectWindow.cpp | 46 | ||||
-rw-r--r-- | src/progs/ingenuity/ConnectWindow.h | 35 | ||||
-rw-r--r-- | src/progs/ingenuity/Controller.cpp | 11 | ||||
-rw-r--r-- | src/progs/ingenuity/Controller.h | 2 | ||||
-rw-r--r-- | src/progs/ingenuity/LoadPluginWindow.cpp | 8 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchWindow.cpp | 2 | ||||
-rw-r--r-- | src/progs/ingenuity/RenameWindow.cpp | 3 | ||||
-rw-r--r-- | src/progs/ingenuity/main.cpp | 7 | ||||
-rw-r--r-- | src/progs/patch_loader/patch_loader.cpp | 22 |
12 files changed, 151 insertions, 100 deletions
diff --git a/src/progs/demolition/DemolitionClientInterface.h b/src/progs/demolition/DemolitionClientInterface.h index 1cd85ec2..303de621 100644 --- a/src/progs/demolition/DemolitionClientInterface.h +++ b/src/progs/demolition/DemolitionClientInterface.h @@ -45,6 +45,8 @@ public: void num_plugins(uint32_t num) {} + void response(int32_t id, bool success, const string& msg) {} + // OSC thread functions void error(const string& msg); diff --git a/src/progs/ingenuity/App.cpp b/src/progs/ingenuity/App.cpp index 26bf50cd..1a7d7760 100644 --- a/src/progs/ingenuity/App.cpp +++ b/src/progs/ingenuity/App.cpp @@ -61,24 +61,26 @@ class OmPort; App* App::_instance = 0; -App::App() -: m_configuration(new Configuration()), - m_about_dialog(NULL), - m_enable_signal(true) +App::App(CountedPtr<SigClientInterface> listener) +: _listener(listener), + _store(new Store(listener)), + _configuration(new Configuration()), + _about_dialog(NULL), + _enable_signal(true) { Glib::RefPtr<Gnome::Glade::Xml> glade_xml = GladeFactory::new_glade_reference(); - glade_xml->get_widget_derived("connect_win", m_connect_window); - //glade_xml->get_widget_derived("new_patch_win", m_new_patch_window); - //glade_xml->get_widget_derived("load_patch_win", m_load_patch_window); - glade_xml->get_widget_derived("config_win", m_config_window); - glade_xml->get_widget_derived("patch_tree_win", m_patch_tree_window); -// glade_xml->get_widget_derived("main_patches_treeview", m_objects_treeview); - glade_xml->get_widget("about_win", m_about_dialog); + glade_xml->get_widget_derived("connect_win", _connect_window); + //glade_xml->get_widget_derived("new_patch_win", _new_patch_window); + //glade_xml->get_widget_derived("load_patch_win", _load_patch_window); + glade_xml->get_widget_derived("config_win", _config_window); + glade_xml->get_widget_derived("patch_tree_win", _patch_tree_window); +// glade_xml->get_widget_derived("main_patches_treeview", _objects_treeview); + glade_xml->get_widget("about_win", _about_dialog); - m_config_window->configuration(m_configuration); + _config_window->configuration(_configuration); - glade_xml->get_widget_derived("messages_win", m_messages_window); + glade_xml->get_widget_derived("messages_win", _messages_window); } @@ -86,13 +88,19 @@ App::~App() { } +void +App::instantiate(CountedPtr<SigClientInterface>& listener) +{ + if (!_instance) + _instance = new App(listener); +} void App::error_message(const string& str) { - m_messages_window->post(str); - m_messages_window->show(); - m_messages_window->raise(); + _messages_window->post(str); + _messages_window->show(); + _messages_window->raise(); } @@ -100,7 +108,7 @@ App::error_message(const string& str) bool App::idle_callback() { - m_client_hooks->process_events(); + _client_hooks->process_events(); #ifdef HAVE_LASH //if (lash_controller->enabled()) @@ -119,7 +127,7 @@ App::idle_callback() App::event_load_session() { Gtk::FileChooserDialog* dialog - = new Gtk::FileChooserDialog(*m_main_window, "Load Session", Gtk::FILE_CHOOSER_ACTION_OPEN); + = new Gtk::FileChooserDialog(*_main_window, "Load Session", Gtk::FILE_CHOOSER_ACTION_OPEN); dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); @@ -140,7 +148,7 @@ App::event_load_session() void App::event_save_session_as() { - Gtk::FileChooserDialog dialog(*m_main_window, "Save Session", Gtk::FILE_CHOOSER_ACTION_SAVE); + Gtk::FileChooserDialog dialog(*_main_window, "Save Session", Gtk::FILE_CHOOSER_ACTION_SAVE); /* Gtk::VBox* box = dialog.get_vbox(); @@ -170,9 +178,9 @@ App::event_save_session_as() if (fin.is_open()) { // File exists string msg = "File already exists! Are you sure you want to overwrite "; msg += filename + "?"; - Gtk::MessageDialog confirm_dialog(*m_main_window, + Gtk::MessageDialog confir_dialog(*m_main_window, msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true); - if (confirm_dialog.run() == Gtk::RESPONSE_YES) + if (confir_dialog.run() == Gtk::RESPONSE_YES) confirm = true; else confirm = false; @@ -191,14 +199,14 @@ App::event_save_session_as() void App::add_patch_window(PatchWindow* pw) { - m_windows.push_back(pw); + _windows.push_back(pw); } void App::remove_patch_window(PatchWindow* pw) { - m_windows.erase(find(m_windows.begin(), m_windows.end(), pw)); + _windows.erase(find(_windows.begin(), _windows.end(), pw)); } @@ -208,7 +216,7 @@ int App::num_open_patch_windows() { int ret = 0; - for (list<PatchWindow*>::iterator i = m_windows.begin(); i != m_windows.end(); ++i) + for (list<PatchWindow*>::iterator i = _windows.begin(); i != _windows.end(); ++i) if ((*i)->is_visible()) ++ret; @@ -221,15 +229,15 @@ App::disconnect() { // FIXME: this is pretty gross.. figure out the death situation better - list<PatchWindow*> windows = m_windows; // make a copy + list<PatchWindow*> windows = _windows; // make a copy for (list<PatchWindow*>::iterator i = windows.begin(); i != windows.end(); ++i) delete (*i); - Store::instance().clear(); + _store->clear(); // PatchWindow destructor removes them from the list - assert(m_windows.size() == 0); + assert(_windows.size() == 0); } diff --git a/src/progs/ingenuity/App.h b/src/progs/ingenuity/App.h index 1e64abe8..2d56e445 100644 --- a/src/progs/ingenuity/App.h +++ b/src/progs/ingenuity/App.h @@ -25,10 +25,16 @@ #include <libgnomecanvasmm.h> #include <gtkmm.h> #include <libglademm.h> +#include <util/CountedPtr.h> using std::string; using std::map; using std::list; using std::cerr; using std::endl; -namespace Ingen { namespace Client { class PatchModel; class PluginModel; } } +namespace Ingen { namespace Client { + class PatchModel; + class PluginModel; + class Store; + class SigClientInterface; +} } using namespace Ingen::Client; /** \defgroup Ingenuity GTK Client @@ -77,40 +83,47 @@ public: int num_open_patch_windows(); - ConnectWindow* connect_window() const { return m_connect_window; } - Gtk::Dialog* about_dialog() const { return m_about_dialog; } - ConfigWindow* configuration_dialog() const { return m_config_window; } - MessagesWindow* messages_dialog() const { return m_messages_window; } - PatchTreeWindow* patch_tree() const { return m_patch_tree_window; } - Configuration* configuration() const { return m_configuration; } + ConnectWindow* connect_window() const { return _connect_window; } + Gtk::Dialog* about_dialog() const { return _about_dialog; } + ConfigWindow* configuration_dialog() const { return _config_window; } + MessagesWindow* messages_dialog() const { return _messages_window; } + PatchTreeWindow* patch_tree() const { return _patch_tree_window; } + Configuration* configuration() const { return _configuration; } + Store* store() const { return _store; } + + const CountedPtr<SigClientInterface>& client() const { return _listener; } + + static void instantiate(CountedPtr<SigClientInterface>& listener); - static void instantiate() { if (!_instance) _instance = new App(); } - static inline App& instance() { assert(_instance); return *_instance; } + static inline App& instance() { assert(_instance); return *_instance; } protected: - App(); + App(CountedPtr<SigClientInterface> listener); static App* _instance; //bool connect_callback(); //bool idle_callback(); - Configuration* m_configuration; + CountedPtr<SigClientInterface> _listener; + Store* _store; + + Configuration* _configuration; - list<PatchWindow*> m_windows; + list<PatchWindow*> _windows; - ConnectWindow* m_connect_window; - MessagesWindow* m_messages_window; - PatchTreeWindow* m_patch_tree_window; - ConfigWindow* m_config_window; - Gtk::Dialog* m_about_dialog; - Gtk::Button* m_engine_error_close_button; + ConnectWindow* _connect_window; + MessagesWindow* _messages_window; + PatchTreeWindow* _patch_tree_window; + ConfigWindow* _config_window; + Gtk::Dialog* _about_dialog; + Gtk::Button* _engine_error_close_button; /** Used to avoid feedback loops with (eg) process checkbutton * FIXME: Maybe this should be globally implemented at the Controller level, * disable all command sending while handling events to avoid feedback * issues with widget event callbacks? This same pattern is duplicated * too much... */ - bool m_enable_signal; + bool _enable_signal; }; diff --git a/src/progs/ingenuity/ConnectWindow.cpp b/src/progs/ingenuity/ConnectWindow.cpp index f608c79c..d4027e20 100644 --- a/src/progs/ingenuity/ConnectWindow.cpp +++ b/src/progs/ingenuity/ConnectWindow.cpp @@ -18,14 +18,15 @@ #include <string> #include <time.h> #include <sys/time.h> +#include <stdlib.h> #include "interface/ClientKey.h" -#include "interface/ClientInterface.h" #include "ThreadedSigClientInterface.h" #include "Controller.h" #include "Store.h" #include "PatchController.h" #include "PatchModel.h" #include "App.h" +using Ingen::Client::ThreadedSigClientInterface; namespace Ingenuity { @@ -33,6 +34,8 @@ namespace Ingenuity { ConnectWindow::ConnectWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml) : Gtk::Dialog(cobject) , _client(NULL) +, _ping_id(-1) +, _attached(false) { xml->get_widget("connect_icon", _icon); xml->get_widget("connect_progress_bar", _progress_bar); @@ -56,13 +59,15 @@ ConnectWindow::ConnectWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome:: void -ConnectWindow::start(CountedPtr<Ingen::Shared::ClientInterface> client) +ConnectWindow::start() { - _client = client; + _client = App::instance().client(); + assert(_client); resize(100, 100); show(); } + void ConnectWindow::init() { @@ -79,6 +84,7 @@ ConnectWindow::init() _progress_label->set_text(string("Disconnected")); } + void ConnectWindow::connect() { @@ -111,6 +117,8 @@ ConnectWindow::connect() void ConnectWindow::disconnect() { + _attached = false; + _progress_bar->set_fraction(0.0); _connect_button->set_sensitive(false); _disconnect_button->set_sensitive(false); @@ -124,7 +132,7 @@ ConnectWindow::disconnect() void ConnectWindow::quit() { - if (Controller::instance().is_attached()) { + if (_attached) { Gtk::MessageDialog d(*this, "This will exit Ingenuity, 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); @@ -180,22 +188,34 @@ ConnectWindow::gtk_callback() /* Connecting to engine */ if (stage == 0) { + assert(!_attached); + assert(_client); + // FIXME //assert(!Controller::instance().is_attached()); _progress_label->set_text(string("Connecting to engine at ").append( Controller::instance().engine_url()).append("...")); present(); - Controller::instance().attach(); + + _client->response_sig.connect(sigc::mem_fun(this, &ConnectWindow::response_received)); + + _ping_id = rand(); + while (_ping_id == -1) + _ping_id = rand(); + + Controller::instance().attach(_ping_id); ++stage; + + } else if (stage == 1) { - if (Controller::instance().is_attached()) { + if (_attached) { Controller::instance().activate(); ++stage; } else { const float ms_since_last = (now.tv_sec - last.tv_sec) * 1000.0f + (now.tv_usec - last.tv_usec) * 0.001f; if (ms_since_last > 1000) { - Controller::instance().attach(); + Controller::instance().attach(_ping_id); last = now; } } @@ -222,19 +242,19 @@ ConnectWindow::gtk_callback() ++stage; } else if (stage == 4) { // Wait for first plugins message - if (Store::instance().plugins().size() > 0) { + if (App::instance().store()->plugins().size() > 0) { _progress_label->set_text(string("Receiving plugins...")); ++stage; } } else if (stage == 5) { // FIXME - /*if (Store::instance().plugins().size() < _client->num_plugins()) { + /*if (App::instance().store().plugins().size() < _client->num_plugins()) { static char buf[32]; - snprintf(buf, 32, "%zu/%zu", Store::instance().plugins().size(), + snprintf(buf, 32, "%zu/%zu", App::instance().store().plugins().size(), ThreadedSigClientInterface::instance()->num_plugins()); _progress_bar->set_text(Glib::ustring(buf)); _progress_bar->set_fraction( - Store::instance().plugins().size() / (double)_client->num_plugins()); + App::instance().store().plugins().size() / (double)_client->num_plugins()); } else {*/ _progress_bar->set_text(""); ++stage; @@ -244,8 +264,8 @@ ConnectWindow::gtk_callback() Controller::instance().request_all_objects(); ++stage; } else if (stage == 7) { - if (Store::instance().num_objects() > 0) { - CountedPtr<PatchModel> root = Store::instance().object("/"); + if (App::instance().store()->num_objects() > 0) { + CountedPtr<PatchModel> root = App::instance().store()->object("/"); assert(root); PatchController* root_controller = new PatchController(root); root_controller->show_patch_window(); diff --git a/src/progs/ingenuity/ConnectWindow.h b/src/progs/ingenuity/ConnectWindow.h index b553c3da..fba6b9d8 100644 --- a/src/progs/ingenuity/ConnectWindow.h +++ b/src/progs/ingenuity/ConnectWindow.h @@ -21,7 +21,8 @@ #include <libglademm/xml.h> #include <libglademm.h> #include "util/CountedPtr.h" -#include "interface/ClientInterface.h" +#include "ThreadedSigClientInterface.h" +using Ingen::Client::SigClientInterface; namespace Ingenuity { @@ -41,7 +42,9 @@ class ConnectWindow : public Gtk::Dialog public: ConnectWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml); - void start(CountedPtr<Ingen::Shared::ClientInterface> client); + void start(); + void response_received(int32_t id, bool, string) { if ((id) == _ping_id) _attached = true; } + private: void server_toggled(); void launch_toggled(); @@ -54,18 +57,22 @@ private: bool gtk_callback(); - CountedPtr<Ingen::Shared::ClientInterface> _client; - Gtk::Image* _icon; - Gtk::ProgressBar* _progress_bar; - Gtk::Label* _progress_label; - Gtk::Entry* _url_entry; - Gtk::RadioButton* _server_radio; - Gtk::SpinButton* _port_spinbutton; - Gtk::RadioButton* _launch_radio; - Gtk::RadioButton* _internal_radio; - Gtk::Button* _disconnect_button; - Gtk::Button* _connect_button; - Gtk::Button* _quit_button; + CountedPtr<SigClientInterface> _client; + + int32_t _ping_id; + bool _attached; + + Gtk::Image* _icon; + Gtk::ProgressBar* _progress_bar; + Gtk::Label* _progress_label; + Gtk::Entry* _url_entry; + Gtk::RadioButton* _server_radio; + Gtk::SpinButton* _port_spinbutton; + Gtk::RadioButton* _launch_radio; + Gtk::RadioButton* _internal_radio; + Gtk::Button* _disconnect_button; + Gtk::Button* _connect_button; + Gtk::Button* _quit_button; }; diff --git a/src/progs/ingenuity/Controller.cpp b/src/progs/ingenuity/Controller.cpp index bb7e4c9b..a007ece8 100644 --- a/src/progs/ingenuity/Controller.cpp +++ b/src/progs/ingenuity/Controller.cpp @@ -40,10 +40,11 @@ Controller::Controller(const string& engine_url) Controller::~Controller() { - if (is_attached()) { + // FIXME + //if (is_attached()) { unregister_client(ClientKey()); // FIXME - detach(); - } + //detach(); + //} delete m_loader; delete m_patch_librarian; @@ -54,9 +55,9 @@ Controller::~Controller() * See documentation OSCModelEngineInterface::attach. */ void -Controller::attach() +Controller::attach(int32_t ping_id) { - OSCModelEngineInterface::attach(false); + OSCModelEngineInterface::attach(ping_id, false); } /* diff --git a/src/progs/ingenuity/Controller.h b/src/progs/ingenuity/Controller.h index a2c1ce0d..6a855758 100644 --- a/src/progs/ingenuity/Controller.h +++ b/src/progs/ingenuity/Controller.h @@ -54,7 +54,7 @@ class Controller : public OSCModelEngineInterface public: ~Controller(); - void attach(); + void attach(int32_t ping_id); //void register_client_and_wait(); diff --git a/src/progs/ingenuity/LoadPluginWindow.cpp b/src/progs/ingenuity/LoadPluginWindow.cpp index 9d18cec4..99fd4704 100644 --- a/src/progs/ingenuity/LoadPluginWindow.cpp +++ b/src/progs/ingenuity/LoadPluginWindow.cpp @@ -134,7 +134,7 @@ void LoadPluginWindow::on_show() { if (!m_has_shown) { - set_plugin_list(Store::instance().plugins()); + set_plugin_list(App::instance().store()->plugins()); // Center on patch window int m_w, m_h; @@ -341,8 +341,8 @@ LoadPluginWindow::filter_changed() size_t num_visible = 0; - for (std::map<string, CountedPtr<PluginModel> >::const_iterator i = Store::instance().plugins().begin(); - i != Store::instance().plugins().end(); ++i) { + for (std::map<string, CountedPtr<PluginModel> >::const_iterator i = App::instance().store()->plugins().begin(); + i != App::instance().store()->plugins().end(); ++i) { const CountedPtr<PluginModel> plugin = (*i).second; @@ -390,7 +390,7 @@ void LoadPluginWindow::clear_clicked() { m_search_entry->set_text(""); - set_plugin_list(Store::instance().plugins()); + set_plugin_list(App::instance().store()->plugins()); } bool diff --git a/src/progs/ingenuity/PatchWindow.cpp b/src/progs/ingenuity/PatchWindow.cpp index ba1ed9e7..69e8f7de 100644 --- a/src/progs/ingenuity/PatchWindow.cpp +++ b/src/progs/ingenuity/PatchWindow.cpp @@ -287,7 +287,7 @@ PatchWindow::breadcrumb_clicked(BreadCrumb* crumb) // FIXME: check to be sure PatchModel exists, then controller - maybe // even make a controller if there isn't one? PatchController* const pc = dynamic_cast<PatchController*>( - Store::instance().object(crumb->path())->controller()); + App::instance().store()->object(crumb->path())->controller()); assert(pc != NULL); if (pc == m_patch) { diff --git a/src/progs/ingenuity/RenameWindow.cpp b/src/progs/ingenuity/RenameWindow.cpp index 5521f951..52f5bc98 100644 --- a/src/progs/ingenuity/RenameWindow.cpp +++ b/src/progs/ingenuity/RenameWindow.cpp @@ -21,6 +21,7 @@ #include "ObjectModel.h" #include "GtkObjectController.h" #include "Store.h" +#include "App.h" using std::string; namespace Ingenuity { @@ -69,7 +70,7 @@ RenameWindow::name_changed() m_message_label->set_text("Name may not contain '/'"); m_ok_button->property_sensitive() = false; //} else if (m_object->parent()->patch_model()->get_node(name) != NULL) { - } else if (Store::instance().object(m_object->model()->parent()->base_path() + name)) { + } else if (App::instance().store()->object(m_object->model()->parent()->base_path() + name)) { m_message_label->set_text("An object already exists with that name."); m_ok_button->property_sensitive() = false; } else if (name.length() == 0) { diff --git a/src/progs/ingenuity/main.cpp b/src/progs/ingenuity/main.cpp index 0c504a11..034a1c85 100644 --- a/src/progs/ingenuity/main.cpp +++ b/src/progs/ingenuity/main.cpp @@ -68,11 +68,10 @@ main(int argc, char** argv) Gnome::Canvas::init(); Gtk::Main gtk_main(argc, argv); - OSCSigEmitter* emitter = new OSCSigEmitter(1024, 16181); + CountedPtr<SigClientInterface> emitter(new OSCSigEmitter(1024, 16181)); /* Instantiate all singletons */ - App::instantiate(); - Store::instantiate(*(SigClientInterface*)emitter); + App::instantiate(emitter); Controller::instantiate(engine_url); @@ -90,7 +89,7 @@ main(int argc, char** argv) LashController* lash_controller = new LashController(lash_args); #endif - App::instance().connect_window()->start(CountedPtr<ClientInterface>(emitter)); + App::instance().connect_window()->start(); gtk_main.run(); return 0; diff --git a/src/progs/patch_loader/patch_loader.cpp b/src/progs/patch_loader/patch_loader.cpp index 1161e92e..105a379c 100644 --- a/src/progs/patch_loader/patch_loader.cpp +++ b/src/progs/patch_loader/patch_loader.cpp @@ -52,21 +52,21 @@ int main(int argc, char** argv) /* **** Mr. Spock.. Engage **** */ - OSCModelEngineInterface osc_controller(engine_url); - PatchLibrarian librarian(&osc_controller); + OSCModelEngineInterface engine(engine_url); + PatchLibrarian librarian(&engine); /* Connect to engine */ - osc_controller.attach(client_port); - osc_controller.activate(); - //osc_controller.register_client(NULL); // FIXME + engine.attach(-1, client_port); + engine.activate(); + //engine.register_client(NULL); // FIXME - //int id = osc_controller.get_next_request_id(); - //osc_controller.set_wait_response_id(id); - //osc_controller.load_plugins(id); - //osc_controller.wait_for_response(); + //int id = engine.get_next_request_id(); + //engine.set_wait_response_id(id); + //engine.load_plugins(id); + //engine.wait_for_response(); /* FIXME: Make this work like this: - * osc_controller.load_plugins(); - * osc_controller.wait_for_response(); + * engine.load_plugins(); + * engine.wait_for_response(); */ // Load patches |