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.
21 #include "gtk2ardour-config.h"
24 /* this file exists solely to break compilation dependencies that
25 would connect changes to the mixer or editor objects.
30 #include "pbd/error.h"
32 #include "ardour/session.h"
35 #include "ardour_ui.h"
36 #include "public_editor.h"
37 #include "meterbridge.h"
41 #include "route_params_ui.h"
55 using namespace ARDOUR;
58 ARDOUR_UI::we_have_dependents ()
61 ProcessorBox::register_actions ();
62 keyboard->setup_keybindings ();
63 editor->setup_tooltips ();
64 editor->UpdateAllTransportClocks.connect (sigc::mem_fun (*this, &ARDOUR_UI::update_transport_clocks));
66 /* catch up on tabbable state */
68 std::cerr << "Tab catch up\n";
70 tabbable_state_change (*editor);
71 tabbable_state_change (*mixer);
72 tabbable_state_change (*rc_option_editor);
74 std::cerr << "Tab catch done\n";
76 /* all actions are defined */
78 ActionManager::enable_accelerators ();
79 ActionManager::load_menus (ARDOUR_COMMAND_LINE::menus_file);
81 editor->track_mixer_selection ();
82 mixer->track_editor_selection ();
84 /* catch up on parameters */
86 boost::function<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
87 Config->map_parameters (pc);
89 ARDOUR_UI_UTILS::reset_dpi ();
93 ARDOUR_UI::connect_dependents_to_session (ARDOUR::Session *s)
96 BootMessage (_("Setup Editor"));
97 editor->set_session (s);
98 BootMessage (_("Setup Mixer"));
99 mixer->set_session (s);
100 meterbridge->set_session (s);
102 /* its safe to do this now */
104 BootMessage (_("Reload Session History"));
105 s->restore_history ("");
108 /** The main editor window has been closed */
110 ARDOUR_UI::exit_on_main_window_close (GdkEventAny * /*ev*/)
113 /* just hide the window, and return - the top menu stays up */
117 /* time to get out of here */
124 ARDOUR_UI::tab_window_root_drop (GtkNotebook* src,
131 Gtk::Notebook* nb = 0;
132 Gtk::Window* win = 0;
133 Gtkmm2ext::Tabbable* tabbable = 0;
136 if (w == GTK_WIDGET(editor->contents().gobj())) {
138 } else if (w == GTK_WIDGET(mixer->contents().gobj())) {
140 } else if (w == GTK_WIDGET(rc_option_editor->contents().gobj())) {
141 tabbable = rc_option_editor;
146 nb = tabbable->tab_root_drop ();
147 win = tabbable->own_window ();
156 return 0; /* what was that? */
160 ARDOUR_UI::idle_ask_about_quit ()
162 if (_session && _session->dirty()) {
165 /* no session or session not dirty, but still ask anyway */
167 Gtk::MessageDialog msg (string_compose ("Quit %1?", PROGRAM_NAME),
168 false, /* no markup */
172 msg.set_default_response (Gtk::RESPONSE_YES);
174 if (msg.run() == Gtk::RESPONSE_YES) {
179 /* not reached but keep the compiler happy */
185 ARDOUR_UI::main_window_delete_event (GdkEventAny* ev)
187 /* quit the application as soon as we go idle. If we call this here,
188 * the window manager/desktop can think we're taking too longer to
189 * handle the "delete" event
192 Glib::signal_idle().connect (sigc::mem_fun (*this, &ARDOUR_UI::idle_ask_about_quit));
198 tab_window_root_drop (GtkNotebook* src,
204 return ARDOUR_UI::instance()->tab_window_root_drop (src, w, x, y, user_data);
208 ARDOUR_UI::setup_windows ()
210 /* we don't use a widget with its own window for the tab close button,
211 which makes it impossible to rely on GTK+ to generate signals for
212 events occuring "in" this widget. Instead, we pre-connect a
213 handler to the relevant events on the notebook and then check
214 to see if the event coordinates tell us that it occured "in"
217 _tabs.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_button_event), false);
218 _tabs.signal_button_release_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_button_event), false);
220 rc_option_editor = new RCOptionEditor;
221 rc_option_editor->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change));
223 if (create_editor ()) {
224 error << _("UI: cannot setup editor") << endmsg;
228 if (create_mixer ()) {
229 error << _("UI: cannot setup mixer") << endmsg;
233 if (create_meterbridge ()) {
234 error << _("UI: cannot setup meterbridge") << endmsg;
238 /* order of addition affects order seen in initial window display */
240 rc_option_editor->add_to_notebook (_tabs, _("Preferences"));
241 mixer->add_to_notebook (_tabs, _("Mixer"));
242 editor->add_to_notebook (_tabs, _("Editor"));
244 /* all other dialogs are created conditionally */
246 we_have_dependents ();
249 EventBox* status_bar_event_box = manage (new EventBox);
251 status_bar_event_box->add (status_bar_label);
252 status_bar_event_box->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
253 status_bar_label.set_size_request (300, -1);
255 status_bar_label.show ();
256 status_bar_event_box->show ();
258 status_bar_event_box->signal_button_press_event().connect (mem_fun (*this, &ARDOUR_UI::status_bar_button_press));
260 status_bar_hpacker.pack_start (*status_bar_event_box, true, true, 6);
261 status_bar_hpacker.pack_start (menu_bar_base, false, false, 2);
263 top_packer.pack_start (menu_bar_base, false, false);
266 main_vpacker.pack_start (top_packer, false, false);
268 /* now add the transport frame to the top of main window */
270 main_vpacker.pack_start (transport_frame, false, false);
271 main_vpacker.pack_start (_tabs, true, true);
274 main_vpacker.pack_start (status_bar_hpacker, false, false);
281 _main_window.signal_delete_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::main_window_delete_event));
283 /* pack the main vpacker into the main window and show everything
286 _main_window.add (main_vpacker);
287 transport_frame.show_all ();
289 const XMLNode* mnode = main_window_settings ();
292 const XMLProperty* prop;
298 if ((prop = mnode->property (X_("x"))) != 0) {
299 x = atoi (prop->value());
302 if ((prop = mnode->property (X_("y"))) != 0) {
303 y = atoi (prop->value());
306 if ((prop = mnode->property (X_("w"))) != 0) {
307 w = atoi (prop->value());
310 if ((prop = mnode->property (X_("h"))) != 0) {
311 h = atoi (prop->value());
314 if (x >= 0 && y >= 0 && w >= 0 && h >= 0) {
315 _main_window.set_position (Gtk::WIN_POS_NONE);
318 if (x >= 0 && y >= 0) {
319 _main_window.move (x, y);
322 if (w > 0 && h > 0) {
323 _main_window.set_default_size (w, h);
326 std::string current_tab;
328 if ((prop = mnode->property (X_("current-tab"))) != 0) {
329 current_tab = prop->value();
331 current_tab = "editor";
333 if (mixer && current_tab == "mixer") {
334 _tabs.set_current_page (_tabs.page_num (mixer->contents()));
335 } else if (rc_option_editor && current_tab == "preferences") {
336 _tabs.set_current_page (_tabs.page_num (rc_option_editor->contents()));
338 _tabs.set_current_page (_tabs.page_num (editor->contents()));
342 _main_window.show_all ();
343 setup_toplevel_window (_main_window, "", this);
345 _tabs.signal_switch_page().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_switch));
346 _tabs.signal_page_removed().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_page_removed));
347 _tabs.signal_page_added().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_page_added));
349 /* It would be nice if Gtkmm had wrapped this rather than just
350 * deprecating the old set_window_creation_hook() method, but oh well...
352 g_signal_connect (_tabs.gobj(), "create-window", (GCallback) ::tab_window_root_drop, this);