Apply tinram's patch from mantis 2758.
[ardour.git] / gtk2_ardour / route_group_dialog.cc
1 /*
2     Copyright (C) 2009 Paul Davis 
3
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.
8
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.
13
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.
17
18 */
19
20 #include <gtkmm/table.h>
21 #include <gtkmm/stock.h>
22 #include <gtkmm2ext/window_title.h>
23 #include "ardour/route_group.h"
24 #include "route_group_dialog.h"
25 #include "i18n.h"
26 #include <iostream>
27
28 using namespace Gtk;
29 using namespace Gtkmm2ext;
30 using namespace ARDOUR;
31 using namespace std;
32
33 RouteGroupDialog::RouteGroupDialog (RouteGroup* g, StockID const & s)
34         : ArdourDialog (_("route group dialog")),
35           _group (g),
36           _active (_("Active")),
37           _gain (_("Gain")),
38           _relative (_("Relative")),
39           _mute (_("Muting")),
40           _solo (_("Soloing")),
41           _rec_enable (_("Record enable")),
42           _select (_("Selection")),
43           _edit (_("Editing"))
44 {
45         set_modal (true);
46         set_skip_taskbar_hint (true);
47         set_resizable (false);
48         set_position (Gtk::WIN_POS_MOUSE);
49         set_name (N_("RouteGroupDialog"));
50
51         WindowTitle title (Glib::get_application_name());
52         title += _("Route group");
53         set_title(title.get_string());
54
55         VBox* vbox = manage (new VBox);
56         Gtk::Label* l;
57
58         get_vbox()->set_spacing (4);
59
60         vbox->set_spacing (18);
61         vbox->set_border_width (5);
62
63         HBox* hbox = manage (new HBox);
64         hbox->set_spacing (6);
65         l = manage (new Label (_("Name:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false ));
66         
67         hbox->pack_start (*l, false, true);
68         hbox->pack_start (_name, true, true);
69
70         vbox->pack_start (*hbox, false, true);
71  
72         VBox* options_box = manage (new VBox);
73         options_box->set_spacing (6);
74
75         l = manage (new Label (_("<b>Sharing</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false ));
76         l->set_use_markup ();
77         options_box->pack_start (*l, false, true);
78
79         _name.set_text (_group->name ());
80         _active.set_active (_group->is_active ());
81
82         _gain.set_active (_group->property (RouteGroup::Gain));
83         _relative.set_active (_group->is_relative());
84         _mute.set_active (_group->property (RouteGroup::Mute));
85         _solo.set_active (_group->property (RouteGroup::Solo));
86         _rec_enable.set_active (_group->property (RouteGroup::RecEnable));
87         _select.set_active (_group->property (RouteGroup::Select));
88         _edit.set_active (_group->property (RouteGroup::Edit));
89
90         gain_toggled ();
91         
92         Table* table = manage (new Table (8, 3, false));
93         table->set_row_spacings (6);
94
95         l = manage (new Label ("", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
96         l->set_padding (8, 0);
97         table->attach (*l, 0, 1, 0, 8, Gtk::FILL, Gtk::FILL, 0, 0);
98
99         table->attach (_active, 1, 3, 0, 1, Gtk::FILL, Gtk::FILL, 0, 0);
100         table->attach (_gain, 1, 3, 1, 2, Gtk::FILL, Gtk::FILL, 0, 0);
101
102         l = manage (new Label ("", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
103         l->set_padding (0, 0);
104         table->attach (*l, 1, 2, 2, 3, Gtk::FILL, Gtk::FILL, 0, 0);
105         table->attach (_relative, 2, 3, 2, 3, Gtk::FILL, Gtk::FILL, 0, 0);
106
107         table->attach (_mute, 1, 3, 3, 4, Gtk::FILL, Gtk::FILL, 0, 0);
108         table->attach (_solo, 1, 3, 4, 5, Gtk::FILL, Gtk::FILL, 0, 0);
109         table->attach (_rec_enable, 1, 3, 5, 6, Gtk::FILL, Gtk::FILL, 0, 0);
110         table->attach (_select, 1, 3, 6, 7, Gtk::FILL, Gtk::FILL, 0, 0);
111         table->attach (_edit, 1, 3, 7, 8, Gtk::FILL, Gtk::FILL, 0, 0);
112
113         options_box->pack_start (*table, false, true);
114         vbox->pack_start (*options_box, false, true);
115
116         get_vbox()->pack_start (*vbox, false, false);
117
118         _gain.signal_toggled().connect(mem_fun (*this, &RouteGroupDialog::gain_toggled));
119
120         add_button (Stock::CANCEL, RESPONSE_CANCEL);
121         add_button (s, RESPONSE_OK);
122
123         show_all_children ();
124 }
125
126 int
127 RouteGroupDialog::do_run ()
128 {
129         int const r = run ();
130
131         if (r == Gtk::RESPONSE_OK) {
132                 _group->set_property (RouteGroup::Gain, _gain.get_active ());
133                 _group->set_property (RouteGroup::Mute, _mute.get_active ());
134                 _group->set_property (RouteGroup::Solo, _solo.get_active ());
135                 _group->set_property (RouteGroup::RecEnable, _rec_enable.get_active ());
136                 _group->set_property (RouteGroup::Select, _select.get_active ());
137                 _group->set_property (RouteGroup::Edit, _edit.get_active ());
138                 _group->set_name (_name.get_text ()); // This emits changed signal
139                 _group->set_active (_active.get_active (), this);
140                 _group->set_relative (_relative.get_active(), this);
141         }
142
143         return r;
144 }
145
146 void
147 RouteGroupDialog::gain_toggled ()
148 {
149         _relative.set_sensitive (_gain.get_active ());
150 }
151