+
+void
+AddRouteDialog::on_show ()
+{
+ refill_channel_setups ();
+ refill_route_groups ();
+
+ Dialog::on_show ();
+}
+
+void
+AddRouteDialog::refill_channel_setups ()
+{
+ ChannelSetup chn;
+
+ route_templates.clear ();
+ 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);
+
+ chn.name = _("MIDI");
+ chn.channels = 0;
+ channel_setups.push_back (chn);
+
+ chn.name = "separator";
+ channel_setups.push_back (chn);
+
+ ARDOUR::find_route_templates (route_templates);
+
+ if (!ARDOUR::Profile->get_sae()) {
+ 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, true);
+ 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 (route_group_combo.get_active_row_number () == 2) {
+ return 0;
+ }
+
+ return _session->route_group_by_name (route_group_combo.get_active_text());
+}
+
+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"));
+
+ _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, "");
+
+ PropertyList plist;
+ plist.add (Properties::active, true);
+ g->apply_changes (plist);
+
+ RouteGroupDialog d (g, true);
+
+ if (d.do_run ()) {
+ delete g;
+ route_group_combo.set_active (2);
+ } else {
+ _session->add_route_group (g);
+ add_route_group (g);
+ route_group_combo.set_active (3);
+ }
+ }
+}
+
+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";
+}
+