summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-11-08 19:15:28 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-11-08 19:15:28 +0000
commitb5f7ae45bda38031f354ea1643ebc1cc22018907 (patch)
tree58ef43d8048cb3c5dbb5305b4d056cd06249c891
parentd7faaf7b028d7e0a56b8cefb90210f7e7505e6f0 (diff)
plugin menu/manager patch from J. Abelardo Gutierrez
git-svn-id: svn://localhost/ardour2/branches/3.0@6038 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/plugin_selector.cc241
-rw-r--r--gtk2_ardour/plugin_selector.h7
-rw-r--r--libs/ardour/ardour/plugin_manager.h42
-rw-r--r--libs/ardour/plugin_manager.cc87
4 files changed, 288 insertions, 89 deletions
diff --git a/gtk2_ardour/plugin_selector.cc b/gtk2_ardour/plugin_selector.cc
index f7ba9cbd0b..c2f81f4981 100644
--- a/gtk2_ardour/plugin_selector.cc
+++ b/gtk2_ardour/plugin_selector.cc
@@ -58,6 +58,7 @@ static const char* _filter_mode_strings[] = {
N_("Author contains"),
N_("Library contains"),
N_("Favorites only"),
+ N_("Hidden only"),
0
};
@@ -77,9 +78,11 @@ PluginSelector::PluginSelector (PluginManager *mgr)
plugin_model = Gtk::ListStore::create (plugin_columns);
plugin_display.set_model (plugin_model);
/* XXX translators: try to convert "Fav" into a short term
- related to "favorite"
+ related to "favorite" and "Hid" into a short term
+ related to "hidden"
*/
plugin_display.append_column (_("Fav"), plugin_columns.favorite);
+ plugin_display.append_column (_("Hid"), plugin_columns.hidden);
plugin_display.append_column (_("Available Plugins"), plugin_columns.name);
plugin_display.append_column (_("Type"), plugin_columns.type_name);
plugin_display.append_column (_("Category"), plugin_columns.category);
@@ -95,9 +98,14 @@ PluginSelector::PluginSelector (PluginManager *mgr)
CellRendererToggle* fav_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (0));
fav_cell->property_activatable() = true;
- fav_cell->property_radio() = false;
+ fav_cell->property_radio() = true;
fav_cell->signal_toggled().connect (mem_fun (*this, &PluginSelector::favorite_changed));
+ CellRendererToggle* hidden_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (1));
+ hidden_cell->property_activatable() = true;
+ hidden_cell->property_radio() = true;
+ hidden_cell->signal_toggled().connect (mem_fun (*this, &PluginSelector::hidden_changed));
+
scroller.set_border_width(10);
scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scroller.add(plugin_display);
@@ -108,7 +116,7 @@ PluginSelector::PluginSelector (PluginManager *mgr)
added_list.set_headers_visible (true);
added_list.set_reorderable (false);
- for (int i = 0; i <=7; i++) {
+ for (int i = 0; i <=8; i++) {
Gtk::TreeView::Column* column = plugin_display.get_column(i);
column->set_sort_column(i);
}
@@ -159,7 +167,7 @@ PluginSelector::PluginSelector (PluginManager *mgr)
table->attach(ascroller, 0, 7, 8, 10);
- add_button (Stock::CANCEL, RESPONSE_CANCEL);
+ add_button (Stock::CLOSE, RESPONSE_CLOSE);
add_button (_("Insert Plugin(s)"), RESPONSE_APPLY);
set_default_response (RESPONSE_APPLY);
set_response_sensitive (RESPONSE_APPLY, false);
@@ -208,7 +216,11 @@ PluginSelector::show_this_plugin (const PluginInfoPtr& info, const std::string&
std::string mode = filter_mode.get_active_text ();
if (mode == _("Favorites only")) {
- return manager->is_a_favorite_plugin (info);
+ return manager->get_status (info) == PluginManager::Favorite;
+ }
+
+ if (mode == _("Hidden only")) {
+ return manager->get_status (info) == PluginManager::Hidden;
}
if (!filterstr.empty()) {
@@ -292,7 +304,8 @@ PluginSelector::refiller (const PluginInfoList& plugs, const::std::string& filte
if (show_this_plugin (*i, filterstr)) {
TreeModel::Row newrow = *(plugin_model->append());
- newrow[plugin_columns.favorite] = manager->is_a_favorite_plugin (*i);
+ newrow[plugin_columns.favorite] = (manager->get_status (*i) == PluginManager::Favorite);
+ newrow[plugin_columns.hidden] = (manager->get_status (*i) == PluginManager::Hidden);
newrow[plugin_columns.name] = (*i)->name;
newrow[plugin_columns.type_name] = type;
newrow[plugin_columns.category] = (*i)->category;
@@ -480,7 +493,7 @@ PluginSelector::filter_mode_changed ()
{
std::string mode = filter_mode.get_active_text ();
- if (mode == _("Favorites only")) {
+ if (mode == _("Favorites only") || mode == _("Hidden only")) {
filter_entry.set_sensitive (false);
} else {
filter_entry.set_sensitive (true);
@@ -496,7 +509,7 @@ PluginSelector::on_show ()
filter_entry.grab_focus ();
}
-struct PluginMenuCompare {
+struct PluginMenuCompareByCreator {
bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
int cmp;
@@ -514,28 +527,45 @@ struct PluginMenuCompare {
}
};
-Gtk::Menu&
-PluginSelector::plugin_menu()
-{
- using namespace Menu_Helpers;
+struct PluginMenuCompareByName {
+ bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
+ int cmp;
- typedef std::map<Glib::ustring,Gtk::Menu*> SubmenuMap;
- SubmenuMap submenu_map;
+ cmp = strcasecmp (a->name.c_str(), b->name.c_str());
- if (!_menu) {
- _menu = new Menu();
- _menu->set_name("ArdourContextMenu");
- }
+ if (cmp < 0) {
+ return true;
+ } else if (cmp == 0) {
+ /* same name ... compare type */
+ if (a->type < b->type) {
+ return true;
+ }
+ }
+ return false;
+ }
+};
- MenuList& items = _menu->items();
- Menu* favs = new Menu();
- favs->set_name("ArdourContextMenu");
+struct PluginMenuCompareByCategory {
+ bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
+ int cmp;
- items.clear ();
- items.push_back (MenuElem (_("Favorites"), *favs));
- items.push_back (MenuElem (_("Plugin Manager"), mem_fun (*this, &PluginSelector::show_manager)));
- items.push_back (SeparatorElem ());
+ cmp = strcasecmp (a->category.c_str(), b->category.c_str());
+ if (cmp < 0) {
+ return true;
+ } else if (cmp == 0) {
+ /* same category ... compare names */
+ if (strcasecmp (a->name.c_str(), b->name.c_str()) < 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+};
+
+Gtk::Menu&
+PluginSelector::plugin_menu()
+{
PluginInfoList all_plugs;
all_plugs.insert (all_plugs.end(), manager->ladspa_plugin_info().begin(), manager->ladspa_plugin_info().end());
@@ -549,38 +579,125 @@ PluginSelector::plugin_menu()
all_plugs.insert (all_plugs.end(), manager->lv2_plugin_info().begin(), manager->lv2_plugin_info().end());
#endif
- PluginMenuCompare cmp;
- all_plugs.sort (cmp);
+ using namespace Menu_Helpers;
- for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
- SubmenuMap::iterator x;
- Gtk::Menu* submenu;
+ if (!_menu) {
+ _menu = new Menu();
+ _menu->set_name("ArdourContextMenu");
+ }
- string creator = (*i)->creator;
- string::size_type pos = 0;
+ MenuList& items = _menu->items();
+ items.clear ();
+
+ Gtk::Menu* favs = create_favs_menu(all_plugs);
+ items.push_back (MenuElem (_("Favorites"), *favs));
+
+ items.push_back (MenuElem (_("Plugin Manager"), mem_fun (*this, &PluginSelector::show_manager)));
+ items.push_back (SeparatorElem ());
+
+ Menu* by_creator = create_by_creator_menu(all_plugs);
+ items.push_back (MenuElem (_("By Creator"), *by_creator));
+
+ Menu* by_category = create_by_category_menu(all_plugs);
+ items.push_back (MenuElem (_("By Category"), *by_category));
+
+ return *_menu;
+}
+
+Gtk::Menu*
+PluginSelector::create_favs_menu (PluginInfoList& all_plugs)
+{
+ using namespace Menu_Helpers;
+
+ Menu* favs = new Menu();
+ favs->set_name("ArdourContextMenu");
+
+ PluginMenuCompareByName cmp_by_name;
+ all_plugs.sort (cmp_by_name);
- if (manager->is_a_favorite_plugin (*i)) {
+ for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
+ if (manager->get_status (*i) == PluginManager::Favorite) {
favs->items().push_back (MenuElem ((*i)->name, (bind (mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i))));
}
+ }
+ return favs;
+}
- /* stupid LADSPA creator strings */
+Gtk::Menu*
+PluginSelector::create_by_creator_menu (ARDOUR::PluginInfoList& all_plugs)
+{
+ using namespace Menu_Helpers;
+ typedef std::map<Glib::ustring,Gtk::Menu*> SubmenuMap;
+ SubmenuMap creator_submenu_map;
+
+ Menu* by_creator = new Menu();
+ by_creator->set_name("ArdourContextMenu");
+
+ MenuList& by_creator_items = by_creator->items();
+ PluginMenuCompareByCreator cmp_by_creator;
+ all_plugs.sort (cmp_by_creator);
+
+ for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
+
+ if (manager->get_status (*i) == PluginManager::Hidden) continue;
+
+ string creator = (*i)->creator;
+
+ /* stupid LADSPA creator strings */
+ string::size_type pos = 0;
while (pos < creator.length() && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
creator = creator.substr (0, pos);
- if ((x = submenu_map.find (creator)) != submenu_map.end()) {
+ SubmenuMap::iterator x;
+ Gtk::Menu* submenu;
+ if ((x = creator_submenu_map.find (creator)) != creator_submenu_map.end()) {
submenu = x->second;
} else {
submenu = new Gtk::Menu;
- items.push_back (MenuElem (creator, *submenu));
- submenu_map.insert (pair<Glib::ustring,Menu*> (creator, submenu));
+ by_creator_items.push_back (MenuElem (creator, *submenu));
+ creator_submenu_map.insert (pair<Glib::ustring,Menu*> (creator, submenu));
submenu->set_name("ArdourContextMenu");
}
-
submenu->items().push_back (MenuElem ((*i)->name, (bind (mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i))));
}
+ return by_creator;
+}
- return *_menu;
+Gtk::Menu*
+PluginSelector::create_by_category_menu (ARDOUR::PluginInfoList& all_plugs)
+{
+ using namespace Menu_Helpers;
+
+ typedef std::map<Glib::ustring,Gtk::Menu*> SubmenuMap;
+ SubmenuMap category_submenu_map;
+
+ Menu* by_category = new Menu();
+ by_category->set_name("ArdourContextMenu");
+
+ MenuList& by_category_items = by_category->items();
+ PluginMenuCompareByCategory cmp_by_category;
+ all_plugs.sort (cmp_by_category);
+
+ for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
+
+ if (manager->get_status (*i) == PluginManager::Hidden) continue;
+
+ string category = (*i)->category;
+
+ SubmenuMap::iterator x;
+ Gtk::Menu* submenu;
+ if ((x = category_submenu_map.find (category)) != category_submenu_map.end()) {
+ submenu = x->second;
+ } else {
+ submenu = new Gtk::Menu;
+ by_category_items.push_back (MenuElem (category, *submenu));
+ category_submenu_map.insert (pair<Glib::ustring,Menu*> (category, submenu));
+ submenu->set_name("ArdourContextMenu");
+ }
+ submenu->items().push_back (MenuElem ((*i)->name, (bind (mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i))));
+ }
+ return by_category;
}
void
@@ -617,18 +734,50 @@ PluginSelector::favorite_changed (const Glib::ustring& path)
/* change state */
(*iter)[plugin_columns.favorite] = favorite;
+ (*iter)[plugin_columns.hidden] = false;
+ PluginManager::PluginStatusType status = (favorite ? PluginManager::Favorite : PluginManager::Normal);
- /* save new favorites list */
+ /* save new statuses list */
pi = (*iter)[plugin_columns.plugin];
- if (favorite) {
- manager->add_favorite (pi->type, pi->unique_id);
- } else {
- manager->remove_favorite (pi->type, pi->unique_id);
- }
+ manager->set_status (pi->type, pi->unique_id, status);
+
+ manager->save_statuses ();
+ }
+ in_row_change = false;
+}
+
+void
+PluginSelector::hidden_changed (const Glib::ustring& path)
+{
+ PluginInfoPtr pi;
+
+ if (in_row_change) {
+ return;
+ }
+
+ in_row_change = true;
+
+ TreeModel::iterator iter = plugin_model->get_iter (path);
+
+ if (iter) {
+
+ bool hidden = !(*iter)[plugin_columns.hidden];
+
+ /* change state */
+
+ (*iter)[plugin_columns.favorite] = false;
+ (*iter)[plugin_columns.hidden] = hidden;
+ PluginManager::PluginStatusType status = (hidden ? PluginManager::Hidden : PluginManager::Normal);
+
+ /* save new statuses list */
+
+ pi = (*iter)[plugin_columns.plugin];
+
+ manager->set_status (pi->type, pi->unique_id, status);
- manager->save_favorites ();
+ manager->save_statuses ();
}
in_row_change = false;
}
diff --git a/gtk2_ardour/plugin_selector.h b/gtk2_ardour/plugin_selector.h
index dc09c30645..2e673d8de7 100644
--- a/gtk2_ardour/plugin_selector.h
+++ b/gtk2_ardour/plugin_selector.h
@@ -66,6 +66,7 @@ class PluginSelector : public ArdourDialog
struct PluginColumns : public Gtk::TreeModel::ColumnRecord {
PluginColumns () {
add (favorite);
+ add (hidden);
add (name);
add (type_name);
add (category);
@@ -77,6 +78,7 @@ class PluginSelector : public ArdourDialog
add (plugin);
}
Gtk::TreeModelColumn<bool> favorite;
+ Gtk::TreeModelColumn<bool> hidden;
Gtk::TreeModelColumn<std::string> name;
Gtk::TreeModelColumn<std::string> type_name;
Gtk::TreeModelColumn<std::string> category;
@@ -126,10 +128,15 @@ class PluginSelector : public ArdourDialog
void setup_filter_string (std::string&);
void favorite_changed (const Glib::ustring& path);
+ void hidden_changed (const Glib::ustring& path);
bool in_row_change;
void plugin_chosen_from_menu (const ARDOUR::PluginInfoPtr&);
Gtk::Menu* _menu;
+
+ Gtk::Menu* create_favs_menu (ARDOUR::PluginInfoList&);
+ Gtk::Menu* create_by_creator_menu (ARDOUR::PluginInfoList&);
+ Gtk::Menu* create_by_category_menu (ARDOUR::PluginInfoList&);
};
#endif // __ardour_plugin_selector_h__
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&