diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-11-08 19:15:28 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-11-08 19:15:28 +0000 |
commit | b5f7ae45bda38031f354ea1643ebc1cc22018907 (patch) | |
tree | 58ef43d8048cb3c5dbb5305b4d056cd06249c891 /libs | |
parent | d7faaf7b028d7e0a56b8cefb90210f7e7505e6f0 (diff) |
plugin menu/manager patch from J. Abelardo Gutierrez
git-svn-id: svn://localhost/ardour2/branches/3.0@6038 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/plugin_manager.h | 42 | ||||
-rw-r--r-- | libs/ardour/plugin_manager.cc | 87 |
2 files changed, 86 insertions, 43 deletions
diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h index d564d62a87..779e26e915 100644 --- a/libs/ardour/ardour/plugin_manager.h +++ b/libs/ardour/ardour/plugin_manager.h @@ -58,30 +58,36 @@ class PluginManager : public boost::noncopyable { static PluginManager* the_manager() { return _manager; } - void load_favorites (); - void save_favorites (); - void add_favorite (ARDOUR::PluginType type, std::string unique_id); - void remove_favorite (ARDOUR::PluginType type, std::string unique_id); - bool is_a_favorite_plugin (const PluginInfoPtr&); + enum PluginStatusType { + Normal = 0, + Favorite, + Hidden + }; + + void load_statuses (); + void save_statuses (); + void set_status (ARDOUR::PluginType type, std::string unique_id, PluginStatusType status); + PluginStatusType get_status (const PluginInfoPtr&); private: - struct FavoritePlugin { - ARDOUR::PluginType type; - std::string unique_id; + struct PluginStatus { + ARDOUR::PluginType type; + std::string unique_id; + PluginStatusType status; - FavoritePlugin (ARDOUR::PluginType t, std::string id) - : type (t), unique_id (id) {} + PluginStatus (ARDOUR::PluginType t, std::string id, PluginStatusType s = Normal) + : type (t), unique_id (id), status (s) {} - bool operator==(const FavoritePlugin& other) const { - return other.type == type && other.unique_id == unique_id; - } + bool operator==(const PluginStatus& other) const { + return other.type == type && other.unique_id == unique_id; + } - bool operator<(const FavoritePlugin& other) const { - return other.type < type || other.unique_id < unique_id; - } + bool operator<(const PluginStatus& other) const { + return other.type < type || other.unique_id < unique_id; + } }; - typedef std::set<FavoritePlugin> FavoritePluginList; - FavoritePluginList favorites; + typedef std::set<PluginStatus> PluginStatusList; + PluginStatusList statuses; ARDOUR::PluginInfoList _empty_plugin_info; ARDOUR::PluginInfoList* _vst_plugin_info; diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 8315397fe8..22e649e03e 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -82,7 +82,7 @@ PluginManager::PluginManager () char* s; string lrdf_path; - load_favorites (); + load_statuses (); #ifdef HAVE_AUDIOUNITS ProcessSerialNumber psn = { 0, kCurrentProcess }; @@ -414,7 +414,7 @@ PluginManager::get_ladspa_category (uint32_t plugin_id) lrdf_statement* matches1 = lrdf_matches (&pattern); if (!matches1) { - return ""; + return "Unknown"; } pattern.subject = matches1->object; @@ -426,7 +426,7 @@ PluginManager::get_ladspa_category (uint32_t plugin_id) lrdf_free_statements(matches1); if (!matches2) { - return (""); + return ("Unknown"); } string label = matches2->object; @@ -557,19 +557,24 @@ PluginManager::vst_discover (string path) #endif // VST_SUPPORT -bool -PluginManager::is_a_favorite_plugin (const PluginInfoPtr& pi) +PluginManager::PluginStatusType +PluginManager::get_status (const PluginInfoPtr& pi) { - FavoritePlugin fp (pi->type, pi->unique_id); - return find (favorites.begin(), favorites.end(), fp) != favorites.end(); + PluginStatus ps (pi->type, pi->unique_id); + PluginStatusList::const_iterator i = find (statuses.begin(), statuses.end(), ps); + if (i == statuses.end() ) { + return Normal; + } else { + return i->status; + } } void -PluginManager::save_favorites () +PluginManager::save_statuses () { ofstream ofs; sys::path path = user_config_directory(); - path /= "favorite_plugins"; + path /= "plugin_statuses"; ofs.open (path.to_string().c_str(), ios_base::openmode (ios::out|ios::trunc)); @@ -577,7 +582,7 @@ PluginManager::save_favorites () return; } - for (FavoritePluginList::iterator i = favorites.begin(); i != favorites.end(); ++i) { + for (PluginStatusList::iterator i = statuses.begin(); i != statuses.end(); ++i) { switch ((*i).type) { case LADSPA: ofs << "LADSPA"; @@ -593,17 +598,31 @@ PluginManager::save_favorites () break; } - ofs << ' ' << (*i).unique_id << endl; + ofs << ' ' << (*i).unique_id << ' '; + + switch ((*i).status) { + case Normal: + ofs << "Normal"; + break; + case Favorite: + ofs << "Favorite"; + break; + case Hidden: + ofs << "Hidden"; + break; + } + + ofs << endl; } ofs.close (); } void -PluginManager::load_favorites () +PluginManager::load_statuses () { sys::path path = user_config_directory(); - path /= "favorite_plugins"; + path /= "plugin_statuses"; ifstream ifs (path.to_string().c_str()); if (!ifs) { @@ -612,7 +631,9 @@ PluginManager::load_favorites () std::string stype; std::string id; + std::string sstatus; PluginType type; + PluginStatusType status; while (ifs) { @@ -626,6 +647,12 @@ PluginManager::load_favorites () break; } + ifs >> sstatus; + if (!ifs) { + break; + + } + if (stype == "LADSPA") { type = LADSPA; } else if (stype == "AudioUnit") { @@ -635,30 +662,40 @@ PluginManager::load_favorites () } else if (stype == "VST") { type = VST; } else { - error << string_compose (_("unknown favorite plugin type \"%1\" - ignored"), stype) + error << string_compose (_("unknown plugin type \"%1\" - ignored"), stype) + << endmsg; + continue; + } + if (sstatus == "Normal") { + status = Normal; + } else if (sstatus == "Favorite") { + status = Favorite; + } else if (sstatus == "Hidden") { + status = Hidden; + } else { + error << string_compose (_("unknown plugin status type \"%1\" - ignored"), stype) << endmsg; continue; } - add_favorite (type, id); + set_status (type, id, status); } ifs.close (); } void -PluginManager::add_favorite (PluginType t, string id) +PluginManager::set_status (PluginType t, string id, PluginStatusType status) { - FavoritePlugin fp (t, id); - pair<FavoritePluginList::iterator,bool> res = favorites.insert (fp); - //cerr << "Added " << t << " " << id << " success ? " << res.second << endl; -} + PluginStatus ps (t, id, status); + statuses.erase (ps); -void -PluginManager::remove_favorite (PluginType t, string id) -{ - FavoritePlugin fp (t, id); - favorites.erase (fp); + if (status == Normal) { + return; + } + + pair<PluginStatusList::iterator, bool> res = statuses.insert (ps); + //cerr << "Added " << t << " " << id << " " << status << " success ? " << res.second << endl; } ARDOUR::PluginInfoList& |