first compilable version of tabbable design.
[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 #ifdef WAF_BUILD
21 #include "gtk2ardour-config.h"
22 #endif
23
24 /* this file exists solely to break compilation dependencies that
25    would connect changes to the mixer or editor objects.
26 */
27
28 #include <cstdio>
29
30 #include "pbd/error.h"
31
32 #include "ardour/session.h"
33
34 #include "actions.h"
35 #include "ardour_ui.h"
36 #include "public_editor.h"
37 #include "meterbridge.h"
38 #include "mixer_ui.h"
39 #include "keyboard.h"
40 #include "splash.h"
41 #include "route_params_ui.h"
42 #include "opts.h"
43 #include "i18n.h"
44
45 using namespace Gtk;
46 using namespace PBD;
47
48 namespace ARDOUR {
49         class Session;
50         class Route;
51 }
52
53 using namespace ARDOUR;
54
55 void
56 ARDOUR_UI::we_have_dependents ()
57 {
58         install_actions ();
59         ProcessorBox::register_actions ();
60         keyboard->setup_keybindings ();
61         editor->setup_tooltips ();
62         editor->UpdateAllTransportClocks.connect (sigc::mem_fun (*this, &ARDOUR_UI::update_transport_clocks));
63
64         editor->add_to_notebook (_tabs, _("Editor"), 1);
65         mixer->add_to_notebook (_tabs, _("Mixer"), 1);
66         
67         /* all actions are defined */
68
69         ActionManager::enable_accelerators ();
70         ActionManager::load_menus (ARDOUR_COMMAND_LINE::menus_file);
71
72         editor->track_mixer_selection ();
73         mixer->track_editor_selection ();
74 }
75
76 void
77 ARDOUR_UI::connect_dependents_to_session (ARDOUR::Session *s)
78 {
79         DisplaySuspender ds;
80         BootMessage (_("Setup Editor"));
81         editor->set_session (s);
82         BootMessage (_("Setup Mixer"));
83         mixer->set_session (s);
84         meterbridge->set_session (s);
85
86         /* its safe to do this now */
87
88         BootMessage (_("Reload Session History"));
89         s->restore_history ("");
90 }
91
92 /** The main editor window has been closed */
93 gint
94 ARDOUR_UI::exit_on_main_window_close (GdkEventAny * /*ev*/)
95 {
96 #ifdef TOP_MENUBAR
97         /* just hide the window, and return - the top menu stays up */
98         editor->hide ();
99         return TRUE;
100 #else
101         /* time to get out of here */
102         finish();
103         return TRUE;
104 #endif
105 }
106
107 GtkNotebook*
108 ARDOUR_UI::tab_window_root_drop (GtkNotebook* src,
109                                  GtkWidget* w,
110                                  gint x,
111                                  gint y,
112                                  gpointer)
113 {
114         using namespace std;
115         Gtk::Notebook* nb = 0;
116         Gtk::Window* win = 0;
117         
118         if (w == GTK_WIDGET(mixer->contents().gobj())) {
119                 /* Mixer */
120
121                 cerr << "Call use own window, mixer\n";
122                 
123                 nb = mixer->tab_root_drop ();
124                 win = mixer->own_window ();
125
126         } else if (w == GTK_WIDGET(editor->contents().gobj())) {
127
128                 /* Editor */
129
130                 cerr << "Call use own window, editor\n";
131                 
132                 nb = editor->tab_root_drop ();
133                 win = editor->own_window ();
134
135         }
136
137         if (nb) {
138                 win->move (x, y);
139                 win->show_all ();
140                 win->present ();
141                 return nb->gobj();
142         }
143         
144         return 0; /* what was that? */
145 }