From 77f6e9e63ce9ad329b43c92e8a9556aff8e78f2f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 6 Oct 2016 15:51:11 -0400 Subject: Add plugin state saving This only works with a server-side save, so the GUI now uses that if the server is not running remotely, where "remotely" is defined as "via TCP". This isn't perfect, since running ingen via TCP locally is a perfectly valid thing to do, but it will do for now. --- src/gui/GraphBox.cpp | 31 +++++++++++++++++++++---------- src/gui/GraphBox.hpp | 2 ++ 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 692e378a..6423c016 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -493,11 +493,7 @@ GraphBox::event_save() if (!document.is_valid() || document.type() != _app->uris().forge.URI) { event_save_as(); } else { - _app->loader()->save_graph(_graph, document.ptr()); - _status_bar->push( - (boost::format("Saved %1% to %2%") % _graph->path().c_str() - % document.ptr()).str(), - STATUS_CONTEXT_GRAPH); + save_graph(Raul::URI(document.ptr())); } } @@ -527,6 +523,24 @@ GraphBox::confirm(const Glib::ustring& message, return dialog.run() == Gtk::RESPONSE_YES; } +void +GraphBox::save_graph(const Raul::URI& uri) +{ + if (_app->interface()->uri().substr(0, 3) == "tcp") { + _status_bar->push( + (boost::format("Saved %1% to %2% on client") + % _graph->path() % uri).str(), + STATUS_CONTEXT_GRAPH); + _app->loader()->save_graph(_graph, uri); + } else { + _status_bar->push( + (boost::format("Saved %1% to %2% on server") + % _graph->path() % uri).str(), + STATUS_CONTEXT_GRAPH); + _app->interface()->copy(_graph->uri(), uri); + } +} + void GraphBox::event_save_as() { @@ -613,14 +627,11 @@ GraphBox::event_save_as() if (confirmed) { const Glib::ustring uri = Glib::filename_to_uri(filename); - _app->loader()->save_graph(_graph, uri); + save_graph(Raul::URI(uri)); + const_cast(_graph.get())->set_property( uris.ingen_file, _app->forge().alloc_uri(uri.c_str())); - _status_bar->push( - (boost::format("Saved %1% to %2%") % _graph->path().c_str() - % filename).str(), - STATUS_CONTEXT_GRAPH); } _app->world()->conf().set( diff --git a/src/gui/GraphBox.hpp b/src/gui/GraphBox.hpp index 3ffd1f91..20e0a764 100644 --- a/src/gui/GraphBox.hpp +++ b/src/gui/GraphBox.hpp @@ -106,6 +106,8 @@ private: bool confirm(const Glib::ustring& message, const Glib::ustring& secondary_text=""); + void save_graph(const Raul::URI& uri); + void event_import(); void event_save(); void event_save_as(); -- cgit v1.2.1