From afedd214a709acd031e99432a62d1a0ee2f39497 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Wed, 21 Feb 2018 18:04:45 -0600 Subject: Method to generate an initial tag file: rm config/plugin_tags touch config/init_plugin_tags --- libs/ardour/ardour/plugin_manager.h | 7 ++++--- libs/ardour/plugin_manager.cc | 35 +++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 15 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h index f079e4b812..c450fb9594 100644 --- a/libs/ardour/ardour/plugin_manager.h +++ b/libs/ardour/ardour/plugin_manager.h @@ -85,7 +85,7 @@ public: void load_tags (); void save_tags (); - void set_tags (ARDOUR::PluginType type, std::string unique_id, std::string tags, bool factory, bool force = false); + void set_tags (std::string name, ARDOUR::PluginType type, std::string unique_id, std::string tags, bool factory, bool force = false); void reset_tags (PluginInfoPtr const&); std::string get_tags_as_string (PluginInfoPtr const&) const; std::vector get_tags (PluginInfoPtr const&) const; @@ -109,13 +109,14 @@ public: private: struct PluginTag { + std::string name; ARDOUR::PluginType type; std::string unique_id; std::string tags; bool user_set; - PluginTag (ARDOUR::PluginType t, std::string id, std::string s, bool user_set) - : type (t), unique_id (id), tags (s), user_set (user_set) {} + PluginTag (std::string n, ARDOUR::PluginType t, std::string id, std::string s, bool user_set) + : name (n), type (t), unique_id (id), tags (s), user_set (user_set) {} bool operator== (PluginTag const& other) const { return other.type == type && other.unique_id == unique_id; diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 80a45a50d7..57aa444fba 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -509,7 +509,7 @@ PluginManager::lua_refresh () for (LuaScriptList::const_iterator s = _scripts.begin(); s != _scripts.end(); ++s) { LuaPluginInfoPtr lpi (new LuaPluginInfo(*s)); _lua_plugin_info->push_back (lpi); - set_tags (lpi->type, lpi->unique_id, lpi->category, true); + set_tags (lpi->name, lpi->type, lpi->unique_id, lpi->category, true); } } @@ -819,7 +819,7 @@ PluginManager::lv2_refresh () _lv2_plugin_info = LV2PluginInfo::discover(); for (PluginInfoList::iterator i = _lv2_plugin_info->begin(); i != _lv2_plugin_info->end(); ++i) { - set_tags ((*i)->type, (*i)->unique_id, (*i)->category, true); + set_tags ((*i)->name, (*i)->type, (*i)->unique_id, (*i)->category, true); } } #endif @@ -843,7 +843,7 @@ PluginManager::au_refresh (bool cache_only) Config->save_state(); for (PluginInfoList::iterator i = _au_plugin_info->begin(); i != _au_plugin_info->end(); ++i) { - set_tags ((*i)->type, (*i)->unique_id, (*i)->category, true); + set_tags ((*i)->name, (*i)->type, (*i)->unique_id, (*i)->category, true); } } @@ -1025,7 +1025,7 @@ PluginManager::windows_vst_discover (string path, bool cache_only) info->type = ARDOUR::Windows_VST; /* if we don't have any tags for this plugin, make some up. */ - set_tags (info->type, info->unique_id, info->category, true); + set_tags ((*i)->name, info->type, info->unique_id, info->category, true); // TODO: check dup-IDs (lxvst AND windows vst) bool duplicate = false; @@ -1165,7 +1165,7 @@ PluginManager::mac_vst_discover (string path, bool cache_only) info->type = ARDOUR::MacVST; /* if we don't have any tags for this plugin, make some up. */ - set_tags (info->type, info->unique_id, info->category, true); + set_tags (info->name, info->type, info->unique_id, info->category, true); bool duplicate = false; if (!_mac_vst_plugin_info->empty()) { @@ -1286,7 +1286,7 @@ PluginManager::lxvst_discover (string path, bool cache_only) info->n_outputs.set_midi ((finfo->wantMidi&2) ? 1 : 0); info->type = ARDOUR::LXVST; - set_tags (info->type, info->unique_id, info->category, true); + set_tags ((*i)->name, info->type, info->unique_id, info->category, true); /* Make sure we don't find the same plugin in more than one place along * the LXVST_PATH We can't use a simple 'find' because the path is included @@ -1502,7 +1502,7 @@ PluginManager::get_tags (const PluginInfoPtr& pi) const { vector tags; - PluginTag ps (to_generic_vst(pi->type), pi->unique_id, "", false); + PluginTag ps (pi->name, to_generic_vst(pi->type), pi->unique_id, "", false); PluginTagList::const_iterator i = find (ptags.begin(), ptags.end(), ps); if (i != ptags.end ()) { PBD::tokenize (i->tags, string(" "), std::back_inserter (tags), true); @@ -1539,11 +1539,18 @@ PluginManager::user_plugin_metadata_dir () const void PluginManager::save_tags () { + //backdoor way to generate an initial plugin-tag file, with names appended + bool init = false; + std::string ipath = Glib::build_filename (user_plugin_metadata_dir(), "init_plugin_tags"); + if (Glib::file_test (ipath, Glib::FILE_TEST_EXISTS)) { + init = true; + } + std::string path = Glib::build_filename (user_plugin_metadata_dir(), "plugin_tags"); XMLNode* root = new XMLNode (X_("PluginTags")); for (PluginTagList::iterator i = ptags.begin(); i != ptags.end(); ++i) { - if (!(*i).user_set) { + if (!(*i).user_set && !init) { continue; } XMLNode* node = new XMLNode (X_("Plugin")); @@ -1551,6 +1558,10 @@ PluginManager::save_tags () node->set_property (X_("id"), (*i).unique_id); node->set_property (X_("tags"), (*i).tags); node->set_property (X_("user-set"), (*i).user_set); + if (init) { + node->set_property (X_("name"), (*i).name); + } + root->add_child_nocopy (*node); } @@ -1593,17 +1604,17 @@ PluginManager::load_tags () user_set = false; } strip_whitespace_edges (tags); - set_tags (type, id, tags, !user_set); + set_tags ("", type, id, tags, !user_set); } } } void -PluginManager::set_tags (PluginType t, string id, string tag, bool factory, bool force) +PluginManager::set_tags (string name, PluginType t, string id, string tag, bool factory, bool force) { string sanitized = sanitize_tag (tag); - PluginTag ps (to_generic_vst (t), id, sanitized, !factory); + PluginTag ps (name, to_generic_vst (t), id, sanitized, !factory); PluginTagList::const_iterator i = find (ptags.begin(), ptags.end(), ps); if (i == ptags.end()) { ptags.insert (ps); @@ -1619,7 +1630,7 @@ PluginManager::set_tags (PluginType t, string id, string tag, bool factory, bool void PluginManager::reset_tags (PluginInfoPtr const& pi) { - set_tags (pi->type, pi->unique_id, pi->category, true, true); + set_tags (pi->name, pi->type, pi->unique_id, pi->category, true, true); } std::string -- cgit v1.2.3