From 74a3eb19f586e3548f59bb9ff9137703cdc45de8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 3 Dec 2011 21:45:57 +0000 Subject: Don't expose canvas data structures. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@3775 a436a847-0d15-0410-975c-d299462d15a1 --- src/Patchage.cpp | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'src/Patchage.cpp') diff --git a/src/Patchage.cpp b/src/Patchage.cpp index e815891..2c35255 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -412,15 +412,22 @@ Patchage::warning_msg(const std::string& msg) _status_text->scroll_to_mark(buffer->get_insert(), 0); } +static void +load_module_location(FlowCanvasNode* node, void* data) +{ + if (FLOW_CANVAS_IS_MODULE(node)) { + FlowCanvas::Module* cmodule = Glib::wrap(FLOW_CANVAS_MODULE(node)); + PatchageModule* pmodule = dynamic_cast(cmodule); + if (pmodule) { + pmodule->load_location(); + } + } +} + void Patchage::update_state() { - for (FlowCanvas::Canvas::Items::const_iterator i = _canvas->items().begin(); - i != _canvas->items().end(); ++i) { - PatchageModule* module = dynamic_cast(*i); - if (module) - module->load_location(); - } + _canvas->for_each_node(load_module_location, NULL); } /** Update the sensitivity status of menus to reflect the present. @@ -485,6 +492,23 @@ Patchage::show_open_session_dialog() } } +static void +print_edge(FlowCanvasEdge* edge, void* data) +{ + std::ofstream* script = (std::ofstream*)data; + FlowCanvas::Edge* edgemm = Glib::wrap(edge); + + PatchagePort* src = dynamic_cast((edgemm)->get_tail()); + PatchagePort* dst = dynamic_cast((edgemm)->get_head()); + + if (!src || !dst || src->type() == ALSA_MIDI || dst->type() == ALSA_MIDI) { + return; + } + + (*script) << "jack_connect '" << src->full_name() + << "' '" << dst->full_name() << "' &" << endl; +} + void Patchage::save_session(bool close) { @@ -531,18 +555,7 @@ Patchage::save_session(bool close) script << "sleep 3" << endl; script << endl; - for (FlowCanvas::Canvas::Edges::const_iterator c = _canvas->edges().begin(); - c != _canvas->edges().end(); ++c) { - PatchagePort* src = dynamic_cast((*c)->get_tail()); - PatchagePort* dst = dynamic_cast((*c)->get_head()); - - if (!src || !dst || src->type() == ALSA_MIDI || dst->type() == ALSA_MIDI) { - continue; - } - - script << "jack_connect '" << src->full_name() - << "' '" << dst->full_name() << "' &" << endl; - } + _canvas->for_each_edge(print_edge, &script); script.close(); g_chmod(script_path.c_str(), 0740); -- cgit v1.2.1