2 Copyright (C) 2009 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.
20 #include <gtkmm/table.h>
21 #include <gtkmm/stock.h>
22 #include <gtkmm/messagedialog.h>
23 #include "ardour/route_group.h"
24 #include "ardour/session.h"
25 #include "route_group_dialog.h"
30 using namespace ARDOUR
;
34 RouteGroupDialog::RouteGroupDialog (RouteGroup
* g
, bool creating_new
)
35 : ArdourDialog (_("Route Group"))
37 , _initial_name (g
->name ())
38 , _active (_("Active"))
40 , _relative (_("Relative"))
42 , _solo (_("Soloing"))
43 , _rec_enable (_("Record enable"))
44 , _select (_("Selection"))
45 , _edit (_("Editing"))
46 , _route_active (_("Route active state"))
49 set_skip_taskbar_hint (true);
50 set_resizable (false);
51 set_position (Gtk::WIN_POS_MOUSE
);
52 set_name (N_("RouteGroupDialog"));
54 VBox
* main_vbox
= manage (new VBox
);
57 get_vbox()->set_spacing (4);
59 main_vbox
->set_spacing (18);
60 main_vbox
->set_border_width (5);
62 HBox
* hbox
= manage (new HBox
);
63 hbox
->set_spacing (6);
64 l
= manage (new Label (_("Name:"), Gtk::ALIGN_LEFT
, Gtk::ALIGN_CENTER
, false ));
66 hbox
->pack_start (*l
, false, true);
67 hbox
->pack_start (_name
, true, true);
69 VBox
* top_vbox
= manage (new VBox
);
70 top_vbox
->set_spacing (4);
72 top_vbox
->pack_start (*hbox
, false, true);
73 top_vbox
->pack_start (_active
);
75 main_vbox
->pack_start (*top_vbox
, false, false);
77 _name
.set_text (_group
->name ());
78 _active
.set_active (_group
->is_active ());
80 VBox
* options_box
= manage (new VBox
);
81 options_box
->set_spacing (6);
83 l
= manage (new Label (_("<b>Sharing</b>"), Gtk::ALIGN_LEFT
, Gtk::ALIGN_CENTER
, false ));
85 options_box
->pack_start (*l
, false, true);
87 _name
.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Dialog::response
), RESPONSE_OK
));
89 _gain
.set_active (_group
->is_gain());
90 _relative
.set_active (_group
->is_relative());
91 _mute
.set_active (_group
->is_mute());
92 _solo
.set_active (_group
->is_solo());
93 _rec_enable
.set_active (_group
->is_recenable());
94 _select
.set_active (_group
->is_select());
95 _edit
.set_active (_group
->is_edit());
96 _route_active
.set_active (_group
->is_route_active());
98 _name
.signal_changed().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
99 _active
.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
100 _gain
.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
101 _relative
.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
102 _mute
.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
103 _solo
.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
104 _rec_enable
.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
105 _select
.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
106 _edit
.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
107 _route_active
.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update
));
111 Table
* table
= manage (new Table (8, 3, false));
112 table
->set_row_spacings (6);
114 l
= manage (new Label ("", Gtk::ALIGN_LEFT
, Gtk::ALIGN_CENTER
, false));
115 l
->set_padding (8, 0);
116 table
->attach (*l
, 0, 1, 0, 8, Gtk::FILL
, Gtk::FILL
, 0, 0);
118 table
->attach (_gain
, 1, 3, 1, 2, Gtk::FILL
, Gtk::FILL
, 0, 0);
120 l
= manage (new Label ("", Gtk::ALIGN_LEFT
, Gtk::ALIGN_CENTER
, false));
121 l
->set_padding (0, 0);
122 table
->attach (*l
, 1, 2, 2, 3, Gtk::FILL
, Gtk::FILL
, 0, 0);
123 table
->attach (_relative
, 2, 3, 2, 3, Gtk::FILL
, Gtk::FILL
, 0, 0);
125 table
->attach (_mute
, 1, 3, 3, 4, Gtk::FILL
, Gtk::FILL
, 0, 0);
126 table
->attach (_solo
, 1, 3, 4, 5, Gtk::FILL
, Gtk::FILL
, 0, 0);
127 table
->attach (_rec_enable
, 1, 3, 5, 6, Gtk::FILL
, Gtk::FILL
, 0, 0);
128 table
->attach (_select
, 1, 3, 6, 7, Gtk::FILL
, Gtk::FILL
, 0, 0);
129 table
->attach (_edit
, 1, 3, 7, 8, Gtk::FILL
, Gtk::FILL
, 0, 0);
130 table
->attach (_route_active
, 1, 3, 8, 9, Gtk::FILL
, Gtk::FILL
, 0, 0);
132 options_box
->pack_start (*table
, false, true);
133 main_vbox
->pack_start (*options_box
, false, true);
135 get_vbox()->pack_start (*main_vbox
, false, false);
137 _gain
.signal_toggled().connect(sigc::mem_fun (*this, &RouteGroupDialog::gain_toggled
));
140 add_button (Stock::CANCEL
, RESPONSE_CANCEL
);
141 add_button (Stock::NEW
, RESPONSE_OK
);
142 set_default_response (RESPONSE_OK
);
144 add_button (Stock::CLOSE
, RESPONSE_CLOSE
);
145 set_default_response (RESPONSE_CLOSE
);
148 show_all_children ();
151 /** @return true if the route group edit was cancelled, otherwise false */
153 RouteGroupDialog::do_run ()
156 int const r
= run ();
157 if (r
== Gtk::RESPONSE_CANCEL
) {
158 /* cancel, so just bail now */
159 return Gtk::RESPONSE_CANCEL
;
162 if (unique_name ()) {
163 /* not cancelled and the name is ok, so all is well */
167 _group
->set_name (_initial_name
);
169 _("A route group of this name already exists. Please use a different name."),
184 RouteGroupDialog::update ()
188 plist
.add (Properties::gain
, _gain
.get_active());
189 plist
.add (Properties::recenable
, _rec_enable
.get_active());
190 plist
.add (Properties::mute
, _mute
.get_active());
191 plist
.add (Properties::solo
, _solo
.get_active ());
192 plist
.add (Properties::select
, _select
.get_active());
193 plist
.add (Properties::edit
, _edit
.get_active());
194 plist
.add (Properties::route_active
, _route_active
.get_active());
195 plist
.add (Properties::relative
, _relative
.get_active());
196 plist
.add (Properties::active
, _active
.get_active());
197 plist
.add (Properties::name
, string (_name
.get_text()));
199 _group
->apply_changes (plist
);
203 RouteGroupDialog::gain_toggled ()
205 _relative
.set_sensitive (_gain
.get_active ());
208 /** @return true if the current group's name is unique accross the session */
210 RouteGroupDialog::unique_name () const
212 list
<RouteGroup
*> route_groups
= _group
->session().route_groups ();
213 list
<RouteGroup
*>::iterator i
= route_groups
.begin ();
214 while (i
!= route_groups
.end() && ((*i
)->name() != _name
.get_text() || *i
== _group
)) {
218 return (i
== route_groups
.end ());