From 2122a857662203936a04a39df7d0e1ad1db82853 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 6 Jan 2007 04:16:26 +0000 Subject: Work on Port destruction (still broken). git-svn-id: http://svn.drobilla.net/lad/ingen@233 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/ingenuity/PatchPortModule.cpp | 2 +- src/progs/ingenuity/Port.cpp | 18 +++++++++++++++--- src/progs/ingenuity/Port.h | 9 ++++++--- src/progs/ingenuity/ThreadedLoader.cpp | 9 +-------- 4 files changed, 23 insertions(+), 15 deletions(-) (limited to 'src/progs') diff --git a/src/progs/ingenuity/PatchPortModule.cpp b/src/progs/ingenuity/PatchPortModule.cpp index e1fb37a8..e4c00130 100644 --- a/src/progs/ingenuity/PatchPortModule.cpp +++ b/src/progs/ingenuity/PatchPortModule.cpp @@ -68,7 +68,7 @@ PatchPortModule::create(boost::shared_ptr canvas, SharedPtrm_patch_port = boost::shared_ptr(new Port(ret, port, true)); + ret->m_patch_port = boost::shared_ptr(new Port(ret, port, true, true)); ret->add_port(ret->m_patch_port); ret->resize(); diff --git a/src/progs/ingenuity/Port.cpp b/src/progs/ingenuity/Port.cpp index 5d12cffa..e8e795d0 100644 --- a/src/progs/ingenuity/Port.cpp +++ b/src/progs/ingenuity/Port.cpp @@ -21,6 +21,7 @@ #include "PortModel.h" #include "ControlModel.h" #include "Configuration.h" +#include "ModelEngineInterface.h" #include "App.h" using std::cerr; using std::endl; @@ -31,15 +32,26 @@ namespace Ingenuity { /** @param flip Make an input port appear as an output port, and vice versa. */ -Port::Port(boost::shared_ptr module, SharedPtr pm, bool flip) +Port::Port(boost::shared_ptr module, SharedPtr pm, bool flip, bool destroyable) : LibFlowCanvas::Port(module, pm->path().name(), flip ? (!pm->is_input()) : pm->is_input(), App::instance().configuration()->get_port_color(pm.get())), - m_port_model(pm) + _port_model(pm) { assert(module); - assert(m_port_model); + assert(_port_model); + + if (destroyable) + m_menu.items().push_back(Gtk::Menu_Helpers::MenuElem("Destroy", + sigc::mem_fun(this, &Port::on_menu_destroy))); +} + + +void +Port::on_menu_destroy() +{ + App::instance().engine()->destroy(_port_model->path()); } diff --git a/src/progs/ingenuity/Port.h b/src/progs/ingenuity/Port.h index a23cd2c9..0498b5a8 100644 --- a/src/progs/ingenuity/Port.h +++ b/src/progs/ingenuity/Port.h @@ -35,14 +35,17 @@ namespace Ingenuity { class Port : public LibFlowCanvas::Port { public: - Port(boost::shared_ptr module, SharedPtr pm, bool flip = false); + Port(boost::shared_ptr module, SharedPtr pm, bool flip = false, bool destroyable = false); virtual ~Port() {} - SharedPtr model() const { return m_port_model; } + SharedPtr model() const { return _port_model; } private: - SharedPtr m_port_model; + + void on_menu_destroy(); + + SharedPtr _port_model; }; diff --git a/src/progs/ingenuity/ThreadedLoader.cpp b/src/progs/ingenuity/ThreadedLoader.cpp index 79cd8507..83b3d6b5 100644 --- a/src/progs/ingenuity/ThreadedLoader.cpp +++ b/src/progs/ingenuity/ThreadedLoader.cpp @@ -55,7 +55,7 @@ ThreadedLoader::_whipped() _mutex.unlock(); } -/** FIXME: most of these paramteres do nothing */ +/** FIXME: use poly parameter */ void ThreadedLoader::load_patch(bool merge, const string& data_base_uri, @@ -67,13 +67,6 @@ ThreadedLoader::load_patch(bool merge, { _mutex.lock(); - /*_events.push_back(sigc::hide_return(sigc::bind( - sigc::mem_fun(_loader, &Loader::load_patch), - merge, data_base_uri, data_path, - engine_data, engine_parent, engine_name, engine_poly)));*/ - - cerr << "FIXME: load under root only\n"; - _events.push_back(sigc::hide_return(sigc::bind( sigc::mem_fun(_loader, &Loader::load), data_base_uri, -- cgit v1.2.1