2 Copyright (C) 2000 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 /* This file contains any ARDOUR_UI methods that require knowledge of
21 the various dialog boxes, and exists so that no compilation dependency
22 exists between the main ARDOUR_UI modules and their respective classes.
23 This is to cut down on the compile times. It also helps with my sanity.
26 #include <ardour/session.h>
29 #include "ardour_ui.h"
30 #include "connection_editor.h"
31 #include "location_ui.h"
33 #include "option_editor.h"
34 #include "public_editor.h"
35 #include "route_params_ui.h"
40 using namespace ARDOUR;
43 using namespace Gtkmm2ext;
46 ARDOUR_UI::connect_to_session (Session *s)
50 session->HaltOnXrun.connect (mem_fun(*this, &ARDOUR_UI::halt_on_xrun_message));
52 /* sensitize menu bar options that are now valid */
54 ActionManager::set_sensitive (ActionManager::session_sensitive_actions, true);
56 rec_button.set_sensitive (true);
57 shuttle_box.set_sensitive (true);
59 if (session->n_diskstreams() == 0) {
60 session->DiskStreamAdded.connect (mem_fun(*this, &ARDOUR_UI::diskstream_added));
63 if (connection_editor) {
64 connection_editor->set_session (s);
68 location_ui->set_session(s);
72 route_params->set_session (s);
76 option_editor->set_session (s);
80 Blink.connect (mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink));
81 Blink.connect (mem_fun(*this, &ARDOUR_UI::solo_blink));
82 Blink.connect (mem_fun(*this, &ARDOUR_UI::audition_blink));
84 /* these are all need to be handled in an RT-safe and MT way, so don't
85 do any GUI work, just queue it for handling by the GUI thread.
88 session->TransportStateChange.connect (mem_fun(*this, &ARDOUR_UI::queue_transport_change));
89 session->ControlChanged.connect (mem_fun(*this, &ARDOUR_UI::queue_map_control_change));
91 /* alert the user to these things happening */
93 session->AuditionActive.connect (mem_fun(*this, &ARDOUR_UI::auditioning_changed));
94 session->SoloActive.connect (mem_fun(*this, &ARDOUR_UI::soloing_changed));
96 solo_alert_button.set_active (session->soloing());
98 /* can't be auditioning here */
100 primary_clock.set_session (s);
101 secondary_clock.set_session (s);
102 big_clock.set_session (s);
103 preroll_clock.set_session (s);
104 postroll_clock.set_session (s);
106 /* Clocks are on by default after we are connected to a session, so show that here.
111 connect_dependents_to_session (s);
120 transport_stopped ();
122 second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_second), 1000);
123 point_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100);
124 point_zero_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_zero_one_seconds), 40);
128 ARDOUR_UI::unload_session ()
130 if (session && session->dirty()) {
131 switch (ask_about_saving_session (_("close session"))) {
136 session->save_state ("");
141 second_connection.disconnect ();
142 point_one_second_connection.disconnect ();
143 point_zero_one_second_connection.disconnect();
145 ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false);
147 rec_button.set_sensitive (false);
148 shuttle_box.set_sensitive (false);
153 /* drop everything attached to the blink signal */
157 primary_clock.set_session (0);
158 secondary_clock.set_session (0);
159 big_clock.set_session (0);
160 preroll_clock.set_session (0);
161 postroll_clock.set_session (0);
164 option_editor->set_session (0);
174 update_buffer_load ();
175 // update_disk_rate ();
181 ARDOUR_UI::create_connection_editor ()
183 if (connection_editor == 0) {
184 // connection_editor = new ConnectionEditor ();
185 // connection_editor->signal_unmap().connect (sigc::bind (ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleConnections")));
189 // connection_editor->set_session (session);
196 ARDOUR_UI::toggle_connection_editor ()
198 if (create_connection_editor()) {
205 if (connection_editor_check->get_active()){
206 connection_editor->present();
208 connection_editor->hide_all();
214 ARDOUR_UI::toggle_big_clock_window ()
216 if (big_clock_window->is_visible()) {
217 big_clock_window->hide ();
219 big_clock_window->show_all ();
220 big_clock_window->present ();
225 ARDOUR_UI::toggle_options_window ()
227 if (option_editor == 0) {
228 option_editor = new OptionEditor (*this, *editor, *mixer);
229 option_editor->signal_unmap().connect(sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleOptionsEditor")));
230 option_editor->set_session (session);
233 if (option_editor->is_visible()) {
234 option_editor->hide ();
236 option_editor->present ();
241 ARDOUR_UI::toggle_auto_input ()
244 toggle_some_session_state (auto_input_button,
245 &Session::get_auto_input,
246 &Session::set_auto_input);
250 ARDOUR_UI::create_location_ui ()
252 if (location_ui == 0) {
253 location_ui = new LocationUI ();
254 location_ui->set_session (session);
255 location_ui->signal_unmap().connect (sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleLocations")));
261 ARDOUR_UI::toggle_location_window ()
263 if (create_location_ui()) {
267 if (location_ui->is_visible()) {
270 location_ui->present();
275 ARDOUR_UI::create_route_params ()
277 if (route_params == 0) {
278 route_params = new RouteParams_UI (*engine);
279 route_params->set_session (session);
280 route_params->signal_unmap().connect (sigc::bind(sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleInspector")));
286 ARDOUR_UI::toggle_route_params_window ()
288 if (create_route_params ()) {
292 if (route_params->is_visible ()) {
293 route_params->hide ();
295 route_params->present ();
300 ARDOUR_UI::create_sound_file_browser ()
303 sfdb = new SoundFileBrowser (_("Sound File Browser"));
304 sfdb->set_session (session);
305 sfdb->signal_unmap().connect (sigc::bind(sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleSoundFileBrowser")));
311 ARDOUR_UI::toggle_sound_file_browser ()
313 if (create_sound_file_browser()) {
317 RefPtr<Action> act = ActionManager::ui_manager->get_action (X_("<Actions>/Common/ToggleSoundFileBrowser"));
319 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
321 if (tact->get_active()) {