Merged with trunk R1283.
[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     $Id$
19 */
20
21 /* this file exists solely to break compilation dependencies that
22    would connect changes to the mixer or editor objects.
23 */
24
25 #include <cstdio>
26
27 #include <gtkmm/accelmap.h>
28
29 #include <pbd/error.h>
30
31 #include "ardour_ui.h"
32 #include "public_editor.h"
33 #include "mixer_ui.h"
34 #include "keyboard.h"
35 #include "route_params_ui.h"
36 #include "i18n.h"
37
38 using namespace sigc;
39 using namespace Gtk;
40 using namespace PBD;
41
42 namespace ARDOUR {
43         class Session;
44         class Route;
45 }
46
47 void
48 ARDOUR_UI::shutdown ()
49 {
50         if (session) {
51                 delete session;
52                 session = 0;
53         }
54
55 }
56
57 void
58 ARDOUR_UI::we_have_dependents ()
59 {
60         setup_keybindings ();
61         editor->UpdateAllTransportClocks.connect (mem_fun (*this, &ARDOUR_UI::update_transport_clocks));
62 }
63
64 static void 
65 accel_map_changed (GtkAccelMap* map,
66                    gchar* path,
67                    guint  key,
68                    GdkModifierType mod,
69                    gpointer arg)
70 {
71         static_cast<ARDOUR_UI*>(arg)->save_keybindings ();
72 }
73
74 void
75 ARDOUR_UI::setup_keybindings ()
76 {
77         install_actions ();
78         RedirectBox::register_actions ();
79         
80         cerr << "loading bindings from " << keybindings_path << endl;
81
82         try {
83                 AccelMap::load (keybindings_path);
84         } catch (...) {
85                 error << string_compose (_("Ardour key bindings file not found at \"%1\" or contains errors."), keybindings_path)
86                       << endmsg;
87         }
88
89         /* catch changes */
90
91         GtkAccelMap* accelmap = gtk_accel_map_get();
92         g_signal_connect (accelmap, "changed", (GCallback) accel_map_changed, this);
93
94 }
95
96 void
97 ARDOUR_UI::connect_dependents_to_session (ARDOUR::Session *s)
98 {
99         editor->connect_to_session (s);
100         mixer->connect_to_session (s);
101
102         /* its safe to do this now */
103         
104         s->restore_history ("");
105 }
106
107 void
108 ARDOUR_UI::goto_editor_window ()
109 {
110         editor->show_window ();
111         editor->present();
112 }
113 void
114 ARDOUR_UI::goto_mixer_window ()
115 {
116         mixer->show_window ();
117         mixer->present();
118 }
119
120 gint
121 ARDOUR_UI::exit_on_main_window_close (GdkEventAny *ev)
122 {
123         finish();
124         return TRUE;
125 }