2 Copyright (C) 2003 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <sigc++/bind.h>
25 #include <gtkmm/stock.h>
26 #include <pbd/error.h>
27 #include <gtkmm2ext/utils.h>
30 #include "add_route_dialog.h"
34 using namespace Gtkmm2ext;
38 static const char* channel_setup_names[] = {
49 static const char* track_mode_names[] = {
55 static vector<string> channel_combo_strings;
56 static vector<string> track_mode_strings;
59 AddRouteDialog::AddRouteDialog ()
60 : Dialog (_("ardour: add track/bus")),
61 track_button (_("Tracks")),
62 bus_button (_("Busses")),
63 routes_adjustment (1, 1, 32, 1, 4),
64 routes_spinner (routes_adjustment)
66 if (channel_combo_strings.empty()) {
67 channel_combo_strings = internationalize (channel_setup_names);
70 if (track_mode_strings.empty()) {
71 track_mode_strings = internationalize (track_mode_names);
75 set_name ("AddRouteDialog");
76 set_wmclass (X_("ardour_add_track_bus"), "Ardour");
77 set_position (Gtk::WIN_POS_MOUSE);
79 name_template_entry.set_name ("AddRouteDialogNameTemplateEntry");
80 track_button.set_name ("AddRouteDialogRadioButton");
81 bus_button.set_name ("AddRouteDialogRadioButton");
82 routes_spinner.set_name ("AddRouteDialogSpinner");
84 RadioButton::Group g = track_button.get_group();
85 bus_button.set_group (g);
86 track_button.set_active (true);
88 HBox *hbrb = manage (new HBox);
90 hbrb->set_spacing (6);
91 hbrb->pack_start (*(manage (new Label (_("Add")))), false, false);
92 hbrb->pack_start (routes_spinner, false, false);
93 hbrb->pack_start (track_button, false, false);
94 hbrb->pack_start (bus_button, false, false);
96 set_popdown_strings (channel_combo, channel_combo_strings);
97 set_popdown_strings (track_mode_combo, track_mode_strings);
98 channel_combo.set_active_text (channel_combo_strings.front());
99 channel_combo.set_name (X_("ChannelCountSelector"));
101 track_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
102 bus_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
104 track_mode_combo.set_active_text (track_mode_strings.front());
105 track_mode_combo.set_name (X_("ChannelCountSelector"));
108 HBox *hbnt = manage (new HBox);
110 hbnt->pack_start (*(manage (new Label (_("Name (template)")))), false, false);
111 hbnt->pack_start (name_template_entry, true, true);
114 get_vbox()->pack_start (*hbrb, false, false);
115 get_vbox()->pack_start (*(manage (new Label ("Channel configuration"))), false, false);
116 get_vbox()->pack_start (channel_combo, false, false);
117 get_vbox()->pack_start (track_mode_combo, false, false, 10);
119 get_vbox()->pack_start (*hbnt, false, false);
122 get_vbox()->show_all ();
124 add_button (Stock::OK, RESPONSE_ACCEPT);
125 add_button (Stock::CANCEL, RESPONSE_CANCEL);
128 AddRouteDialog::~AddRouteDialog ()
133 AddRouteDialog::track_type_chosen ()
135 if (track_button.get_active()) {
136 track_mode_combo.set_sensitive (true);
138 track_mode_combo.set_sensitive (true);
143 AddRouteDialog::track ()
145 return track_button.get_active ();
149 AddRouteDialog::name_template ()
151 return name_template_entry.get_text ();
155 AddRouteDialog::count ()
157 return (int) floor (routes_adjustment.get_value ());
161 AddRouteDialog::mode ()
163 Glib::ustring str = track_mode_combo.get_active_text();
164 if (str == _("normal")) {
165 return ARDOUR::Normal;
166 } else if (str == _("tape")) {
167 return ARDOUR::Destructive;
169 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
174 return ARDOUR::Normal;
178 AddRouteDialog::channels ()
180 string str = channel_combo.get_active_text();
183 if (str == _("mono")) {
185 } else if (str == _("stereo")) {
187 } else if ((chns = atoi (str)) != 0) {