most of the 2.X->3.0 commit (up to rev 4299) except for gtk2_ardour/editor_canvas...
[ardour.git] / gtk2_ardour / ardour_ui_dependents.cc
1 /*
2     Copyright (C) 2000 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 /* this file exists solely to break compilation dependencies that
21    would connect changes to the mixer or editor objects.
22 */
23
24 #include <cstdio>
25
26 #include <pbd/error.h>
27
28 #include "ardour_ui.h"
29 #include "public_editor.h"
30 #include "mixer_ui.h"
31 #include "keyboard.h"
32 #include "splash.h"
33 #include "route_params_ui.h"
34 #include "opts.h"
35 #include "i18n.h"
36
37 using namespace sigc;
38 using namespace Gtk;
39 using namespace PBD;
40
41 namespace ARDOUR {
42         class Session;
43         class Route;
44 }
45
46 using namespace ARDOUR;
47
48 void
49 ARDOUR_UI::shutdown ()
50 {
51         if (session) {
52                 /* we're exiting cleanly, so remove any auto-save data */
53                 session->remove_pending_capture_state ();
54                 session = 0;
55         }
56
57         ui_config->save_state();
58 }
59
60 void
61 ARDOUR_UI::we_have_dependents ()
62 {
63         install_actions ();
64         ProcessorBox::register_actions ();
65
66         Keyboard::setup_keybindings ();
67
68         editor->UpdateAllTransportClocks.connect (mem_fun (*this, &ARDOUR_UI::update_transport_clocks));
69 }
70
71 void
72 ARDOUR_UI::connect_dependents_to_session (ARDOUR::Session *s)
73 {
74         BootMessage (_("Setup Editor"));
75         editor->connect_to_session (s);
76         BootMessage (_("Setup Mixer"));
77         mixer->connect_to_session (s);
78
79         /* its safe to do this now */
80         
81         BootMessage (_("Reload Session History"));
82         s->restore_history ("");
83 }
84
85 static bool
86 _hide_splash (gpointer arg)
87 {
88         ((ARDOUR_UI*)arg)->hide_splash();
89         return false;
90 }
91
92 void
93 ARDOUR_UI::goto_editor_window ()
94 {
95         if (splash && splash->is_visible()) {
96                 // in 2 seconds, hide the splash screen 
97                 Glib::signal_timeout().connect (bind (sigc::ptr_fun (_hide_splash), this), 2000);
98         }
99
100         editor->show_window ();
101         editor->present ();
102         _mixer_on_top = false;
103         flush_pending ();
104 }
105
106 void
107 ARDOUR_UI::goto_mixer_window ()
108 {
109         mixer->show_window ();
110         mixer->present ();
111         _mixer_on_top = true;
112         flush_pending ();
113 }
114
115 void
116 ARDOUR_UI::toggle_editor_mixer_on_top ()
117 {
118         if (_mixer_on_top) {
119                 goto_editor_window ();
120         } else {
121                 goto_mixer_window ();
122         }
123 }
124
125 gint
126 ARDOUR_UI::exit_on_main_window_close (GdkEventAny *ev)
127 {
128 #ifdef TOP_MENUBAR
129         /* just hide the window, and return - the top menu stays up */
130         editor->hide ();
131         return TRUE;
132 #else
133         /* time to get out of here */
134         finish();
135         return TRUE;
136 #endif
137 }