summaryrefslogtreecommitdiff
path: root/gtk2_ardour/instrument_selector.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-04-18 19:15:53 +0200
committerRobin Gareus <robin@gareus.org>2016-04-18 19:15:53 +0200
commit218b016a80a54db9f2804c258354ba7c39374888 (patch)
treed639401ae602de1d8feb3022171d72d2386b7043 /gtk2_ardour/instrument_selector.cc
parente14b6428c30ea77a463ee3795850f4e0d961dd13 (diff)
update instrument list when rescanning plugins
Diffstat (limited to 'gtk2_ardour/instrument_selector.cc')
-rw-r--r--gtk2_ardour/instrument_selector.cc33
1 files changed, 31 insertions, 2 deletions
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);
}