diff --git a/gtk2_ardour/add_route_dialog.cc b/gtk2_ardour/add_route_dialog.cc index 702e4d49f6..b9b72c9104 100644 --- a/gtk2_ardour/add_route_dialog.cc +++ b/gtk2_ardour/add_route_dialog.cc @@ -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: diff --git a/gtk2_ardour/add_route_dialog.h b/gtk2_ardour/add_route_dialog.h index 298577496b..3b029d361f 100644 --- a/gtk2_ardour/add_route_dialog.h +++ b/gtk2_ardour/add_route_dialog.h @@ -124,6 +124,7 @@ private: bool channel_separator (const Glib::RefPtr &m, const Gtk::TreeModel::iterator &i); bool route_separator (const Glib::RefPtr &m, const Gtk::TreeModel::iterator &i); void maybe_update_name_template_entry (); + void instrument_changed (); struct TrackTemplateColumns : public Gtk::TreeModel::ColumnRecord { TrackTemplateColumns () { diff --git a/gtk2_ardour/instrument_selector.cc b/gtk2_ardour/instrument_selector.cc index 4e3204dc54..e542d7bfd4 100644 --- a/gtk2_ardour/instrument_selector.cc +++ b/gtk2_ardour/instrument_selector.cc @@ -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; +} diff --git a/gtk2_ardour/instrument_selector.h b/gtk2_ardour/instrument_selector.h index c84470f86a..b973ecee7f 100644 --- a/gtk2_ardour/instrument_selector.h +++ b/gtk2_ardour/instrument_selector.h @@ -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 {