+void
+AddRouteDialog::on_show ()
+{
+ refill_channel_setups ();
+ refill_route_groups ();
+
+ Dialog::on_show ();
+}
+
+void
+AddRouteDialog::refill_channel_setups ()
+{
+ ChannelSetup chn;
+
+ route_templates.clear ();
+
+ string channel_current_choice = channel_combo.get_active_text();
+
+ channel_combo_strings.clear ();
+ channel_setups.clear ();
+
+ chn.name = _("Mono");
+ chn.channels = 1;
+ channel_setups.push_back (chn);
+
+ chn.name = _("Stereo");
+ chn.channels = 2;
+ channel_setups.push_back (chn);
+
+ chn.name = "separator";
+ channel_setups.push_back (chn);
+
+ ARDOUR::find_route_templates (route_templates);
+
+ if (!route_templates.empty()) {
+ vector<string> v;
+ for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
+ chn.name = x->name;
+ chn.channels = 0;
+ chn.template_path = x->path;
+ channel_setups.push_back (chn);
+ }
+ }
+
+ /* clear template path for the rest */
+
+ chn.template_path = "";
+
+ chn.name = _("3 Channel");
+ chn.channels = 3;
+ channel_setups.push_back (chn);
+
+ chn.name = _("4 Channel");
+ chn.channels = 4;
+ channel_setups.push_back (chn);
+
+ chn.name = _("5 Channel");
+ chn.channels = 5;
+ channel_setups.push_back (chn);
+
+ chn.name = _("6 Channel");
+ chn.channels = 6;
+ channel_setups.push_back (chn);
+
+ chn.name = _("8 Channel");
+ chn.channels = 8;
+ channel_setups.push_back (chn);
+
+ chn.name = _("12 Channel");
+ chn.channels = 12;
+ channel_setups.push_back (chn);
+
+ chn.name = _("Custom");
+ chn.channels = 0;
+ channel_setups.push_back (chn);
+
+ for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
+ channel_combo_strings.push_back ((*i).name);
+ }
+
+ set_popdown_strings (channel_combo, channel_combo_strings);
+
+ if (!channel_current_choice.empty()) {
+ channel_combo.set_active_text (channel_current_choice);
+ } else {
+ channel_combo.set_active_text (channel_combo_strings.front());
+ }
+}
+
+void
+AddRouteDialog::add_route_group (RouteGroup* g)
+{
+ route_group_combo.insert_text (3, g->name ());
+}
+
+RouteGroup*
+AddRouteDialog::route_group ()
+{
+ if (!_session || route_group_combo.get_active_row_number () == 2) {
+ return 0;
+ }
+
+ return _session->route_group_by_name (route_group_combo.get_active_text());
+}
+
+bool
+AddRouteDialog::use_strict_io() {
+ return strict_io_combo.get_active_row_number () == 1;
+}
+
+void
+AddRouteDialog::refill_route_groups ()
+{
+ route_group_combo.clear ();
+ route_group_combo.append_text (_("New Group..."));
+
+ route_group_combo.append_text ("separator");
+
+ route_group_combo.append_text (_("No Group"));
+
+ if (_session) {
+ _session->foreach_route_group (sigc::mem_fun (*this, &AddRouteDialog::add_route_group));
+ }
+
+ route_group_combo.set_active (2);
+}
+
+void
+AddRouteDialog::group_changed ()
+{
+ if (_session && route_group_combo.get_active_text () == _("New Group...")) {
+ RouteGroup* g = new RouteGroup (*_session, "");
+ RouteGroupDialog* d = new RouteGroupDialog (g, true);
+
+ d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &AddRouteDialog::new_group_dialog_finished), d));
+ d->present();
+ }
+}
+
+void
+AddRouteDialog::new_group_dialog_finished (int r, RouteGroupDialog* d)
+{
+ if (r == RESPONSE_OK) {
+
+ if (!d->name_check()) {
+ return;
+ }
+
+ if (_session) {
+ _session->add_route_group (d->group());
+ }
+
+ add_route_group (d->group());
+ route_group_combo.set_active (3);
+ } else {
+ delete d->group ();
+ route_group_combo.set_active (2);
+ }
+
+ delete_when_idle (d);
+}
+
+AddRouteDialog::InsertAt
+AddRouteDialog::insert_at ()
+{
+ std::string str = insert_at_combo.get_active_text();
+
+ if (str == _("First")) {
+ return First;
+ } else if (str == _("After Selection")) {
+ return AfterSelection;
+ } else if (str == _("Before Selection")){
+ return BeforeSelection;
+ }
+ return Last;
+}
+
+bool
+AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
+{
+ channel_combo.set_active (i);
+
+ return channel_combo.get_active_text () == "separator";
+}
+
+bool
+AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
+{
+ route_group_combo.set_active (i);
+
+ return route_group_combo.get_active_text () == "separator";
+}
+
+PluginInfoPtr
+AddRouteDialog::requested_instrument ()
+{
+ return instrument_combo.selected_instrument();
+}