summaryrefslogtreecommitdiffstats
path: root/src/Patchage.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-03 21:45:57 +0000
committerDavid Robillard <d@drobilla.net>2011-12-03 21:45:57 +0000
commit74a3eb19f586e3548f59bb9ff9137703cdc45de8 (patch)
tree07d9070e88dd46e7b536b7b8aeed2e248ffc00b1 /src/Patchage.cpp
parent0654b5d4017b2dbd605ea9d7567f220ceeca44e1 (diff)
downloadpatchage-74a3eb19f586e3548f59bb9ff9137703cdc45de8.tar.gz
patchage-74a3eb19f586e3548f59bb9ff9137703cdc45de8.tar.bz2
patchage-74a3eb19f586e3548f59bb9ff9137703cdc45de8.zip
Don't expose canvas data structures.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@3775 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/Patchage.cpp')
-rw-r--r--src/Patchage.cpp49
1 files changed, 31 insertions, 18 deletions
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<PatchageModule*>(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<PatchageModule*>(*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<PatchagePort*>((edgemm)->get_tail());
+ PatchagePort* dst = dynamic_cast<PatchagePort*>((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<PatchagePort*>((*c)->get_tail());
- PatchagePort* dst = dynamic_cast<PatchagePort*>((*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);