Name new MIDI tracks after instrument plugin

This commit is contained in:
Robin Gareus
2020-09-17 21:05:41 +02:00
parent 824e54f399
commit 6612cdf44a
4 changed files with 27 additions and 3 deletions

View File

@@ -334,6 +334,7 @@ AddRouteDialog::AddRouteDialog ()
channel_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::channel_separator));
route_group_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::route_separator));
route_group_combo.signal_changed ().connect (sigc::mem_fun (*this, &AddRouteDialog::group_changed));
instrument_combo.signal_changed ().connect (sigc::mem_fun (*this, &AddRouteDialog::instrument_changed));
routes_spinner.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
name_template_entry.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
@@ -503,6 +504,16 @@ AddRouteDialog::trk_template_row_selected ()
}
}
void
AddRouteDialog::instrument_changed ()
{
if (name_edited_by_user) {
return;
}
std::string n = instrument_combo.selected_instrument_name ();
name_template_entry.set_text (n.empty () ? _("MIDI") : n);
reset_name_edited ();
}
void
AddRouteDialog::name_template_entry_insertion (Glib::ustring const &,int*)
@@ -590,7 +601,8 @@ AddRouteDialog::maybe_update_name_template_entry ()
name_template_entry.set_text (_("Audio"));
break;
case MidiTrack:
name_template_entry.set_text (_("MIDI"));
/* set name of instrument or _("MIDI") */
instrument_changed ();
break;
case AudioBus:
case MidiBus:

View File

@@ -124,6 +124,7 @@ private:
bool channel_separator (const Glib::RefPtr<Gtk::TreeModel> &m, const Gtk::TreeModel::iterator &i);
bool route_separator (const Glib::RefPtr<Gtk::TreeModel> &m, const Gtk::TreeModel::iterator &i);
void maybe_update_name_template_entry ();
void instrument_changed ();
struct TrackTemplateColumns : public Gtk::TreeModel::ColumnRecord {
TrackTemplateColumns () {

View File

@@ -181,7 +181,7 @@ InstrumentSelector::build_instrument_list()
}
PluginInfoPtr
InstrumentSelector::selected_instrument()
InstrumentSelector::selected_instrument() const
{
TreeModel::iterator iter = get_active();
if (!iter) {
@@ -191,3 +191,13 @@ InstrumentSelector::selected_instrument()
const TreeModel::Row& row = (*iter);
return row[_instrument_list_columns.info_ptr];
}
std::string
InstrumentSelector::selected_instrument_name () const
{
PluginInfoPtr pip = selected_instrument ();
if (!pip) {
return "";
}
return pip->name;
}

View File

@@ -41,7 +41,8 @@ class InstrumentSelector : public Gtk::ComboBox
public:
InstrumentSelector();
ARDOUR::PluginInfoPtr selected_instrument();
ARDOUR::PluginInfoPtr selected_instrument () const;
std::string selected_instrument_name () const;
private:
struct InstrumentListColumns : public Gtk::TreeModel::ColumnRecord {