Plugin Order: remove from instant.xml and save to: plugin_metadata/plugin_order
authorBen Loftis <ben@harrisonconsoles.com>
Tue, 8 May 2018 18:00:27 +0000 (13:00 -0500)
committerBen Loftis <ben@harrisonconsoles.com>
Tue, 8 May 2018 18:26:08 +0000 (13:26 -0500)
libs/ardour/ardour/plugin_manager.h
libs/ardour/plugin_manager.cc

index a66e2d0674e38863152daa5968bc438290140d4b..7b90b045c319c8e1343717e2fc727c1f88358a40 100644 (file)
@@ -85,6 +85,9 @@ public:
        void load_tags ();
        void save_tags ();
 
+       bool load_plugin_order_file (XMLNode &n) const;  //returns TRUE if the passed-in node has valid info
+       void save_plugin_order_file (XMLNode &elem) const;
+
        enum TagType {
                FromPlug,           //tag info is being set from plugin metadata
                FromFactoryFile,    // ... from the factory metadata file
index 233f986a7bbc0fb79bdf6b17bda67aa4bbe1259a..d5d98cb54f1a4f618fa6568aaf81aa425de5da69 100644 (file)
@@ -1537,6 +1537,43 @@ PluginManager::user_plugin_metadata_dir () const
        return dir;
 }
 
+bool
+PluginManager::load_plugin_order_file (XMLNode &n) const
+{
+       std::string path = Glib::build_filename (user_plugin_metadata_dir(), "plugin_order");
+
+       info << string_compose (_("Loading plugin order file %1"), path) << endmsg;
+       if (!Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
+               return false;
+       }
+
+       XMLTree tree;
+       if (tree.read (path)) {
+               n = *(tree.root());
+               return true;
+       } else {
+               error << string_compose (_("Cannot parse Plugin Order info from %1"), path) << endmsg;
+               return false;
+       }
+}
+
+
+void
+PluginManager::save_plugin_order_file (XMLNode &elem) const
+{
+       std::string path = Glib::build_filename (user_plugin_metadata_dir(), "plugin_order");
+
+       info << string_compose (_("Saving plugin order file %1"), path) << endmsg;
+
+       XMLTree tree;
+       tree.set_root (&elem);
+       if (!tree.write (path)) {
+               error << string_compose (_("Could not save Plugin Order info to %1"), path) << endmsg;
+       }
+       tree.set_root (0);  //note: must disconnect the elem from XMLTree, or it will try to delete memory it didn't allocate
+}
+
+
 void
 PluginManager::save_tags ()
 {