Method to generate an initial tag file:

rm config/plugin_tags
touch config/init_plugin_tags
This commit is contained in:
Ben Loftis 2018-02-21 18:04:45 -06:00
parent d4ae858bf6
commit afedd214a7
3 changed files with 28 additions and 16 deletions

View File

@ -862,7 +862,7 @@ PluginSelector::tag_entry_changed ()
TreeModel::Row row = *(plugin_display.get_selection()->get_selected()); TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin]; ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin];
manager.set_tags (pi->type, pi->unique_id, tag_entry->get_text(), false); manager.set_tags (pi->name, pi->type, pi->unique_id, tag_entry->get_text(), false);
_need_tag_save = true; _need_tag_save = true;
_need_menu_rebuild = true; _need_menu_rebuild = true;

View File

@ -85,7 +85,7 @@ public:
void load_tags (); void load_tags ();
void save_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&); void reset_tags (PluginInfoPtr const&);
std::string get_tags_as_string (PluginInfoPtr const&) const; std::string get_tags_as_string (PluginInfoPtr const&) const;
std::vector<std::string> get_tags (PluginInfoPtr const&) const; std::vector<std::string> get_tags (PluginInfoPtr const&) const;
@ -109,13 +109,14 @@ public:
private: private:
struct PluginTag { struct PluginTag {
std::string name;
ARDOUR::PluginType type; ARDOUR::PluginType type;
std::string unique_id; std::string unique_id;
std::string tags; std::string tags;
bool user_set; bool user_set;
PluginTag (ARDOUR::PluginType t, std::string id, std::string s, bool user_set) PluginTag (std::string n, ARDOUR::PluginType t, std::string id, std::string s, bool user_set)
: type (t), unique_id (id), tags (s), user_set (user_set) {} : name (n), type (t), unique_id (id), tags (s), user_set (user_set) {}
bool operator== (PluginTag const& other) const { bool operator== (PluginTag const& other) const {
return other.type == type && other.unique_id == unique_id; return other.type == type && other.unique_id == unique_id;

View File

@ -509,7 +509,7 @@ PluginManager::lua_refresh ()
for (LuaScriptList::const_iterator s = _scripts.begin(); s != _scripts.end(); ++s) { for (LuaScriptList::const_iterator s = _scripts.begin(); s != _scripts.end(); ++s) {
LuaPluginInfoPtr lpi (new LuaPluginInfo(*s)); LuaPluginInfoPtr lpi (new LuaPluginInfo(*s));
_lua_plugin_info->push_back (lpi); _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(); _lv2_plugin_info = LV2PluginInfo::discover();
for (PluginInfoList::iterator i = _lv2_plugin_info->begin(); i != _lv2_plugin_info->end(); ++i) { 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 #endif
@ -843,7 +843,7 @@ PluginManager::au_refresh (bool cache_only)
Config->save_state(); Config->save_state();
for (PluginInfoList::iterator i = _au_plugin_info->begin(); i != _au_plugin_info->end(); ++i) { 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; info->type = ARDOUR::Windows_VST;
/* if we don't have any tags for this plugin, make some up. */ /* 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) // TODO: check dup-IDs (lxvst AND windows vst)
bool duplicate = false; bool duplicate = false;
@ -1165,7 +1165,7 @@ PluginManager::mac_vst_discover (string path, bool cache_only)
info->type = ARDOUR::MacVST; info->type = ARDOUR::MacVST;
/* if we don't have any tags for this plugin, make some up. */ /* 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; bool duplicate = false;
if (!_mac_vst_plugin_info->empty()) { 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->n_outputs.set_midi ((finfo->wantMidi&2) ? 1 : 0);
info->type = ARDOUR::LXVST; 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 /* 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 * 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<std::string> tags; vector<std::string> 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); PluginTagList::const_iterator i = find (ptags.begin(), ptags.end(), ps);
if (i != ptags.end ()) { if (i != ptags.end ()) {
PBD::tokenize (i->tags, string(" "), std::back_inserter (tags), true); PBD::tokenize (i->tags, string(" "), std::back_inserter (tags), true);
@ -1539,11 +1539,18 @@ PluginManager::user_plugin_metadata_dir () const
void void
PluginManager::save_tags () 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"); std::string path = Glib::build_filename (user_plugin_metadata_dir(), "plugin_tags");
XMLNode* root = new XMLNode (X_("PluginTags")); XMLNode* root = new XMLNode (X_("PluginTags"));
for (PluginTagList::iterator i = ptags.begin(); i != ptags.end(); ++i) { for (PluginTagList::iterator i = ptags.begin(); i != ptags.end(); ++i) {
if (!(*i).user_set) { if (!(*i).user_set && !init) {
continue; continue;
} }
XMLNode* node = new XMLNode (X_("Plugin")); 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_("id"), (*i).unique_id);
node->set_property (X_("tags"), (*i).tags); node->set_property (X_("tags"), (*i).tags);
node->set_property (X_("user-set"), (*i).user_set); node->set_property (X_("user-set"), (*i).user_set);
if (init) {
node->set_property (X_("name"), (*i).name);
}
root->add_child_nocopy (*node); root->add_child_nocopy (*node);
} }
@ -1593,17 +1604,17 @@ PluginManager::load_tags ()
user_set = false; user_set = false;
} }
strip_whitespace_edges (tags); strip_whitespace_edges (tags);
set_tags (type, id, tags, !user_set); set_tags ("", type, id, tags, !user_set);
} }
} }
} }
void 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); 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); PluginTagList::const_iterator i = find (ptags.begin(), ptags.end(), ps);
if (i == ptags.end()) { if (i == ptags.end()) {
ptags.insert (ps); ptags.insert (ps);
@ -1619,7 +1630,7 @@ PluginManager::set_tags (PluginType t, string id, string tag, bool factory, bool
void void
PluginManager::reset_tags (PluginInfoPtr const& pi) 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 std::string