Plugin GUI activate/enable update (prefer enable)
[ardour.git] / gtk2_ardour / instrument_selector.cc
index 5dfa0918971db6e63dbbed2368e76aa58693e662..d4f89e2f63ec7fb125e198f4745d4d55d737969c 100644 (file)
@@ -17,7 +17,7 @@
 */
 
 #include "ardour/plugin_manager.h"
-
+#include "gtkmm2ext/gui_thread.h"
 #include "instrument_selector.h"
 
 #include "i18n.h"
@@ -28,10 +28,39 @@ using namespace ARDOUR;
 InstrumentSelector::InstrumentSelector()
        : _reasonable_synth_id(0)
 {
+       refill ();
+
+       PluginManager::instance ().PluginListChanged.connect (_update_connection, invalidator (*this), boost::bind (&InstrumentSelector::refill, this), gui_context());
+}
+
+void
+InstrumentSelector::refill()
+{
+       TreeModel::iterator iter = get_active();
+       std::string selected;
+       if (iter) {
+               const TreeModel::Row& row = (*iter);
+               selected = row[_instrument_list_columns.name];
+       }
+
+       unset_model ();
+       clear ();
        build_instrument_list();
        set_model(_instrument_list);
        pack_start(_instrument_list_columns.name);
-       set_active(_reasonable_synth_id);
+       if (selected.empty ()) {
+               set_active(_reasonable_synth_id);
+       } else {
+               TreeModel::Children rows = _instrument_list->children();
+               TreeModel::Children::iterator i;
+               for (i = rows.begin(); i != rows.end(); ++i) {
+                       std::string cn = (*i)[_instrument_list_columns.name];
+                       if (cn == selected) {
+                               set_active(*i);
+                               break;
+                       }
+               }
+       }
        set_button_sensitivity(Gtk::SENSITIVITY_AUTO);
 }
 
@@ -42,6 +71,7 @@ InstrumentSelector::build_instrument_list()
 
        PluginInfoList all_plugs;
        all_plugs.insert(all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
+       all_plugs.insert(all_plugs.end(), manager.lua_plugin_info().begin(), manager.lua_plugin_info().end());
 #ifdef WINDOWS_VST_SUPPORT
        all_plugs.insert(all_plugs.end(), manager.windows_vst_plugin_info().begin(), manager.windows_vst_plugin_info().end());
 #endif