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 tabbable_state_change (*editor);
69 tabbable_state_change (*mixer);
70 tabbable_state_change (*rc_option_editor);
72 /* all actions are defined */
74 ActionManager::enable_accelerators ();
75 ActionManager::load_menus (ARDOUR_COMMAND_LINE::menus_file);
77 editor->track_mixer_selection ();
78 mixer->track_editor_selection ();
80 /* catch up on parameters */
82 boost::function<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
83 Config->map_parameters (pc);
85 ARDOUR_UI_UTILS::reset_dpi ();
89 ARDOUR_UI::connect_dependents_to_session (ARDOUR::Session *s)
92 BootMessage (_("Setup Editor"));
93 editor->set_session (s);
94 BootMessage (_("Setup Mixer"));
95 mixer->set_session (s);
96 meterbridge->set_session (s);
98 /* its safe to do this now */
100 BootMessage (_("Reload Session History"));
101 s->restore_history ("");
104 /** The main editor window has been closed */
106 ARDOUR_UI::exit_on_main_window_close (GdkEventAny * /*ev*/)
109 /* just hide the window, and return - the top menu stays up */
113 /* time to get out of here */
120 ARDOUR_UI::tab_window_root_drop (GtkNotebook* src,
127 Gtk::Notebook* nb = 0;
128 Gtk::Window* win = 0;
129 Gtkmm2ext::Tabbable* tabbable = 0;
132 if (w == GTK_WIDGET(editor->contents().gobj())) {
134 } else if (w == GTK_WIDGET(mixer->contents().gobj())) {
136 } else if (w == GTK_WIDGET(rc_option_editor->contents().gobj())) {
137 tabbable = rc_option_editor;
142 nb = tabbable->tab_root_drop ();
143 win = tabbable->own_window ();
152 return 0; /* what was that? */
156 ARDOUR_UI::idle_ask_about_quit ()
158 if (_session && _session->dirty()) {
161 /* no session or session not dirty, but still ask anyway */
163 Gtk::MessageDialog msg (string_compose ("Quit %1?", PROGRAM_NAME),
164 false, /* no markup */
168 msg.set_default_response (Gtk::RESPONSE_YES);
170 if (msg.run() == Gtk::RESPONSE_YES) {
175 /* not reached but keep the compiler happy */
181 ARDOUR_UI::main_window_delete_event (GdkEventAny* ev)
183 /* quit the application as soon as we go idle. If we call this here,
184 * the window manager/desktop can think we're taking too longer to
185 * handle the "delete" event
188 Glib::signal_idle().connect (sigc::mem_fun (*this, &ARDOUR_UI::idle_ask_about_quit));
194 tab_window_root_drop (GtkNotebook* src,
200 return ARDOUR_UI::instance()->tab_window_root_drop (src, w, x, y, user_data);
204 ARDOUR_UI::setup_windows ()
206 /* we don't use a widget with its own window for the tab close button,
207 which makes it impossible to rely on GTK+ to generate signals for
208 events occuring "in" this widget. Instead, we pre-connect a
209 handler to the relevant events on the notebook and then check
210 to see if the event coordinates tell us that it occured "in"
213 _tabs.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_button_event), false);
214 _tabs.signal_button_release_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_button_event), false);
216 rc_option_editor = new RCOptionEditor;
217 rc_option_editor->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change));
219 if (create_editor ()) {
220 error << _("UI: cannot setup editor") << endmsg;
224 if (create_mixer ()) {
225 error << _("UI: cannot setup mixer") << endmsg;
229 if (create_meterbridge ()) {
230 error << _("UI: cannot setup meterbridge") << endmsg;
234 /* order of addition affects order seen in initial window display */
236 rc_option_editor->add_to_notebook (_tabs, _("Preferences"));
237 mixer->add_to_notebook (_tabs, _("Mixer"));
238 editor->add_to_notebook (_tabs, _("Editor"));
240 /* all other dialogs are created conditionally */
242 we_have_dependents ();
245 EventBox* status_bar_event_box = manage (new EventBox);
247 status_bar_event_box->add (status_bar_label);
248 status_bar_event_box->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
249 status_bar_label.set_size_request (300, -1);
251 status_bar_label.show ();
252 status_bar_event_box->show ();
254 status_bar_event_box->signal_button_press_event().connect (mem_fun (*this, &ARDOUR_UI::status_bar_button_press));
256 status_bar_hpacker.pack_start (*status_bar_event_box, true, true, 6);
257 status_bar_hpacker.pack_start (menu_bar_base, false, false, 2);
259 top_packer.pack_start (menu_bar_base, false, false);
262 main_vpacker.pack_start (top_packer, false, false);
264 /* now add the transport frame to the top of main window */
266 main_vpacker.pack_start (transport_frame, false, false);
267 main_vpacker.pack_start (_tabs, true, true);
270 main_vpacker.pack_start (status_bar_hpacker, false, false);
277 _main_window.signal_delete_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::main_window_delete_event));
279 /* pack the main vpacker into the main window and show everything
282 _main_window.add (main_vpacker);
283 transport_frame.show_all ();
285 const XMLNode* mnode = main_window_settings ();
288 const XMLProperty* prop;
294 if ((prop = mnode->property (X_("x"))) != 0) {
295 x = atoi (prop->value());
298 if ((prop = mnode->property (X_("y"))) != 0) {
299 y = atoi (prop->value());
302 if ((prop = mnode->property (X_("w"))) != 0) {
303 w = atoi (prop->value());
306 if ((prop = mnode->property (X_("h"))) != 0) {
307 h = atoi (prop->value());
310 if (x >= 0 && y >= 0 && w >= 0 && h >= 0) {
311 _main_window.set_position (Gtk::WIN_POS_NONE);
314 if (x >= 0 && y >= 0) {
315 _main_window.move (x, y);
318 if (w > 0 && h > 0) {
319 _main_window.set_default_size (w, h);
322 std::string current_tab;
324 if ((prop = mnode->property (X_("current-tab"))) != 0) {
325 current_tab = prop->value();
327 current_tab = "editor";
329 if (mixer && current_tab == "mixer") {
330 _tabs.set_current_page (_tabs.page_num (mixer->contents()));
331 } else if (rc_option_editor && current_tab == "preferences") {
332 _tabs.set_current_page (_tabs.page_num (rc_option_editor->contents()));
334 _tabs.set_current_page (_tabs.page_num (editor->contents()));
338 _main_window.show_all ();
339 setup_toplevel_window (_main_window, "", this);
341 _tabs.signal_switch_page().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_switch));
342 _tabs.signal_page_removed().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_page_removed));
343 _tabs.signal_page_added().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_page_added));
345 /* It would be nice if Gtkmm had wrapped this rather than just
346 * deprecating the old set_window_creation_hook() method, but oh well...
348 g_signal_connect (_tabs.gobj(), "create-window", (GCallback) ::tab_window_root_drop, this);