2 Copyright (C) 2000-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "gtk2ardour-config.h"
28 #include <gtkmm/button.h>
29 #include <gtkmm/comboboxtext.h>
30 #include <gtkmm/frame.h>
31 #include <gtkmm/messagedialog.h>
32 #include <gtkmm/notebook.h>
33 #include <gtkmm/stock.h>
34 #include <gtkmm/table.h>
35 #include <gtkmm/treestore.h>
37 #include "gtkmm2ext/utils.h"
39 #include "widgets/tooltips.h"
41 #include "pbd/convert.h"
42 #include "pbd/tokenizer.h"
44 #include "ardour/utils.h"
46 #include "plugin_selector.h"
47 #include "gui_thread.h"
48 #include "ui_config.h"
52 using namespace ARDOUR;
56 using namespace ArdourWidgets;
58 static const uint32_t MAX_CREATOR_LEN = 24;
60 PluginSelector::PluginSelector (PluginManager& mgr)
61 : ArdourDialog (_("Plugin Manager"), true, false)
62 , search_clear_button (Stock::CLEAR)
64 , _inhibit_refill (false)
66 set_name ("PluginSelectorWindow");
67 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
70 in_row_change = false;
72 manager.PluginListChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::build_plugin_menu, this), gui_context());
73 manager.PluginStatusChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::build_plugin_menu, this), gui_context());
75 manager.PluginStatusChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::plugin_status_changed, this, _1, _2, _3), gui_context());
76 manager.PluginTagChanged.connect(plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::tags_changed, this, _1, _2, _3), gui_context());
78 plugin_model = Gtk::ListStore::create (plugin_columns);
79 plugin_display.set_model (plugin_model);
80 /* XXX translators: try to convert "Fav" into a short term
81 * related to "favorite" and "Hid" into a short term
84 plugin_display.append_column (_("Fav"), plugin_columns.favorite);
85 plugin_display.append_column (_("Hide"), plugin_columns.hidden);
86 plugin_display.append_column (_("Name"), plugin_columns.name);
87 plugin_display.append_column (_("Tags"), plugin_columns.tags);
88 plugin_display.append_column (_("Creator"), plugin_columns.creator);
89 plugin_display.append_column (_("Type"), plugin_columns.type_name);
90 plugin_display.append_column (_("Audio I/O"),plugin_columns.audio_io);
91 plugin_display.append_column (_("MIDI I/O"), plugin_columns.midi_io);
92 plugin_display.set_headers_visible (true);
93 plugin_display.set_headers_clickable (true);
94 plugin_display.set_reorderable (false);
95 plugin_display.set_rules_hint (true);
96 plugin_display.add_object_drag (plugin_columns.plugin.index(), "PluginInfoPtr");
97 plugin_display.set_drag_column (plugin_columns.name.index());
99 // setting a sort-column prevents re-ordering via Drag/Drop
100 plugin_model->set_sort_column (plugin_columns.name.index(), Gtk::SORT_ASCENDING);
102 plugin_display.set_name("PluginSelectorDisplay");
103 plugin_display.signal_row_activated().connect_notify (sigc::mem_fun(*this, &PluginSelector::row_activated));
104 plugin_display.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &PluginSelector::display_selection_changed));
106 CellRendererToggle* fav_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (0));
107 fav_cell->property_activatable() = true;
108 fav_cell->property_radio() = true;
109 fav_cell->signal_toggled().connect (sigc::mem_fun (*this, &PluginSelector::favorite_changed));
111 CellRendererToggle* hidden_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (1));
112 hidden_cell->property_activatable() = true;
113 hidden_cell->property_radio() = true;
114 hidden_cell->signal_toggled().connect (sigc::mem_fun (*this, &PluginSelector::hidden_changed));
116 scroller.set_border_width(10);
117 scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
118 scroller.add(plugin_display);
120 amodel = Gtk::ListStore::create(acols);
121 added_list.set_model (amodel);
122 added_list.append_column (_("Plugins to be connected"), acols.text);
123 added_list.set_headers_visible (true);
124 added_list.set_reorderable (false);
126 for (int i = 2; i <= 7; ++i) {
127 Gtk::TreeView::Column* column = plugin_display.get_column(i);
129 column->set_sort_column(i);
133 ascroller.set_border_width(10);
134 ascroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
135 ascroller.add(added_list);
136 btn_add = manage(new Gtk::Button(Stock::ADD));
137 set_tooltip(*btn_add, _("Add a plugin to the effect list"));
138 btn_add->set_sensitive (false);
139 btn_remove = manage(new Gtk::Button(Stock::REMOVE));
140 btn_remove->set_sensitive (false);
141 set_tooltip(*btn_remove, _("Remove a plugin from the effect list"));
143 btn_add->set_name("PluginSelectorButton");
144 btn_remove->set_name("PluginSelectorButton");
148 Gtk::Table* search_table = manage(new Gtk::Table(2, 2));
150 search_entry.signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::search_entry_changed));
151 search_clear_button.signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::search_clear_button_clicked));
153 _search_name_checkbox = manage (new ArdourButton (_("Name"), ArdourButton::led_default_elements, true));
154 _search_name_checkbox->set_active(true);
155 _search_name_checkbox->set_name ("pluginlist filter button");
157 _search_tags_checkbox = manage (new ArdourButton (_("Tags"), ArdourButton::led_default_elements, true));
158 _search_tags_checkbox->set_active(true);
159 _search_tags_checkbox->set_name ("pluginlist filter button");
161 _search_ignore_checkbox = manage (new ArdourButton(_("Ignore Filters when searching"), ArdourButton::led_default_elements, true));
162 _search_ignore_checkbox->set_active(true);
163 _search_ignore_checkbox->set_name ("pluginlist filter button");
165 Gtk::Label* search_help_label1 = manage (new Label(
166 _("All search terms must be matched."), Gtk::ALIGN_LEFT));
168 Gtk::Label* search_help_label2 = manage (new Label(
169 _("Ex: \"ess dyn\" will find \"dynamic de-esser\" but not \"de-esser\"."), Gtk::ALIGN_LEFT));
171 search_table->attach (search_entry, 0, 3, 0, 1, FILL|EXPAND, FILL);
172 search_table->attach (search_clear_button, 3, 4, 0, 1, FILL, FILL);
173 search_table->attach (*_search_name_checkbox, 0, 1, 1, 2, FILL, FILL);
174 search_table->attach (*_search_tags_checkbox, 1, 2, 1, 2, FILL, FILL);
175 search_table->attach (*_search_ignore_checkbox,2, 3, 1, 2, FILL, FILL);
176 search_table->attach (*search_help_label1, 0, 3, 2, 3, FILL, FILL);
177 search_table->attach (*search_help_label2, 0, 3, 3, 4, FILL, FILL);
179 search_table->set_border_width (4);
180 search_table->set_col_spacings (4);
181 search_table->set_row_spacings (4);
183 Frame* search_frame = manage (new Frame);
184 search_frame->set_name ("BaseFrame");
185 search_frame->set_label (_("Search"));
186 search_frame->add (*search_table);
187 search_frame->show_all ();
189 _search_name_checkbox->signal_clicked.connect (sigc::mem_fun (*this, &PluginSelector::refill));
190 _search_tags_checkbox->signal_clicked.connect (sigc::mem_fun (*this, &PluginSelector::refill));
191 _search_ignore_checkbox->signal_clicked.connect (sigc::mem_fun (*this, &PluginSelector::set_sensitive_widgets));
195 Gtk::RadioButtonGroup fil_radio_group;
197 _fil_effects_radio = manage (new RadioButton (fil_radio_group, _("Show Effects Only")));
198 _fil_instruments_radio = manage (new RadioButton (fil_radio_group, _("Show Instruments Only")));
199 _fil_utils_radio = manage (new RadioButton (fil_radio_group, _("Show Utilities Only")));
200 _fil_favorites_radio = manage (new RadioButton (fil_radio_group, _("Show Favorites Only")));
201 _fil_hidden_radio = manage (new RadioButton (fil_radio_group, _("Show Hidden Only")));
202 _fil_all_radio = manage (new RadioButton (fil_radio_group, _("Show All")));
204 //_fil_type_combo = manage (new ComboBoxText);
205 _fil_type_combo.append_text_item (_("Show All Formats"));
206 _fil_type_combo.append_text_item (X_("VST"));
207 #ifdef AUDIOUNIT_SUPPORT
208 _fil_type_combo.append_text_item (X_("AudioUnit"));
211 _fil_type_combo.append_text_item (X_("LV2"));
213 _fil_type_combo.append_text_item (X_("Lua"));
214 _fil_type_combo.append_text_item (X_("LADSPA"));
215 _fil_type_combo.set_text (_("Show All Formats"));
217 /* note: _fil_creator_combo menu gets filled in build_plugin_menu */
218 _fil_creator_combo.set_text_ellipsize (Pango::ELLIPSIZE_END);
219 _fil_creator_combo.set_layout_ellipsize_width (PANGO_SCALE * 160 * UIConfiguration::instance ().get_ui_scale ());
221 VBox* filter_vbox = manage (new VBox);
222 filter_vbox->pack_start (*_fil_effects_radio, false, false);
223 filter_vbox->pack_start (*_fil_instruments_radio, false, false);
224 filter_vbox->pack_start (*_fil_utils_radio, false, false);
225 filter_vbox->pack_start (*_fil_favorites_radio, false, false);
226 filter_vbox->pack_start (*_fil_hidden_radio, false, false);
227 filter_vbox->pack_start (*_fil_all_radio, false, false);
228 filter_vbox->pack_start (_fil_type_combo, false, false);
229 filter_vbox->pack_start (_fil_creator_combo, false, false);
231 filter_vbox->set_border_width (4);
232 filter_vbox->set_spacing (4);
234 Frame* filter_frame = manage (new Frame);
235 filter_frame->set_name ("BaseFrame");
236 filter_frame->set_label (_("Filter"));
237 filter_frame->add (*filter_vbox);
238 filter_frame->show_all ();
240 _fil_effects_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
241 _fil_instruments_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
242 _fil_utils_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
243 _fil_favorites_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
244 _fil_hidden_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
246 _fil_type_combo.StateChanged.connect (sigc::mem_fun (*this, &PluginSelector::refill));
247 _fil_creator_combo.StateChanged.connect (sigc::mem_fun (*this, &PluginSelector::refill));
251 Gtk::Table* tagging_table = manage(new Gtk::Table(1, 2));
252 tagging_table->set_border_width (4);
253 tagging_table->set_col_spacings (4);
254 tagging_table->set_row_spacings (4);
256 tag_entry = manage (new Gtk::Entry);
257 tag_entry_connection = tag_entry->signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::tag_entry_changed));
259 tag_reset_button = manage (new Button (_("Reset")));
260 tag_reset_button->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::tag_reset_button_clicked));
262 Gtk::Label* tagging_help_label1 = manage (new Label(
263 _("Enter space-separated, one-word Tags for the selected plugin."), Gtk::ALIGN_LEFT));
265 Gtk::Label* tagging_help_label2 = manage (new Label(
266 _("You can include dashes, colons or underscores in a Tag."), Gtk::ALIGN_LEFT));
268 Gtk::Label* tagging_help_label3 = manage (new Label(
269 _("Ex: \"dynamic de-esser vocal\" applies 3 Tags."), Gtk::ALIGN_LEFT));
272 tagging_table->attach (*tag_entry, 0, 1, p, p+1, FILL|EXPAND, FILL);
273 tagging_table->attach (*tag_reset_button, 1, 2, p, p+1, FILL, FILL); p++;
274 tagging_table->attach (*tagging_help_label1, 0, 2, p, p+1, FILL, FILL); p++;
275 tagging_table->attach (*tagging_help_label2, 0, 2, p, p+1, FILL, FILL); p++;
276 tagging_table->attach (*tagging_help_label3, 0, 2, p, p+1, FILL, FILL); p++;
278 Frame* tag_frame = manage (new Frame);
279 tag_frame->set_name ("BaseFrame");
280 tag_frame->set_label (_("Tags for Selected Plugin"));
281 tag_frame->add (*tagging_table);
282 tag_frame->show_all ();
284 /* Add & remove buttons */
286 HBox* add_remove = manage (new HBox);
287 add_remove->pack_start (*btn_add, true, true);
288 add_remove->pack_start (*btn_remove, true, true);
290 btn_add->signal_clicked().connect(sigc::mem_fun(*this, &PluginSelector::btn_add_clicked));
291 btn_remove->signal_clicked().connect(sigc::mem_fun(*this, &PluginSelector::btn_remove_clicked));
292 added_list.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &PluginSelector::added_list_selection_changed));
293 added_list.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::added_row_clicked));
295 added_list.set_name("PluginSelectorList");
297 /* Top-level Layout */
299 VBox* to_be_inserted_vbox = manage (new VBox);
300 to_be_inserted_vbox->pack_start (ascroller);
301 to_be_inserted_vbox->pack_start (*add_remove, false, false);
302 to_be_inserted_vbox->set_size_request (200, -1);
304 Gtk::Table* table = manage(new Gtk::Table(3, 3));
305 table->set_size_request(-1, 600);
306 table->attach (scroller, 0, 3, 0, 5); /* this is the main plugin list */
307 table->attach (*search_frame, 0, 1, 6, 7, FILL, FILL, 5, 5);
308 table->attach (*tag_frame, 0, 1, 7, 8, FILL, FILL, 5, 5);
309 table->attach (*filter_frame, 1, 2, 6, 8, FILL, FILL, 5, 5);
310 table->attach (*to_be_inserted_vbox, 2, 3, 6, 8, FILL|EXPAND, FILL, 5, 5); /* to be inserted... */
312 add_button (Stock::CLOSE, RESPONSE_CLOSE);
313 add_button (_("Insert Plugin(s)"), RESPONSE_APPLY);
314 set_default_response (RESPONSE_APPLY);
315 set_response_sensitive (RESPONSE_APPLY, false);
316 get_vbox()->pack_start (*table);
318 table->set_name("PluginSelectorTable");
320 plugin_display.grab_focus();
322 build_plugin_menu ();
323 display_selection_changed ();
326 PluginSelector::~PluginSelector ()
332 PluginSelector::row_activated(Gtk::TreeModel::Path, Gtk::TreeViewColumn*)
338 PluginSelector::added_row_clicked(GdkEventButton* event)
340 if (event->type == GDK_2BUTTON_PRESS)
341 btn_remove_clicked();
345 PluginSelector::show_this_plugin (const PluginInfoPtr& info, const std::string& searchstr)
348 bool maybe_show = false;
350 if (!searchstr.empty()) {
354 if (_search_name_checkbox->get_active()) { /* name contains */
355 compstr = info->name;
356 transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
357 if (compstr.find (searchstr) != string::npos) {
362 if (_search_tags_checkbox->get_active()) { /* tag contains */
363 compstr = manager.get_tags_as_string (info);
364 transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
365 if (compstr.find (searchstr) != string::npos) {
374 /* user asked to ignore filters */
375 if (maybe_show && _search_ignore_checkbox->get_active()) {
376 if (manager.get_status (info) == PluginManager::Hidden) {
383 if (_fil_effects_radio->get_active() && !info->is_effect()) {
387 if (_fil_instruments_radio->get_active() && !info->is_instrument()) {
391 if (_fil_utils_radio->get_active() && !(info->is_utility() || info->is_analyzer())) {
395 if (_fil_favorites_radio->get_active() && !(manager.get_status (info) == PluginManager::Favorite)) {
399 if (_fil_hidden_radio->get_active() && !(manager.get_status (info) == PluginManager::Hidden)) {
403 if (!_fil_hidden_radio->get_active() && manager.get_status (info) == PluginManager::Hidden) {
407 /* Filter "type" combobox */
409 if (_fil_type_combo.get_text() == X_("VST") && PluginManager::to_generic_vst(info->type) != LXVST) {
413 if (_fil_type_combo.get_text() == X_("AudioUnit") && info->type != AudioUnit) {
418 if (_fil_type_combo.get_text() == X_("LV2") && info->type != LV2) {
423 if (_fil_type_combo.get_text() == X_("Lua") && info->type != Lua) {
427 if (_fil_type_combo.get_text() == X_("LADSPA") && info->type != LADSPA) {
431 /* Filter "creator" combobox */
433 if (_fil_creator_combo.get_text() != _("Show All Creators")) {
434 if (_fil_creator_combo.get_text() != info->creator) {
443 PluginSelector::setup_search_string (string& searchstr)
445 searchstr = search_entry.get_text ();
446 transform (searchstr.begin(), searchstr.end(), searchstr.begin(), ::toupper);
450 PluginSelector::set_sensitive_widgets ()
452 if (_search_ignore_checkbox->get_active() && !search_entry.get_text().empty()) {
453 _fil_effects_radio->set_sensitive(false);
454 _fil_instruments_radio->set_sensitive(false);
455 _fil_utils_radio->set_sensitive(false);
456 _fil_favorites_radio->set_sensitive(false);
457 _fil_hidden_radio->set_sensitive(false);
458 _fil_all_radio->set_sensitive(false);
459 _inhibit_refill = true;
460 _fil_type_combo.set_sensitive(false);
461 _fil_creator_combo.set_sensitive(false);
462 _inhibit_refill = false;
464 _fil_effects_radio->set_sensitive(true);
465 _fil_instruments_radio->set_sensitive(true);
466 _fil_utils_radio->set_sensitive(true);
467 _fil_favorites_radio->set_sensitive(true);
468 _fil_hidden_radio->set_sensitive(true);
469 _fil_all_radio->set_sensitive(true);
470 _inhibit_refill = true;
471 _fil_type_combo.set_sensitive(true);
472 _fil_creator_combo.set_sensitive(true);
473 _inhibit_refill = false;
475 if (!search_entry.get_text().empty()) {
481 PluginSelector::refill ()
483 if (_inhibit_refill) {
487 std::string searchstr;
489 in_row_change = true;
491 plugin_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
495 bool sorted = plugin_model->get_sort_column_id (sort_col, sort_type);
497 /* Disable sorting to gain performance */
498 plugin_model->set_sort_column (-2, SORT_ASCENDING);
500 plugin_model->clear ();
502 setup_search_string (searchstr);
504 ladspa_refiller (searchstr);
505 lv2_refiller (searchstr);
506 vst_refiller (searchstr);
507 lxvst_refiller (searchstr);
508 mac_vst_refiller (searchstr);
509 au_refiller (searchstr);
510 lua_refiller (searchstr);
512 in_row_change = false;
514 plugin_display.set_model (plugin_model);
516 plugin_model->set_sort_column (sort_col, sort_type);
521 PluginSelector::refiller (const PluginInfoList& plugs, const::std::string& searchstr, const char* type)
525 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
527 if (show_this_plugin (*i, searchstr)) {
529 TreeModel::Row newrow = *(plugin_model->append());
530 newrow[plugin_columns.favorite] = (manager.get_status (*i) == PluginManager::Favorite);
531 newrow[plugin_columns.hidden] = (manager.get_status (*i) == PluginManager::Hidden);
533 string name = (*i)->name;
534 if (name.length() > 48) {
535 name = name.substr (0, 48);
538 newrow[plugin_columns.name] = name;
540 newrow[plugin_columns.type_name] = type;
543 string creator = (*i)->creator;
544 string::size_type pos = 0;
545 if ((*i)->type == ARDOUR::LADSPA) {
546 /* stupid LADSPA creator strings */
547 #ifdef PLATFORM_WINDOWS
548 while (pos < creator.length() && creator[pos] > -2 && creator[pos] < 256 && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
550 while (pos < creator.length() && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
553 pos = creator.length ();
555 // If there were too few characters to create a
556 // meaningful name, mark this creator as 'Unknown'
557 if (creator.length() < 2 || pos < 3) {
560 creator = creator.substr (0, pos);
563 if (creator.length() > MAX_CREATOR_LEN) {
564 creator = creator.substr (0, MAX_CREATOR_LEN);
565 creator.append("...");
567 newrow[plugin_columns.creator] = creator;
570 string tags = manager.get_tags_as_string(*i);
571 if (tags.length() > 32) {
572 tags = tags.substr (0, 32);
575 newrow[plugin_columns.tags] = tags;
577 if ((*i)->reconfigurable_io ()) {
578 newrow[plugin_columns.audio_io] = "* / *";
579 newrow[plugin_columns.midi_io] = "* / *";
581 snprintf (buf, sizeof(buf), "%d / %d", (*i)->n_inputs.n_audio(), (*i)->n_outputs.n_audio());
582 newrow[plugin_columns.audio_io] = buf;
583 snprintf (buf, sizeof(buf), "%d / %d", (*i)->n_inputs.n_midi(), (*i)->n_outputs.n_midi());
584 newrow[plugin_columns.midi_io] = buf;
587 newrow[plugin_columns.plugin] = *i;
593 PluginSelector::ladspa_refiller (const std::string& searchstr)
595 refiller (manager.ladspa_plugin_info(), searchstr, "LADSPA");
599 PluginSelector::lua_refiller (const std::string& searchstr)
601 refiller (manager.lua_plugin_info(), searchstr, "Lua");
605 PluginSelector::lv2_refiller (const std::string& searchstr)
608 refiller (manager.lv2_plugin_info(), searchstr, "LV2");
613 #ifdef WINDOWS_VST_SUPPORT
614 PluginSelector::vst_refiller (const std::string& searchstr)
616 PluginSelector::vst_refiller (const std::string&)
619 #ifdef WINDOWS_VST_SUPPORT
620 refiller (manager.windows_vst_plugin_info(), searchstr, "VST");
626 PluginSelector::lxvst_refiller (const std::string& searchstr)
628 PluginSelector::lxvst_refiller (const std::string&)
632 refiller (manager.lxvst_plugin_info(), searchstr, "LXVST");
637 #ifdef MACVST_SUPPORT
638 PluginSelector::mac_vst_refiller (const std::string& searchstr)
640 PluginSelector::mac_vst_refiller (const std::string&)
643 #ifdef MACVST_SUPPORT
644 refiller (manager.mac_vst_plugin_info(), searchstr, "MacVST");
649 #ifdef AUDIOUNIT_SUPPORT
650 PluginSelector::au_refiller (const std::string& searchstr)
652 PluginSelector::au_refiller (const std::string&)
655 #ifdef AUDIOUNIT_SUPPORT
656 refiller (manager.au_plugin_info(), searchstr, "AU");
661 PluginSelector::load_plugin (PluginInfoPtr pi)
667 return pi->load (*_session);
671 PluginSelector::btn_add_clicked()
673 if (plugin_display.get_selection()->count_selected_rows() == 0) {
674 /* may happen with ctrl + double-click un-selecting but activating a row */
679 TreeModel::Row newrow = *(amodel->append());
682 row = *(plugin_display.get_selection()->get_selected());
683 name = row[plugin_columns.name];
684 pi = row[plugin_columns.plugin];
686 newrow[acols.text] = name;
687 newrow[acols.plugin] = pi;
689 if (!amodel->children().empty()) {
690 set_response_sensitive (RESPONSE_APPLY, true);
695 PluginSelector::btn_remove_clicked()
697 TreeModel::iterator iter = added_list.get_selection()->get_selected();
700 if (amodel->children().empty()) {
701 set_response_sensitive (RESPONSE_APPLY, false);
706 PluginSelector::display_selection_changed()
708 tag_entry_connection.block ();
709 if (plugin_display.get_selection()->count_selected_rows() != 0) {
711 /* a plugin row is selected; allow the user to edit the "tags" on it. */
712 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
713 string tags = manager.get_tags_as_string (row[plugin_columns.plugin]);
714 tag_entry->set_text (tags);
716 tag_entry->set_sensitive (true);
717 tag_reset_button->set_sensitive (true);
718 btn_add->set_sensitive (true);
721 tag_entry->set_text ("");
723 tag_entry->set_sensitive (false);
724 tag_reset_button->set_sensitive (false);
725 btn_add->set_sensitive (false);
727 tag_entry_connection.unblock ();
731 PluginSelector::added_list_selection_changed()
733 if (added_list.get_selection()->count_selected_rows() != 0) {
734 btn_remove->set_sensitive (true);
736 btn_remove->set_sensitive (false);
741 PluginSelector::run ()
744 TreeModel::Children::iterator i;
750 SelectedPlugins plugins;
751 r = (ResponseType) Dialog::run ();
755 for (i = amodel->children().begin(); i != amodel->children().end(); ++i) {
756 PluginInfoPtr pp = (*i)[acols.plugin];
757 PluginPtr p = load_plugin (pp);
759 plugins.push_back (p);
761 MessageDialog msg (string_compose (_("The plugin \"%1\" could not be loaded\n\nSee the Log window for more details (maybe)"), pp->name));
765 if (interested_object && !plugins.empty()) {
766 finish = !interested_object->use_plugins (plugins);
780 interested_object = 0;
782 if (_need_tag_save) {
786 if (_need_status_save) {
787 manager.save_statuses();
794 PluginSelector::search_clear_button_clicked ()
796 search_entry.set_text ("");
800 PluginSelector::tag_reset_button_clicked ()
802 if (plugin_display.get_selection()->count_selected_rows() != 0) {
803 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
804 ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin];
805 manager.reset_tags (pi);
806 display_selection_changed ();
807 _need_tag_save = true;
812 PluginSelector::search_entry_changed ()
814 set_sensitive_widgets();
815 if (search_entry.get_text().empty()) {
821 PluginSelector::tag_entry_changed ()
823 if (plugin_display.get_selection()->count_selected_rows() != 0) {
824 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
826 ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin];
827 manager.set_tags (pi->type, pi->unique_id, tag_entry->get_text(), pi->name, PluginManager::FromGui);
829 _need_tag_save = true;
834 PluginSelector::tags_changed (PluginType t, std::string unique_id, std::string tags)
836 if (plugin_display.get_selection()->count_selected_rows() != 0) {
837 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
838 if (tags.length() > 32) {
839 tags = tags.substr (0, 32);
842 row[plugin_columns.tags] = tags;
847 PluginSelector::plugin_status_changed (PluginType t, std::string uid, PluginManager::PluginStatusType stat)
849 Gtk::TreeModel::iterator i;
850 for (i = plugin_model->children().begin(); i != plugin_model->children().end(); ++i) {
851 PluginInfoPtr pp = (*i)[plugin_columns.plugin];
852 if ((pp->type == t) && (pp->unique_id == uid)) {
853 (*i)[plugin_columns.favorite] = (stat == PluginManager::Favorite) ? true : false;
854 (*i)[plugin_columns.hidden] = (stat == PluginManager::Hidden) ? true : false;
856 /* if plug was hidden, remove it from the view */
857 if (stat == PluginManager::Hidden) {
858 if (!_fil_hidden_radio->get_active() && !_fil_all_radio->get_active()) {
859 plugin_model->erase(i);
861 } else if (_fil_hidden_radio->get_active()) {
862 plugin_model->erase(i);
864 /* if no longer a favorite, remove it from the view */
865 if (stat != PluginManager::Favorite && _fil_favorites_radio->get_active()) {
866 plugin_model->erase(i);
875 PluginSelector::on_show ()
877 ArdourDialog::on_show ();
878 search_entry.grab_focus ();
882 _need_tag_save = false;
883 _need_status_save = false;
886 struct PluginMenuCompareByCreator {
887 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
890 cmp = cmp_nocase_utf8 (a->creator, b->creator);
894 } else if (cmp == 0) {
895 /* same creator ... compare names */
896 if (cmp_nocase_utf8 (a->name, b->name) < 0) {
904 struct PluginMenuCompareByName {
905 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
908 cmp = cmp_nocase_utf8 (a->name, b->name);
912 } else if (cmp == 0) {
913 /* same name ... compare type */
914 if (a->type < b->type) {
922 /** @return Plugin menu. The caller should not delete it */
924 PluginSelector::plugin_menu()
930 PluginSelector::build_plugin_menu ()
932 PluginInfoList all_plugs;
934 all_plugs.insert (all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
935 all_plugs.insert (all_plugs.end(), manager.lua_plugin_info().begin(), manager.lua_plugin_info().end());
936 #ifdef WINDOWS_VST_SUPPORT
937 all_plugs.insert (all_plugs.end(), manager.windows_vst_plugin_info().begin(), manager.windows_vst_plugin_info().end());
940 all_plugs.insert (all_plugs.end(), manager.lxvst_plugin_info().begin(), manager.lxvst_plugin_info().end());
942 #ifdef MACVST_SUPPORT
943 all_plugs.insert (all_plugs.end(), manager.mac_vst_plugin_info().begin(), manager.mac_vst_plugin_info().end());
945 #ifdef AUDIOUNIT_SUPPORT
946 all_plugs.insert (all_plugs.end(), manager.au_plugin_info().begin(), manager.au_plugin_info().end());
949 all_plugs.insert (all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end());
952 using namespace Menu_Helpers;
956 _plugin_menu = new Menu;
957 _plugin_menu->set_name("ArdourContextMenu");
959 MenuList& items = _plugin_menu->items();
962 Gtk::Menu* favs = create_favs_menu(all_plugs);
963 items.push_back (MenuElem (_("Favorites"), *manage (favs)));
965 items.push_back (MenuElem (_("Plugin Manager..."), sigc::mem_fun (*this, &PluginSelector::show_manager)));
966 items.push_back (SeparatorElem ());
968 Menu* by_creator = create_by_creator_menu(all_plugs);
969 items.push_back (MenuElem (_("By Creator"), *manage (by_creator)));
971 Menu* by_tags = create_by_tags_menu(all_plugs);
972 items.push_back (MenuElem (_("By Tags"), *manage (by_tags)));
976 GetPluginTypeStr(PluginInfoPtr info)
980 switch (info->type) {
982 type = X_(" (LADSPA)");
1004 PluginSelector::create_favs_menu (PluginInfoList& all_plugs)
1006 using namespace Menu_Helpers;
1008 Menu* favs = new Menu();
1009 favs->set_name("ArdourContextMenu");
1011 PluginMenuCompareByName cmp_by_name;
1012 all_plugs.sort (cmp_by_name);
1014 for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1015 if (manager.get_status (*i) == PluginManager::Favorite) {
1016 string typ = GetPluginTypeStr(*i);
1017 MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1018 elem.get_child()->set_use_underline (false);
1019 favs->items().push_back (elem);
1026 PluginSelector::create_by_creator_menu (ARDOUR::PluginInfoList& all_plugs)
1028 _inhibit_refill = true;
1029 _fil_creator_combo.clear_items ();
1030 _fil_creator_combo.append_text_item (_("Show All Creators"));
1031 _fil_creator_combo.set_text (_("Show All Creators"));
1032 _inhibit_refill = false;
1034 using namespace Menu_Helpers;
1036 typedef std::map<std::string,Gtk::Menu*> SubmenuMap;
1037 SubmenuMap creator_submenu_map;
1039 Menu* by_creator = new Menu();
1040 by_creator->set_name("ArdourContextMenu");
1042 MenuList& by_creator_items = by_creator->items();
1043 PluginMenuCompareByCreator cmp_by_creator;
1044 all_plugs.sort (cmp_by_creator);
1046 for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1048 if (manager.get_status (*i) == PluginManager::Hidden) continue;
1050 string creator = (*i)->creator;
1052 /* If there were too few characters to create a
1053 * meaningful name, mark this creator as 'Unknown'
1055 if (creator.length() < 2) {
1056 creator = "Unknown";
1059 SubmenuMap::iterator x;
1061 if ((x = creator_submenu_map.find (creator)) != creator_submenu_map.end()) {
1062 submenu = x->second;
1065 _fil_creator_combo.append_text_item (creator);
1067 submenu = new Gtk::Menu;
1068 by_creator_items.push_back (MenuElem (creator, *manage (submenu)));
1069 creator_submenu_map.insert (pair<std::string,Menu*> (creator, submenu));
1070 submenu->set_name("ArdourContextMenu");
1072 string typ = GetPluginTypeStr(*i);
1073 MenuElem elem ((*i)->name+typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1074 elem.get_child()->set_use_underline (false);
1075 submenu->items().push_back (elem);
1082 PluginSelector::create_by_tags_menu (ARDOUR::PluginInfoList& all_plugs)
1084 using namespace Menu_Helpers;
1086 typedef std::map<std::string,Gtk::Menu*> SubmenuMap;
1087 SubmenuMap tags_submenu_map;
1089 Menu* by_tags = new Menu();
1090 by_tags->set_name("ArdourContextMenu");
1091 MenuList& by_tags_items = by_tags->items();
1093 std::vector<std::string> all_tags = manager.get_all_tags (PluginManager::NoHidden);
1094 for (vector<string>::iterator t = all_tags.begin(); t != all_tags.end(); ++t) {
1095 Gtk::Menu *submenu = new Gtk::Menu;
1096 by_tags_items.push_back (MenuElem (*t, *manage (submenu)));
1097 tags_submenu_map.insert (pair<std::string,Menu*> (*t, submenu));
1098 submenu->set_name("ArdourContextMenu");
1101 PluginMenuCompareByName cmp_by_name;
1102 all_plugs.sort (cmp_by_name);
1104 for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1106 if (manager.get_status (*i) == PluginManager::Hidden) continue;
1108 /* for each tag in the plugins tag list, add it to that submenu */
1109 vector<string> tokens = manager.get_tags(*i);
1110 for (vector<string>::iterator t = tokens.begin(); t != tokens.end(); ++t) {
1111 SubmenuMap::iterator x;
1113 if ((x = tags_submenu_map.find (*t)) != tags_submenu_map.end()) {
1114 submenu = x->second;
1115 string typ = GetPluginTypeStr(*i);
1116 MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1117 elem.get_child()->set_use_underline (false);
1118 submenu->items().push_back (elem);
1126 PluginSelector::plugin_chosen_from_menu (const PluginInfoPtr& pi)
1128 PluginPtr p = load_plugin (pi);
1130 if (p && interested_object) {
1131 SelectedPlugins plugins;
1132 plugins.push_back (p);
1133 interested_object->use_plugins (plugins);
1136 interested_object = 0;
1140 PluginSelector::favorite_changed (const std::string& path)
1144 if (in_row_change) {
1148 in_row_change = true;
1150 TreeModel::iterator iter = plugin_model->get_iter (path);
1154 bool favorite = !(*iter)[plugin_columns.favorite];
1158 PluginManager::PluginStatusType status = (favorite ? PluginManager::Favorite : PluginManager::Normal);
1160 /* save new statuses list */
1162 pi = (*iter)[plugin_columns.plugin];
1164 manager.set_status (pi->type, pi->unique_id, status);
1166 _need_status_save = true;
1168 in_row_change = false;
1172 PluginSelector::hidden_changed (const std::string& path)
1176 if (in_row_change) {
1180 in_row_change = true;
1182 TreeModel::iterator iter = plugin_model->get_iter (path);
1186 bool hidden = !(*iter)[plugin_columns.hidden];
1190 PluginManager::PluginStatusType status = (hidden ? PluginManager::Hidden : PluginManager::Normal);
1192 /* save new statuses list */
1194 pi = (*iter)[plugin_columns.plugin];
1196 manager.set_status (pi->type, pi->unique_id, status);
1198 _need_status_save = true;
1200 in_row_change = false;
1204 PluginSelector::show_manager ()
1211 PluginSelector::set_interested_object (PluginInterestedObject& obj)
1213 interested_object = &obj;