From f5bbbe321c04eff0171e3143358400bc2aae660a Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Tue, 8 May 2018 13:25:54 -0500 Subject: Plugin Order: Use the new plugin_manager function to save plugin order. --- gtk2_ardour/ardour_ui_ed.cc | 2 ++ gtk2_ardour/mixer_ui.cc | 72 +++++++++++++++++++++++++++++++++------------ gtk2_ardour/mixer_ui.h | 2 ++ 3 files changed, 58 insertions(+), 18 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index f818b1e109..4ee384f467 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -820,6 +820,8 @@ ARDOUR_UI::save_ardour_state () Config->save_state(); + mixer->save_plugin_order_file(); + UIConfiguration::instance().save_state (); if (_session) { diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 779dac2bce..4f902e9831 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -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 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 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; } diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index 47f278e02e..cfe1f1b294 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -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); -- cgit v1.2.3