update instrument list when rescanning plugins

This commit is contained in:
Robin Gareus 2016-04-18 19:15:53 +02:00
parent e14b6428c3
commit 218b016a80
2 changed files with 35 additions and 2 deletions

View 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);
}

View File

@ -26,6 +26,8 @@
#include <gtkmm/treemodel.h>
#include <gtkmm/liststore.h>
#include "pbd/signals.h"
#include "ardour/plugin.h"
#include "ardour/types.h"
#include "ardour/template_utils.h"
@ -52,10 +54,12 @@ private:
};
void build_instrument_list();
void refill();
Glib::RefPtr<Gtk::ListStore> _instrument_list;
InstrumentListColumns _instrument_list_columns;
uint32_t _reasonable_synth_id;
PBD::ScopedConnection _update_connection;
};
#endif /* __gtk_ardour_instrument_selector_h__ */