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>
36 #include "gtkmm2ext/utils.h"
38 #include "widgets/tooltips.h"
40 #include "pbd/convert.h"
41 #include "pbd/tokenizer.h"
43 #include "ardour/utils.h"
45 #include "plugin_selector.h"
46 #include "gui_thread.h"
47 #include "ui_config.h"
51 using namespace ARDOUR;
55 using namespace ArdourWidgets;
57 static const uint32_t MAX_CREATOR_LEN = 24;
59 PluginSelector::PluginSelector (PluginManager& mgr)
60 : ArdourDialog (_("Plugin Manager"), true, false)
61 , search_clear_button (Stock::CLEAR)
63 , inhibit_refill (false)
65 set_name ("PluginSelectorWindow");
66 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
69 in_row_change = false;
71 manager.PluginListChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::build_plugin_menu, this), gui_context());
72 manager.PluginListChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::refill, this), gui_context());
73 manager.PluginStatusesChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::plugin_status_changed, this, _1, _2, _3), gui_context());
74 manager.PluginTagsChanged.connect(plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::tags_changed, this, _1, _2, _3), gui_context());
76 plugin_model = Gtk::ListStore::create (plugin_columns);
77 plugin_display.set_model (plugin_model);
78 /* XXX translators: try to convert "Fav" into a short term
79 * related to "favorite" and "Hid" into a short term
82 plugin_display.append_column (_("Fav"), plugin_columns.favorite);
83 plugin_display.append_column (_("Hide"), plugin_columns.hidden);
84 plugin_display.append_column (_("Name"), plugin_columns.name);
85 plugin_display.append_column (_("Tags"), plugin_columns.tags);
86 plugin_display.append_column (_("Creator"), plugin_columns.creator);
87 plugin_display.append_column (_("Type"), plugin_columns.type_name);
88 plugin_display.append_column (_("Audio I/O"),plugin_columns.audio_io);
89 plugin_display.append_column (_("MIDI I/O"), plugin_columns.midi_io);
90 plugin_display.set_headers_visible (true);
91 plugin_display.set_headers_clickable (true);
92 plugin_display.set_reorderable (false);
93 plugin_display.set_rules_hint (true);
94 plugin_display.add_object_drag (plugin_columns.plugin.index(), "PluginInfoPtr");
95 plugin_display.set_drag_column (plugin_columns.name.index());
97 // setting a sort-column prevents re-ordering via Drag/Drop
98 plugin_model->set_sort_column (plugin_columns.name.index(), Gtk::SORT_ASCENDING);
100 plugin_display.set_name("PluginSelectorDisplay");
101 plugin_display.signal_row_activated().connect_notify (sigc::mem_fun(*this, &PluginSelector::row_activated));
102 plugin_display.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &PluginSelector::display_selection_changed));
104 CellRendererToggle* fav_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (0));
105 fav_cell->property_activatable() = true;
106 fav_cell->property_radio() = true;
107 fav_cell->signal_toggled().connect (sigc::mem_fun (*this, &PluginSelector::favorite_changed));
109 CellRendererToggle* hidden_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (1));
110 hidden_cell->property_activatable() = true;
111 hidden_cell->property_radio() = true;
112 hidden_cell->signal_toggled().connect (sigc::mem_fun (*this, &PluginSelector::hidden_changed));
114 scroller.set_border_width(10);
115 scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
116 scroller.add(plugin_display);
118 amodel = Gtk::ListStore::create(acols);
119 added_list.set_model (amodel);
120 added_list.append_column (_("Plugins to be connected"), acols.text);
121 added_list.set_headers_visible (true);
122 added_list.set_reorderable (false);
124 for (int i = 2; i <= 7; ++i) {
125 Gtk::TreeView::Column* column = plugin_display.get_column(i);
127 column->set_sort_column(i);
131 ascroller.set_border_width(10);
132 ascroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
133 ascroller.add(added_list);
134 btn_add = manage(new Gtk::Button(Stock::ADD));
135 set_tooltip(*btn_add, _("Add a plugin to the effect list"));
136 btn_add->set_sensitive (false);
137 btn_remove = manage(new Gtk::Button(Stock::REMOVE));
138 btn_remove->set_sensitive (false);
139 set_tooltip(*btn_remove, _("Remove a plugin from the effect list"));
141 btn_add->set_name("PluginSelectorButton");
142 btn_remove->set_name("PluginSelectorButton");
146 Gtk::Table* search_table = manage(new Gtk::Table(2, 2));
148 search_entry.signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::search_entry_changed));
149 search_clear_button.signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::search_clear_button_clicked));
151 _search_name_checkbox = manage (new ArdourButton (_("Name"), ArdourButton::led_default_elements, true));
152 _search_name_checkbox->set_active(true);
153 _search_name_checkbox->set_name ("pluginlist filter button");
155 _search_tags_checkbox = manage (new ArdourButton (_("Tags"), ArdourButton::led_default_elements, true));
156 _search_tags_checkbox->set_active(true);
157 _search_tags_checkbox->set_name ("pluginlist filter button");
159 _search_ignore_checkbox = manage (new ArdourButton(_("Ignore Filters when searching"), ArdourButton::led_default_elements, true));
160 _search_ignore_checkbox->set_active(true);
161 _search_ignore_checkbox->set_name ("pluginlist filter button");
163 Gtk::Label* search_help_label1 = manage (new Label(
164 _("All search terms must be matched."), Gtk::ALIGN_LEFT));
166 Gtk::Label* search_help_label2 = manage (new Label(
167 _("Ex: \"ess dyn\" will find \"dynamic de-esser\" but not \"de-esser\"."), Gtk::ALIGN_LEFT));
169 search_table->attach (search_entry, 0, 3, 0, 1, FILL|EXPAND, FILL);
170 search_table->attach (search_clear_button, 3, 4, 0, 1, FILL, FILL);
171 search_table->attach (*_search_name_checkbox, 0, 1, 1, 2, FILL, FILL);
172 search_table->attach (*_search_tags_checkbox, 1, 2, 1, 2, FILL, FILL);
173 search_table->attach (*_search_ignore_checkbox,2, 3, 1, 2, FILL, FILL);
174 search_table->attach (*search_help_label1, 0, 3, 2, 3, FILL, FILL);
175 search_table->attach (*search_help_label2, 0, 3, 3, 4, FILL, FILL);
177 search_table->set_border_width (4);
178 search_table->set_col_spacings (4);
179 search_table->set_row_spacings (4);
181 Frame* search_frame = manage (new Frame);
182 search_frame->set_name ("BaseFrame");
183 search_frame->set_label (_("Search"));
184 search_frame->add (*search_table);
185 search_frame->show_all ();
187 _search_name_checkbox->signal_clicked.connect (sigc::mem_fun (*this, &PluginSelector::refill));
188 _search_tags_checkbox->signal_clicked.connect (sigc::mem_fun (*this, &PluginSelector::refill));
189 _search_ignore_checkbox->signal_clicked.connect (sigc::mem_fun (*this, &PluginSelector::set_sensitive_widgets));
193 Gtk::RadioButtonGroup fil_radio_group;
195 _fil_effects_radio = manage (new RadioButton (fil_radio_group, _("Show Effects Only")));
196 _fil_instruments_radio = manage (new RadioButton (fil_radio_group, _("Show Instruments Only")));
197 _fil_utils_radio = manage (new RadioButton (fil_radio_group, _("Show Utilities Only")));
198 _fil_favorites_radio = manage (new RadioButton (fil_radio_group, _("Show Favorites Only")));
199 _fil_hidden_radio = manage (new RadioButton (fil_radio_group, _("Show Hidden Only")));
200 _fil_all_radio = manage (new RadioButton (fil_radio_group, _("Show All")));
202 //_fil_type_combo = manage (new ComboBoxText);
203 _fil_type_combo.append_text_item (_("Show All Formats"));
204 _fil_type_combo.append_text_item (X_("VST"));
205 #ifdef AUDIOUNIT_SUPPORT
206 _fil_type_combo.append_text_item (X_("AudioUnit"));
209 _fil_type_combo.append_text_item (X_("LV2"));
211 _fil_type_combo.append_text_item (X_("LUA"));
212 _fil_type_combo.append_text_item (X_("LADSPA"));
213 _fil_type_combo.set_text (_("Show All Formats"));
215 /* note: _fil_creator_combo menu gets filled in build_plugin_menu */
216 _fil_creator_combo.set_text_ellipsize (Pango::ELLIPSIZE_END);
217 _fil_creator_combo.set_layout_ellipsize_width (PANGO_SCALE * 160 * UIConfiguration::instance ().get_ui_scale ());
219 _fil_channel_combo.append_text_item (_("Audio I/O"));
220 _fil_channel_combo.append_text_item (_("Mono Audio I/O"));
221 _fil_channel_combo.append_text_item (_("Stereo Audio I/O"));
222 _fil_channel_combo.append_text_item (_("MIDI I/O (only)"));
223 _fil_channel_combo.append_text_item (_("Show All I/O"));
225 _fil_channel_combo.set_text (_("Audio I/O"));
227 _fil_channel_combo.set_text (_("Show All I/O"));
230 VBox* filter_vbox = manage (new VBox);
231 filter_vbox->pack_start (*_fil_effects_radio, false, false);
232 filter_vbox->pack_start (*_fil_instruments_radio, false, false);
233 filter_vbox->pack_start (*_fil_utils_radio, false, false);
234 filter_vbox->pack_start (*_fil_favorites_radio, false, false);
235 filter_vbox->pack_start (*_fil_hidden_radio, false, false);
236 filter_vbox->pack_start (*_fil_all_radio, false, false);
237 filter_vbox->pack_start (_fil_type_combo, false, false);
238 filter_vbox->pack_start (_fil_creator_combo, false, false);
239 filter_vbox->pack_start (_fil_channel_combo, false, false);
241 filter_vbox->set_border_width (4);
242 filter_vbox->set_spacing (4);
244 Frame* filter_frame = manage (new Frame);
245 filter_frame->set_name ("BaseFrame");
246 filter_frame->set_label (_("Filter"));
247 filter_frame->add (*filter_vbox);
248 filter_frame->show_all ();
250 _fil_effects_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
251 _fil_instruments_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
252 _fil_utils_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
253 _fil_favorites_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
254 _fil_hidden_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
256 _fil_type_combo.StateChanged.connect (sigc::mem_fun (*this, &PluginSelector::refill));
257 _fil_creator_combo.StateChanged.connect (sigc::mem_fun (*this, &PluginSelector::refill));
258 _fil_channel_combo.StateChanged.connect (sigc::mem_fun (*this, &PluginSelector::refill));
262 Gtk::Table* tagging_table = manage(new Gtk::Table(1, 2));
263 tagging_table->set_border_width (4);
264 tagging_table->set_col_spacings (4);
265 tagging_table->set_row_spacings (4);
267 tag_entry = manage (new Gtk::Entry);
268 tag_entry_connection = tag_entry->signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::tag_entry_changed));
270 tag_reset_button = manage (new Button (_("Reset")));
271 tag_reset_button->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::tag_reset_button_clicked));
273 Gtk::Label* tagging_help_label1 = manage (new Label(
274 _("Enter space-separated, one-word Tags for the selected plugin."), Gtk::ALIGN_LEFT));
276 Gtk::Label* tagging_help_label2 = manage (new Label(
277 _("You can include dashes, colons or underscores in a Tag."), Gtk::ALIGN_LEFT));
279 Gtk::Label* tagging_help_label3 = manage (new Label(
280 _("Ex: \"dynamic de-esser vocal\" applies 3 Tags."), Gtk::ALIGN_LEFT));
283 tagging_table->attach (*tag_entry, 0, 1, p, p+1, FILL|EXPAND, FILL);
284 tagging_table->attach (*tag_reset_button, 1, 2, p, p+1, FILL, FILL); p++;
285 tagging_table->attach (*tagging_help_label1, 0, 2, p, p+1, FILL, FILL); p++;
286 tagging_table->attach (*tagging_help_label2, 0, 2, p, p+1, FILL, FILL); p++;
287 tagging_table->attach (*tagging_help_label3, 0, 2, p, p+1, FILL, FILL); p++;
289 Frame* tag_frame = manage (new Frame);
290 tag_frame->set_name ("BaseFrame");
291 tag_frame->set_label (_("Tags for Selected Plugin"));
292 tag_frame->add (*tagging_table);
293 tag_frame->show_all ();
295 /* Add & remove buttons */
297 HBox* add_remove = manage (new HBox);
298 add_remove->pack_start (*btn_add, true, true);
299 add_remove->pack_start (*btn_remove, true, true);
301 btn_add->signal_clicked().connect(sigc::mem_fun(*this, &PluginSelector::btn_add_clicked));
302 btn_remove->signal_clicked().connect(sigc::mem_fun(*this, &PluginSelector::btn_remove_clicked));
303 added_list.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &PluginSelector::added_list_selection_changed));
304 added_list.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::added_row_clicked));
306 added_list.set_name("PluginSelectorList");
308 /* Top-level Layout */
310 VBox* to_be_inserted_vbox = manage (new VBox);
311 to_be_inserted_vbox->pack_start (ascroller);
312 to_be_inserted_vbox->pack_start (*add_remove, false, false);
313 to_be_inserted_vbox->set_size_request (200, -1);
315 Gtk::Table* table = manage(new Gtk::Table(3, 3));
316 table->set_size_request(-1, 600);
317 table->attach (scroller, 0, 3, 0, 5); /* this is the main plugin list */
318 table->attach (*search_frame, 0, 1, 6, 7, FILL, FILL, 5, 5);
319 table->attach (*tag_frame, 0, 1, 7, 8, FILL, FILL, 5, 5);
320 table->attach (*filter_frame, 1, 2, 6, 8, FILL, FILL, 5, 5);
321 table->attach (*to_be_inserted_vbox, 2, 3, 6, 8, FILL|EXPAND, FILL, 5, 5); /* to be inserted... */
323 add_button (Stock::CLOSE, RESPONSE_CLOSE);
324 add_button (_("Insert Plugin(s)"), RESPONSE_APPLY);
325 set_default_response (RESPONSE_APPLY);
326 set_response_sensitive (RESPONSE_APPLY, false);
327 get_vbox()->pack_start (*table);
329 table->set_name("PluginSelectorTable");
331 plugin_display.grab_focus();
333 build_plugin_menu ();
334 display_selection_changed ();
337 PluginSelector::~PluginSelector ()
343 PluginSelector::row_activated(Gtk::TreeModel::Path, Gtk::TreeViewColumn*)
349 PluginSelector::added_row_clicked(GdkEventButton* event)
351 if (event->type == GDK_2BUTTON_PRESS)
352 btn_remove_clicked();
356 PluginSelector::show_this_plugin (const PluginInfoPtr& info, const std::string& searchstr)
359 bool maybe_show = false;
361 if (!searchstr.empty()) {
365 if (_search_name_checkbox->get_active()) { /* name contains */
366 compstr = info->name;
367 transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
368 if (compstr.find (searchstr) != string::npos) {
373 if (_search_tags_checkbox->get_active()) { /* tag contains */
374 compstr = manager.get_tags_as_string (info);
375 transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
376 if (compstr.find (searchstr) != string::npos) {
385 /* user asked to ignore filters */
386 if (maybe_show && _search_ignore_checkbox->get_active()) {
391 if (_fil_effects_radio->get_active() && !info->is_effect()) {
395 if (_fil_instruments_radio->get_active() && !info->is_instrument()) {
399 if (_fil_utils_radio->get_active() && !(info->is_utility() || info->is_analyzer())) {
403 if (_fil_favorites_radio->get_active() && !(manager.get_status (info) == PluginManager::Favorite)) {
407 if (_fil_hidden_radio->get_active() && !(manager.get_status (info) == PluginManager::Hidden)) {
411 if (manager.get_status (info) == PluginManager::Hidden) {
412 if (!_fil_hidden_radio->get_active() && !_fil_all_radio->get_active()) {
417 /* Filter "type" combobox */
419 if (_fil_type_combo.get_text() == X_("VST") && PluginManager::to_generic_vst(info->type) != LXVST) {
423 if (_fil_type_combo.get_text() == X_("AudioUnit") && info->type != AudioUnit) {
428 if (_fil_type_combo.get_text() == X_("LV2") && info->type != LV2) {
433 if (_fil_type_combo.get_text() == X_("LUA") && info->type != Lua) {
437 if (_fil_type_combo.get_text() == X_("LADSPA") && info->type != LADSPA) {
441 /* Filter "creator" combobox */
443 if (_fil_creator_combo.get_text() != _("Show All Creators")) {
444 if (_fil_creator_combo.get_text() != info->creator) {
449 /* Filter "I/O" combobox */
451 if (_fil_channel_combo.get_text() != _("Show All I/O") || info->reconfigurable_io ()) {
454 if (info->reconfigurable_io ()) {
455 return true; // who knows.... ?
459 if (_fil_channel_combo.get_text() == _("Audio I/O")) {
460 if ((info->n_inputs.n_audio() == 0 || info->n_outputs.n_audio() == 0)) {
465 if (_fil_channel_combo.get_text() == _("Mono Audio I/O")) {
466 if (info->n_inputs.n_audio() != 1 || info->n_outputs.n_audio() != 1) {
471 if (_fil_channel_combo.get_text() == _("Stereo Audio I/O")) {
472 if (info->n_inputs.n_audio() != 2 || info->n_outputs.n_audio() != 2) {
477 if (_fil_channel_combo.get_text() == _("MIDI I/O (only)")) {
478 if ((info->n_inputs.n_audio() != 0 || info->n_outputs.n_audio() == 0)) {
489 PluginSelector::setup_search_string (string& searchstr)
491 searchstr = search_entry.get_text ();
492 transform (searchstr.begin(), searchstr.end(), searchstr.begin(), ::toupper);
496 PluginSelector::set_sensitive_widgets ()
498 if (_search_ignore_checkbox->get_active() && !search_entry.get_text().empty()) {
499 _fil_effects_radio->set_sensitive(false);
500 _fil_instruments_radio->set_sensitive(false);
501 _fil_utils_radio->set_sensitive(false);
502 _fil_favorites_radio->set_sensitive(false);
503 _fil_hidden_radio->set_sensitive(false);
504 _fil_all_radio->set_sensitive(false);
505 _fil_type_combo.set_sensitive(false);
506 _fil_creator_combo.set_sensitive(false);
507 _fil_channel_combo.set_sensitive(false);
509 _fil_effects_radio->set_sensitive(true);
510 _fil_instruments_radio->set_sensitive(true);
511 _fil_utils_radio->set_sensitive(true);
512 _fil_favorites_radio->set_sensitive(true);
513 _fil_hidden_radio->set_sensitive(true);
514 _fil_all_radio->set_sensitive(true);
515 _fil_type_combo.set_sensitive(true);
516 _fil_creator_combo.set_sensitive(true);
517 _fil_channel_combo.set_sensitive(true);
519 if (!search_entry.get_text().empty()) {
525 PluginSelector::refill ()
527 if (inhibit_refill) {
531 std::string searchstr;
533 in_row_change = true;
535 plugin_model->clear ();
537 setup_search_string (searchstr);
539 ladspa_refiller (searchstr);
540 lv2_refiller (searchstr);
541 vst_refiller (searchstr);
542 lxvst_refiller (searchstr);
543 mac_vst_refiller (searchstr);
544 au_refiller (searchstr);
545 lua_refiller (searchstr);
547 in_row_change = false;
551 PluginSelector::refiller (const PluginInfoList& plugs, const::std::string& searchstr, const char* type)
555 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
557 if (show_this_plugin (*i, searchstr)) {
559 TreeModel::Row newrow = *(plugin_model->append());
560 newrow[plugin_columns.favorite] = (manager.get_status (*i) == PluginManager::Favorite);
561 newrow[plugin_columns.hidden] = (manager.get_status (*i) == PluginManager::Hidden);
563 string name = (*i)->name;
564 if (name.length() > 48) {
565 name = name.substr (0, 48);
568 newrow[plugin_columns.name] = name;
570 newrow[plugin_columns.type_name] = type;
573 string creator = (*i)->creator;
574 string::size_type pos = 0;
575 if ((*i)->type == ARDOUR::LADSPA) {
576 /* stupid LADSPA creator strings */
577 #ifdef PLATFORM_WINDOWS
578 while (pos < creator.length() && creator[pos] > -2 && creator[pos] < 256 && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
580 while (pos < creator.length() && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
583 pos = creator.length ();
585 // If there were too few characters to create a
586 // meaningful name, mark this creator as 'Unknown'
587 if (creator.length() < 2 || pos < 3) {
590 creator = creator.substr (0, pos);
593 if (creator.length() > MAX_CREATOR_LEN) {
594 creator = creator.substr (0, MAX_CREATOR_LEN);
595 creator.append("...");
597 newrow[plugin_columns.creator] = creator;
600 string tags = manager.get_tags_as_string(*i);
601 if (tags.length() > 32) {
602 tags = tags.substr (0, 32);
605 newrow[plugin_columns.tags] = tags;
607 if ((*i)->reconfigurable_io ()) {
608 newrow[plugin_columns.audio_io] = "* / *";
609 newrow[plugin_columns.midi_io] = "* / *";
611 snprintf (buf, sizeof(buf), "%d / %d", (*i)->n_inputs.n_audio(), (*i)->n_outputs.n_audio());
612 newrow[plugin_columns.audio_io] = buf;
613 snprintf (buf, sizeof(buf), "%d / %d", (*i)->n_inputs.n_audio(), (*i)->n_outputs.n_audio());
614 newrow[plugin_columns.midi_io] = buf;
617 newrow[plugin_columns.plugin] = *i;
623 PluginSelector::ladspa_refiller (const std::string& searchstr)
625 refiller (manager.ladspa_plugin_info(), searchstr, "LADSPA");
629 PluginSelector::lua_refiller (const std::string& searchstr)
631 refiller (manager.lua_plugin_info(), searchstr, "Lua");
635 PluginSelector::lv2_refiller (const std::string& searchstr)
638 refiller (manager.lv2_plugin_info(), searchstr, "LV2");
643 #ifdef WINDOWS_VST_SUPPORT
644 PluginSelector::vst_refiller (const std::string& searchstr)
646 PluginSelector::vst_refiller (const std::string&)
649 #ifdef WINDOWS_VST_SUPPORT
650 refiller (manager.windows_vst_plugin_info(), searchstr, "VST");
656 PluginSelector::lxvst_refiller (const std::string& searchstr)
658 PluginSelector::lxvst_refiller (const std::string&)
662 refiller (manager.lxvst_plugin_info(), searchstr, "LXVST");
667 #ifdef MACVST_SUPPORT
668 PluginSelector::mac_vst_refiller (const std::string& searchstr)
670 PluginSelector::mac_vst_refiller (const std::string&)
673 #ifdef MACVST_SUPPORT
674 refiller (manager.mac_vst_plugin_info(), searchstr, "MacVST");
679 #ifdef AUDIOUNIT_SUPPORT
680 PluginSelector::au_refiller (const std::string& searchstr)
682 PluginSelector::au_refiller (const std::string&)
685 #ifdef AUDIOUNIT_SUPPORT
686 refiller (manager.au_plugin_info(), searchstr, "AU");
691 PluginSelector::load_plugin (PluginInfoPtr pi)
697 return pi->load (*_session);
701 PluginSelector::btn_add_clicked()
703 if (plugin_display.get_selection()->count_selected_rows() == 0) {
704 /* may happen with ctrl + double-click un-selecting but activating a row */
709 TreeModel::Row newrow = *(amodel->append());
712 row = *(plugin_display.get_selection()->get_selected());
713 name = row[plugin_columns.name];
714 pi = row[plugin_columns.plugin];
716 newrow[acols.text] = name;
717 newrow[acols.plugin] = pi;
719 if (!amodel->children().empty()) {
720 set_response_sensitive (RESPONSE_APPLY, true);
725 PluginSelector::btn_remove_clicked()
727 TreeModel::iterator iter = added_list.get_selection()->get_selected();
730 if (amodel->children().empty()) {
731 set_response_sensitive (RESPONSE_APPLY, false);
736 PluginSelector::display_selection_changed()
738 tag_entry_connection.block ();
739 if (plugin_display.get_selection()->count_selected_rows() != 0) {
741 /* a plugin row is selected; allow the user to edit the "tags" on it. */
742 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
743 string tags = manager.get_tags_as_string (row[plugin_columns.plugin]);
744 tag_entry->set_text (tags);
746 tag_entry->set_sensitive (true);
747 tag_reset_button->set_sensitive (true);
748 btn_add->set_sensitive (true);
751 tag_entry->set_text ("");
753 tag_entry->set_sensitive (false);
754 tag_reset_button->set_sensitive (false);
755 btn_add->set_sensitive (false);
757 tag_entry_connection.unblock ();
761 PluginSelector::added_list_selection_changed()
763 if (added_list.get_selection()->count_selected_rows() != 0) {
764 btn_remove->set_sensitive (true);
766 btn_remove->set_sensitive (false);
771 PluginSelector::run ()
774 TreeModel::Children::iterator i;
780 SelectedPlugins plugins;
781 r = (ResponseType) Dialog::run ();
785 for (i = amodel->children().begin(); i != amodel->children().end(); ++i) {
786 PluginInfoPtr pp = (*i)[acols.plugin];
787 PluginPtr p = load_plugin (pp);
789 plugins.push_back (p);
791 MessageDialog msg (string_compose (_("The plugin \"%1\" could not be loaded\n\nSee the Log window for more details (maybe)"), pp->name));
795 if (interested_object && !plugins.empty()) {
796 finish = !interested_object->use_plugins (plugins);
810 interested_object = 0;
812 if (_need_tag_save) {
816 if (_need_status_save) {
817 manager.save_statuses();
820 if (_need_menu_rebuild) {
828 PluginSelector::search_clear_button_clicked ()
830 search_entry.set_text ("");
834 PluginSelector::tag_reset_button_clicked ()
836 if (plugin_display.get_selection()->count_selected_rows() != 0) {
837 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
838 ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin];
839 manager.reset_tags (pi);
840 display_selection_changed ();
841 _need_tag_save = true;
846 PluginSelector::search_entry_changed ()
848 set_sensitive_widgets();
849 if (search_entry.get_text().empty()) {
855 PluginSelector::tag_entry_changed ()
857 if (plugin_display.get_selection()->count_selected_rows() != 0) {
858 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
860 ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin];
861 manager.set_tags (pi->type, pi->unique_id, tag_entry->get_text(), false);
863 _need_tag_save = true;
868 PluginSelector::tags_changed (PluginType t, std::string unique_id, std::string tags)
870 if (plugin_display.get_selection()->count_selected_rows() != 0) {
871 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
872 if (tags.length() > 32) {
873 tags = tags.substr (0, 32);
876 row[plugin_columns.tags] = tags;
879 /* A plugin's tags change while the user is entering them.
880 * defer a rebuilding of the "tag" menu until the dialog is closed.
882 _need_menu_rebuild = true;
886 PluginSelector::plugin_status_changed (PluginType t, std::string uid, PluginManager::PluginStatusType stat)
888 Gtk::TreeModel::iterator i;
889 for (i = plugin_model->children().begin(); i != plugin_model->children().end(); ++i) {
890 PluginInfoPtr pp = (*i)[plugin_columns.plugin];
891 if ((pp->type == t) && (pp->unique_id == uid)) {
892 (*i)[plugin_columns.favorite] = (stat == PluginManager::Favorite) ? true : false;
893 (*i)[plugin_columns.hidden] = (stat == PluginManager::Hidden) ? true : false;
895 /* if plug was hidden, remove it from the view */
896 if (stat == PluginManager::Hidden) {
897 if (!_fil_hidden_radio->get_active() && !_fil_all_radio->get_active()) {
898 plugin_model->erase(i);
900 } else if (_fil_hidden_radio->get_active()) {
901 plugin_model->erase(i);
903 /* if no longer a favorite, remove it from the view */
904 if (stat != PluginManager::Favorite && _fil_favorites_radio->get_active()) {
905 plugin_model->erase(i);
908 /* plugin menu must be re-built to accommodate Hidden and Favorite plugins */
917 PluginSelector::on_show ()
919 ArdourDialog::on_show ();
920 search_entry.grab_focus ();
924 _need_tag_save = false;
925 _need_status_save = false;
926 _need_menu_rebuild = false;
929 struct PluginMenuCompareByCreator {
930 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
933 cmp = cmp_nocase_utf8 (a->creator, b->creator);
937 } else if (cmp == 0) {
938 /* same creator ... compare names */
939 if (cmp_nocase_utf8 (a->name, b->name) < 0) {
947 struct PluginMenuCompareByName {
948 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
951 cmp = cmp_nocase_utf8 (a->name, b->name);
955 } else if (cmp == 0) {
956 /* same name ... compare type */
957 if (a->type < b->type) {
965 /** @return Plugin menu. The caller should not delete it */
967 PluginSelector::plugin_menu()
973 PluginSelector::build_plugin_menu ()
975 PluginInfoList all_plugs;
977 all_plugs.insert (all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
978 all_plugs.insert (all_plugs.end(), manager.lua_plugin_info().begin(), manager.lua_plugin_info().end());
979 #ifdef WINDOWS_VST_SUPPORT
980 all_plugs.insert (all_plugs.end(), manager.windows_vst_plugin_info().begin(), manager.windows_vst_plugin_info().end());
983 all_plugs.insert (all_plugs.end(), manager.lxvst_plugin_info().begin(), manager.lxvst_plugin_info().end());
985 #ifdef MACVST_SUPPORT
986 all_plugs.insert (all_plugs.end(), manager.mac_vst_plugin_info().begin(), manager.mac_vst_plugin_info().end());
988 #ifdef AUDIOUNIT_SUPPORT
989 all_plugs.insert (all_plugs.end(), manager.au_plugin_info().begin(), manager.au_plugin_info().end());
992 all_plugs.insert (all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end());
995 using namespace Menu_Helpers;
999 _plugin_menu = manage (new Menu);
1000 _plugin_menu->set_name("ArdourContextMenu");
1002 MenuList& items = _plugin_menu->items();
1005 Gtk::Menu* favs = create_favs_menu(all_plugs);
1006 items.push_back (MenuElem (_("Favorites"), *manage (favs)));
1008 items.push_back (MenuElem (_("Plugin Manager..."), sigc::mem_fun (*this, &PluginSelector::show_manager)));
1009 items.push_back (SeparatorElem ());
1011 Menu* by_creator = create_by_creator_menu(all_plugs);
1012 items.push_back (MenuElem (_("By Creator"), *manage (by_creator)));
1014 Menu* by_tags = create_by_tags_menu(all_plugs);
1015 items.push_back (MenuElem (_("By Tags"), *manage (by_tags)));
1019 GetPluginTypeStr(PluginInfoPtr info)
1023 switch (info->type) {
1025 type = X_(" (LADSPA)");
1031 type = X_(" (LV2)");
1036 type = X_(" (VST)");
1039 type = X_(" (Lua)");
1047 PluginSelector::create_favs_menu (PluginInfoList& all_plugs)
1049 using namespace Menu_Helpers;
1051 Menu* favs = new Menu();
1052 favs->set_name("ArdourContextMenu");
1054 PluginMenuCompareByName cmp_by_name;
1055 all_plugs.sort (cmp_by_name);
1057 for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1058 if (manager.get_status (*i) == PluginManager::Favorite) {
1059 string typ = GetPluginTypeStr(*i);
1060 MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1061 elem.get_child()->set_use_underline (false);
1062 favs->items().push_back (elem);
1069 PluginSelector::create_by_creator_menu (ARDOUR::PluginInfoList& all_plugs)
1071 inhibit_refill = true;
1072 _fil_creator_combo.clear_items ();
1073 _fil_creator_combo.append_text_item (_("Show All Creators"));
1074 _fil_creator_combo.set_text (_("Show All Creators"));
1075 inhibit_refill = false;
1077 using namespace Menu_Helpers;
1079 typedef std::map<std::string,Gtk::Menu*> SubmenuMap;
1080 SubmenuMap creator_submenu_map;
1082 Menu* by_creator = new Menu();
1083 by_creator->set_name("ArdourContextMenu");
1085 MenuList& by_creator_items = by_creator->items();
1086 PluginMenuCompareByCreator cmp_by_creator;
1087 all_plugs.sort (cmp_by_creator);
1089 for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1091 if (manager.get_status (*i) == PluginManager::Hidden) continue;
1093 string creator = (*i)->creator;
1095 /* If there were too few characters to create a
1096 * meaningful name, mark this creator as 'Unknown'
1098 if (creator.length() < 2) {
1099 creator = "Unknown";
1102 SubmenuMap::iterator x;
1104 if ((x = creator_submenu_map.find (creator)) != creator_submenu_map.end()) {
1105 submenu = x->second;
1108 _fil_creator_combo.append_text_item (creator);
1110 submenu = new Gtk::Menu;
1111 by_creator_items.push_back (MenuElem (creator, *manage (submenu)));
1112 creator_submenu_map.insert (pair<std::string,Menu*> (creator, submenu));
1113 submenu->set_name("ArdourContextMenu");
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);
1125 PluginSelector::create_by_tags_menu (ARDOUR::PluginInfoList& all_plugs)
1127 using namespace Menu_Helpers;
1129 typedef std::map<std::string,Gtk::Menu*> SubmenuMap;
1130 SubmenuMap tags_submenu_map;
1132 Menu* by_tags = new Menu();
1133 by_tags->set_name("ArdourContextMenu");
1134 MenuList& by_tags_items = by_tags->items();
1136 std::vector<std::string> all_tags = manager.get_all_tags(false);
1137 for (vector<string>::iterator t = all_tags.begin(); t != all_tags.end(); ++t) {
1138 Gtk::Menu *submenu = new Gtk::Menu;
1139 by_tags_items.push_back (MenuElem (*t, *manage (submenu)));
1140 tags_submenu_map.insert (pair<std::string,Menu*> (*t, submenu));
1141 submenu->set_name("ArdourContextMenu");
1144 PluginMenuCompareByName cmp_by_name;
1145 all_plugs.sort (cmp_by_name);
1147 for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1149 if (manager.get_status (*i) == PluginManager::Hidden) continue;
1151 /* for each tag in the plugins tag list, add it to that submenu */
1152 vector<string> tokens = manager.get_tags(*i);
1153 for (vector<string>::iterator t = tokens.begin(); t != tokens.end(); ++t) {
1154 SubmenuMap::iterator x;
1156 if ((x = tags_submenu_map.find (*t)) != tags_submenu_map.end()) {
1157 submenu = x->second;
1160 string typ = GetPluginTypeStr(*i);
1161 MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1162 elem.get_child()->set_use_underline (false);
1163 submenu->items().push_back (elem);
1170 PluginSelector::plugin_chosen_from_menu (const PluginInfoPtr& pi)
1172 PluginPtr p = load_plugin (pi);
1174 if (p && interested_object) {
1175 SelectedPlugins plugins;
1176 plugins.push_back (p);
1177 interested_object->use_plugins (plugins);
1180 interested_object = 0;
1184 PluginSelector::favorite_changed (const std::string& path)
1188 if (in_row_change) {
1192 in_row_change = true;
1194 TreeModel::iterator iter = plugin_model->get_iter (path);
1198 bool favorite = !(*iter)[plugin_columns.favorite];
1202 PluginManager::PluginStatusType status = (favorite ? PluginManager::Favorite : PluginManager::Normal);
1204 /* save new statuses list */
1206 pi = (*iter)[plugin_columns.plugin];
1208 manager.set_status (pi->type, pi->unique_id, status);
1210 _need_status_save = true;
1212 in_row_change = false;
1216 PluginSelector::hidden_changed (const std::string& path)
1220 if (in_row_change) {
1224 in_row_change = true;
1226 TreeModel::iterator iter = plugin_model->get_iter (path);
1230 bool hidden = !(*iter)[plugin_columns.hidden];
1234 PluginManager::PluginStatusType status = (hidden ? PluginManager::Hidden : PluginManager::Normal);
1236 /* save new statuses list */
1238 pi = (*iter)[plugin_columns.plugin];
1240 manager.set_status (pi->type, pi->unique_id, status);
1242 _need_status_save = true;
1244 in_row_change = false;
1248 PluginSelector::show_manager ()
1255 PluginSelector::set_interested_object (PluginInterestedObject& obj)
1257 interested_object = &obj;