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"
37 #include "color_manager.h"
41 using namespace ARDOUR;
45 using namespace Gtkmm2ext;
48 ARDOUR_UI::connect_to_session (Session *s)
52 session->HaltOnXrun.connect (mem_fun(*this, &ARDOUR_UI::halt_on_xrun_message));
54 /* sensitize menu bar options that are now valid */
56 ActionManager::set_sensitive (ActionManager::session_sensitive_actions, true);
58 if (session->locations()->num_range_markers()) {
59 ActionManager::set_sensitive (ActionManager::range_sensitive_actions, true);
61 ActionManager::set_sensitive (ActionManager::range_sensitive_actions, false);
64 /* there are never any selections on startup */
66 ActionManager::set_sensitive (ActionManager::region_selection_sensitive_actions, false);
67 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
68 ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, false);
69 ActionManager::set_sensitive (ActionManager::line_selection_sensitive_actions, false);
70 ActionManager::set_sensitive (ActionManager::point_selection_sensitive_actions, false);
71 ActionManager::set_sensitive (ActionManager::playlist_selection_sensitive_actions, false);
73 session->locations()->added.connect (mem_fun (*this, &ARDOUR_UI::handle_locations_change));
74 session->locations()->removed.connect (mem_fun (*this, &ARDOUR_UI::handle_locations_change));
76 rec_button.set_sensitive (true);
77 shuttle_box.set_sensitive (true);
79 if (connection_editor) {
80 connection_editor->set_session (s);
84 location_ui->set_session(s);
88 route_params->set_session (s);
92 option_editor->set_session (s);
96 sfdb->set_session (s);
99 setup_session_options ();
101 Blink.connect (mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink));
102 Blink.connect (mem_fun(*this, &ARDOUR_UI::solo_blink));
103 Blink.connect (mem_fun(*this, &ARDOUR_UI::audition_blink));
105 /* these are all need to be handled in an RT-safe and MT way, so don't
106 do any GUI work, just queue it for handling by the GUI thread.
109 session->TransportStateChange.connect (mem_fun(*this, &ARDOUR_UI::queue_transport_change));
111 /* alert the user to these things happening */
113 session->AuditionActive.connect (mem_fun(*this, &ARDOUR_UI::auditioning_changed));
114 session->SoloActive.connect (mem_fun(*this, &ARDOUR_UI::soloing_changed));
116 solo_alert_button.set_active (session->soloing());
118 /* can't be auditioning here */
120 primary_clock.set_session (s);
121 secondary_clock.set_session (s);
122 big_clock.set_session (s);
123 preroll_clock.set_session (s);
124 postroll_clock.set_session (s);
126 /* Clocks are on by default after we are connected to a session, so show that here.
129 connect_dependents_to_session (s);
134 transport_stopped ();
136 second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_second), 1000);
137 point_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100);
138 point_zero_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_zero_one_seconds), 40);
142 ARDOUR_UI::unload_session ()
144 if (session && session->dirty()) {
145 switch (ask_about_saving_session (_("close"))) {
150 session->save_state ("");
155 second_connection.disconnect ();
156 point_one_second_connection.disconnect ();
157 point_zero_one_second_connection.disconnect();
159 ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false);
161 rec_button.set_sensitive (false);
162 shuttle_box.set_sensitive (false);
167 /* drop everything attached to the blink signal */
171 primary_clock.set_session (0);
172 secondary_clock.set_session (0);
173 big_clock.set_session (0);
174 preroll_clock.set_session (0);
175 postroll_clock.set_session (0);
178 option_editor->set_session (0);
188 update_buffer_load ();
194 ARDOUR_UI::create_connection_editor ()
197 if (connection_editor == 0) {
198 connection_editor = new ConnectionEditor ();
199 connection_editor->signal_unmap().connect (sigc::bind (ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleConnections")));
203 connection_editor->set_session (session);
211 ARDOUR_UI::toggle_connection_editor ()
213 if (create_connection_editor()) {
218 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleConnections"));
220 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
222 if (tact->get_active()) {
223 connection_editor->show_all ();
224 connection_editor->present ();
226 connection_editor->hide ();
233 ARDOUR_UI::toggle_big_clock_window ()
235 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleBigClock"));
237 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
239 if (tact->get_active()) {
240 big_clock_window->show_all ();
241 big_clock_window->present ();
243 big_clock_window->hide ();
249 ARDOUR_UI::toggle_options_window ()
251 if (option_editor == 0) {
252 option_editor = new OptionEditor (*this, *editor, *mixer);
253 option_editor->signal_unmap().connect(sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleOptionsEditor")));
254 option_editor->set_session (session);
257 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleOptionsEditor"));
259 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
261 if (tact->get_active()) {
262 option_editor->show_all ();
263 option_editor->present ();
265 option_editor->hide ();
271 ARDOUR_UI::create_location_ui ()
273 if (location_ui == 0) {
274 location_ui = new LocationUI ();
275 location_ui->set_session (session);
276 location_ui->signal_unmap().connect (sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleLocations")));
282 ARDOUR_UI::toggle_location_window ()
284 if (create_location_ui()) {
288 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleLocations"));
290 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
292 if (tact->get_active()) {
293 location_ui->show_all ();
294 location_ui->present ();
296 location_ui->hide ();
302 ARDOUR_UI::toggle_color_manager ()
304 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleColorManager"));
306 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
308 if (tact->get_active()) {
309 color_manager->show_all ();
310 color_manager->present ();
312 color_manager->hide ();
318 ARDOUR_UI::create_route_params ()
320 if (route_params == 0) {
321 route_params = new RouteParams_UI (*engine);
322 route_params->set_session (session);
323 route_params->signal_unmap().connect (sigc::bind(sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleInspector")));
329 ARDOUR_UI::toggle_route_params_window ()
331 if (create_route_params ()) {
335 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleInspector"));
337 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
339 if (tact->get_active()) {
340 route_params->show_all ();
341 route_params->present ();
343 route_params->hide ();
349 ARDOUR_UI::create_sound_file_browser ()
352 sfdb = new SoundFileBrowser (_("Sound File Browser"), session);
353 sfdb->signal_unmap().connect (sigc::bind(sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleSoundFileBrowser")));
359 ARDOUR_UI::toggle_sound_file_browser ()
361 if (create_sound_file_browser()) {
365 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleSoundFileBrowser"));
367 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
369 if (tact->get_active()) {
379 ARDOUR_UI::handle_locations_change (Location* ignored)
382 if (session->locations()->num_range_markers()) {
383 ActionManager::set_sensitive (ActionManager::range_sensitive_actions, true);
385 ActionManager::set_sensitive (ActionManager::range_sensitive_actions, false);