summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-12 03:31:57 +0000
committerDavid Robillard <d@drobilla.net>2012-05-12 03:31:57 +0000
commit8211b45bffe20e8a271396b7568609a84b7cf0ec (patch)
tree8f2b9557977c0b7a681cb8fc2209c554213c1e66 /src/gui
parent271b3f9d7f376cbbaef202ef6f898e5f9bb4c324 (diff)
downloadingen-8211b45bffe20e8a271396b7568609a84b7cf0ec.tar.gz
ingen-8211b45bffe20e8a271396b7568609a84b7cf0ec.tar.bz2
ingen-8211b45bffe20e8a271396b7568609a84b7cf0ec.zip
Get copy and paste working again.
Client side and text based is probably not the idea way to go about implementing this, but it more or less works and is certainly better than nothing for now. Copy paste of patch ports, and pasting into any path other than the root still isn't working currently. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4367 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/PatchCanvas.cpp69
1 files changed, 42 insertions, 27 deletions
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp
index 3562a007..640051cb 100644
--- a/src/gui/PatchCanvas.cpp
+++ b/src/gui/PatchCanvas.cpp
@@ -637,42 +637,56 @@ PatchCanvas::destroy_selection()
for_each_selected_edge(destroy_edge, &_app);
}
-void
-PatchCanvas::copy_selection()
+static void
+serialise_node(GanvNode* node, void* data)
{
- std::cerr << "FIXME: copy" << std::endl;
- #if 0
- static const char* base_uri = "";
- Serialiser serialiser(*_app.world(), _app.store());
- serialiser.start_to_string(_patch->path(), base_uri);
+ Serialisation::Serialiser* serialiser = (Serialisation::Serialiser*)data;
+ if (!GANV_IS_MODULE(node)) {
+ return;
+ }
- FOREACH_ITEM(m, selected_items()) {
- NodeModule* module = dynamic_cast<NodeModule*>(*m);
- if (module) {
- serialiser.serialise(module->node());
- } else {
- PatchPortModule* port_module = dynamic_cast<PatchPortModule*>(*m);
- if (port_module)
- serialiser.serialise(port_module->port());
+ Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
+ NodeModule* node_module = dynamic_cast<NodeModule*>(module);
+
+ if (node_module) {
+ serialiser->serialise(node_module->node());
+ } else {
+ PatchPortModule* port_module = dynamic_cast<PatchPortModule*>(module);
+ if (port_module) {
+ serialiser->serialise(port_module->port());
}
}
+}
- for (SelectedEdges::const_iterator c = selected_edges().begin();
- c != selected_edges().end(); ++c) {
- Edge* const edge = dynamic_cast<Edge*>(*c);
- if (edge) {
- const Sord::URI subject(*_app.world()->rdf_world(),
- base_uri);
- serialiser.serialise_edge(subject, edge->model());
- }
+static void
+serialise_edge(GanvEdge* edge, void* data)
+{
+ Serialisation::Serialiser* serialiser = (Serialisation::Serialiser*)data;
+ if (!GANV_IS_EDGE(edge)) {
+ return;
+ }
+
+ GUI::Edge* gedge = dynamic_cast<GUI::Edge*>(Glib::wrap(GANV_EDGE(edge)));
+ if (gedge) {
+ serialiser->serialise_edge(Sord::Node(), gedge->model());
}
+}
+
+void
+PatchCanvas::copy_selection()
+{
+ static const char* base_uri = "http://drobilla.net/ns/ingen/selection/";
+ Serialisation::Serialiser serialiser(*_app.world());
+ serialiser.start_to_string(_patch->path(), base_uri);
+
+ for_each_selected_node(serialise_node, &serialiser);
+ for_each_selected_edge(serialise_edge, &serialiser);
- string result = serialiser.finish();
+ const std::string result = serialiser.finish();
_paste_count = 0;
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
clipboard->set_text(result);
- #endif
}
void
@@ -702,7 +716,7 @@ PatchCanvas::paste()
uris.ingen_Patch));
props.insert(make_pair(uris.ingen_polyphony,
_app.forge().make(int32_t(_patch->internal_poly()))));
- clipboard.put(Path(), props);
+ clipboard.put(Path("/"), props);
size_t first_slash;
while (to_create != "/" && !to_create.empty()
&& (first_slash = to_create.find("/")) != string::npos) {
@@ -723,7 +737,8 @@ PatchCanvas::paste()
}
ClashAvoider avoider(*_app.store().get(), clipboard, &clipboard);
- parser->parse_string(_app.world(), &avoider, str, "",
+ static const char* base_uri = "http://drobilla.net/ns/ingen/selection/";
+ parser->parse_string(_app.world(), &avoider, str, base_uri,
parent, symbol);
for (Store::iterator i = clipboard.begin(); i != clipboard.end(); ++i) {