From 218b016a80a54db9f2804c258354ba7c39374888 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 18 Apr 2016 19:15:53 +0200 Subject: update instrument list when rescanning plugins --- gtk2_ardour/instrument_selector.cc | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'gtk2_ardour/instrument_selector.cc') diff --git a/gtk2_ardour/instrument_selector.cc b/gtk2_ardour/instrument_selector.cc index 5dfa091897..3df05f9512 100644 --- a/gtk2_ardour/instrument_selector.cc +++ b/gtk2_ardour/instrument_selector.cc @@ -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); } -- cgit v1.2.3