Plugin Order: Use the new plugin_manager function to save plugin order.
authorBen Loftis <ben@harrisonconsoles.com>
Tue, 8 May 2018 18:25:54 +0000 (13:25 -0500)
committerBen Loftis <ben@harrisonconsoles.com>
Tue, 8 May 2018 18:26:08 +0000 (13:26 -0500)
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/mixer_ui.cc
gtk2_ardour/mixer_ui.h

index f818b1e1093ac63a1b654688e4605f4b596da3ee..4ee384f467c0883687e4eb037ad0822273169b14 100644 (file)
@@ -820,6 +820,8 @@ ARDOUR_UI::save_ardour_state ()
 
        Config->save_state();
 
+       mixer->save_plugin_order_file();
+
        UIConfiguration::instance().save_state ();
 
        if (_session) {
index 779dac2bceccd48bdc1db78c043d377bce0507ec..4f902e9831a9da95907fa9cdb3c92a869a562290 100644 (file)
@@ -2153,12 +2153,12 @@ Mixer_UI::set_state (const XMLNode& node, int version)
                show_monitor_section (yn);
        }
 
-
-       XMLNode* plugin_order;
-       if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
+       //check for the user's plugin_order file
+       XMLNode plugin_order_new(X_("PO"));
+       if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
                store_current_favorite_order ();
                std::list<string> order;
-               const XMLNodeList& kids = plugin_order->children("PluginInfo");
+               const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
                XMLNodeConstIterator i;
                for (i = kids.begin(); i != kids.end(); ++i) {
                        std::string unique_id;
@@ -2172,10 +2172,60 @@ Mixer_UI::set_state (const XMLNode& node, int version)
                PluginStateSorter cmp (order);
                favorite_order.sort (cmp);
                sync_treeview_from_favorite_order ();
+
+       } else {
+               //if there is no user file, then use an existing one from instant.xml
+               //NOTE: if you are loading an old session, this might come from the session's instant.xml
+               //Todo:  in the next major version, we should probably stop doing the instant.xml check, and just use the new file
+               XMLNode* plugin_order;
+               if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
+                       store_current_favorite_order ();
+                       std::list<string> order;
+                       const XMLNodeList& kids = plugin_order->children("PluginInfo");
+                       XMLNodeConstIterator i;
+                       for (i = kids.begin(); i != kids.end(); ++i) {
+                               std::string unique_id;
+                               if ((*i)->get_property ("unique-id", unique_id)) {
+                                       order.push_back (unique_id);
+                                       if ((*i)->get_property ("expanded", yn)) {
+                                               favorite_ui_state[unique_id] = yn;
+                                       }
+                               }
+                       }
+
+                       PluginStateSorter cmp (order);
+                       favorite_order.sort (cmp);
+                       sync_treeview_from_favorite_order ();
+               }
        }
+
        return 0;
 }
 
+void
+Mixer_UI::save_plugin_order_file ()
+{
+printf("save_plugin_order_file\n");
+       //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
+
+       //NOTE:  this replaces the old code that stores info in instant.xml
+       //why?  because instant.xml prefers the per-session settings, and we want this to be a global pref
+
+       store_current_favorite_order ();
+       XMLNode plugin_order ("PluginOrder");
+       uint32_t cnt = 0;
+       for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
+               XMLNode* p = new XMLNode ("PluginInfo");
+               p->set_property ("sort", cnt);
+               p->set_property ("unique-id", (*i)->unique_id);
+               if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
+                       p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
+               }
+               plugin_order.add_child_nocopy (*p);
+       }
+       PluginManager::instance().save_plugin_order_file( plugin_order );
+}
+
 XMLNode&
 Mixer_UI::get_state ()
 {
@@ -2198,20 +2248,6 @@ Mixer_UI::get_state ()
        assert (tact);
        node->set_property ("monitor-section-visible", tact->get_active ());
 
-       store_current_favorite_order ();
-       XMLNode* plugin_order = new XMLNode ("PluginOrder");
-       uint32_t cnt = 0;
-       for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
-               XMLNode* p = new XMLNode ("PluginInfo");
-               p->set_property ("sort", cnt);
-               p->set_property ("unique-id", (*i)->unique_id);
-               if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
-                       p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
-               }
-               plugin_order->add_child_nocopy (*p);
-       }
-       node->add_child_nocopy (*plugin_order);
-
        return *node;
 }
 
index 47f278e02e71ae3b866d625f67d733b7a82252de..cfe1f1b29462b8bc82cf7a606426c7c7bf4b7ca7 100644 (file)
@@ -99,6 +99,8 @@ public:
        XMLNode& get_state ();
        int set_state (const XMLNode&, int /* version */);
 
+       void save_plugin_order_file ();
+
        void show_mixer_list (bool yn);
        void show_monitor_section (bool);