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 ()
63 ProcessorBox::register_actions ();
65 editor->setup_tooltips ();
66 editor->UpdateAllTransportClocks.connect (sigc::mem_fun (*this, &ARDOUR_UI::update_transport_clocks));
68 /* catch up on tabbable state */
70 tabbable_state_change (*editor);
71 tabbable_state_change (*mixer);
72 tabbable_state_change (*rc_option_editor);
74 /* all actions are defined */
76 ActionManager::load_menus (ARDOUR_COMMAND_LINE::menus_file);
78 editor->track_mixer_selection ();
79 mixer->track_editor_selection ();
81 /* catch up on parameters */
83 boost::function<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
84 Config->map_parameters (pc);
86 ARDOUR_UI_UTILS::reset_dpi ();
90 ARDOUR_UI::connect_dependents_to_session (ARDOUR::Session *s)
93 BootMessage (_("Setup Editor"));
94 editor->set_session (s);
95 BootMessage (_("Setup Mixer"));
96 mixer->set_session (s);
97 meterbridge->set_session (s);
99 /* its safe to do this now */
101 BootMessage (_("Reload Session History"));
102 s->restore_history ("");
105 /** The main editor window has been closed */
107 ARDOUR_UI::exit_on_main_window_close (GdkEventAny * /*ev*/)
110 /* just hide the window, and return - the top menu stays up */
114 /* time to get out of here */
121 ARDOUR_UI::tab_window_root_drop (GtkNotebook* src,
128 Gtk::Notebook* nb = 0;
129 Gtk::Window* win = 0;
130 Gtkmm2ext::Tabbable* tabbable = 0;
133 if (w == GTK_WIDGET(editor->contents().gobj())) {
135 } else if (w == GTK_WIDGET(mixer->contents().gobj())) {
137 } else if (w == GTK_WIDGET(rc_option_editor->contents().gobj())) {
138 tabbable = rc_option_editor;
143 nb = tabbable->tab_root_drop ();
144 win = tabbable->own_window ();
153 return 0; /* what was that? */
157 ARDOUR_UI::idle_ask_about_quit ()
159 if (_session && _session->dirty()) {
162 /* no session or session not dirty, but still ask anyway */
164 Gtk::MessageDialog msg (string_compose ("Quit %1?", PROGRAM_NAME),
165 false, /* no markup */
169 msg.set_default_response (Gtk::RESPONSE_YES);
171 if (msg.run() == Gtk::RESPONSE_YES) {
176 /* not reached but keep the compiler happy */
182 ARDOUR_UI::main_window_delete_event (GdkEventAny* ev)
184 /* quit the application as soon as we go idle. If we call this here,
185 * the window manager/desktop can think we're taking too longer to
186 * handle the "delete" event
189 Glib::signal_idle().connect (sigc::mem_fun (*this, &ARDOUR_UI::idle_ask_about_quit));
195 tab_window_root_drop (GtkNotebook* src,
201 return ARDOUR_UI::instance()->tab_window_root_drop (src, w, x, y, user_data);
205 ARDOUR_UI::setup_windows ()
207 /* actions do not need to be defined when we load keybindings. They
208 * will be lazily discovered. But bindings do need to exist when we
209 * create windows/tabs with their own binding sets.
212 keyboard->setup_keybindings ();
214 /* we don't use a widget with its own window for the tab close button,
215 which makes it impossible to rely on GTK+ to generate signals for
216 events occuring "in" this widget. Instead, we pre-connect a
217 handler to the relevant events on the notebook and then check
218 to see if the event coordinates tell us that it occured "in"
221 _tabs.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_button_event), false);
222 _tabs.signal_button_release_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_button_event), false);
224 rc_option_editor = new RCOptionEditor;
225 rc_option_editor->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change));
227 if (create_editor ()) {
228 error << _("UI: cannot setup editor") << endmsg;
232 if (create_mixer ()) {
233 error << _("UI: cannot setup mixer") << endmsg;
237 if (create_meterbridge ()) {
238 error << _("UI: cannot setup meterbridge") << endmsg;
242 /* order of addition affects order seen in initial window display */
244 rc_option_editor->add_to_notebook (_tabs, _("Preferences"));
245 mixer->add_to_notebook (_tabs, _("Mixer"));
246 editor->add_to_notebook (_tabs, _("Editor"));
248 /* all other dialogs are created conditionally */
250 we_have_dependents ();
253 EventBox* status_bar_event_box = manage (new EventBox);
255 status_bar_event_box->add (status_bar_label);
256 status_bar_event_box->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
257 status_bar_label.set_size_request (300, -1);
259 status_bar_label.show ();
260 status_bar_event_box->show ();
262 status_bar_event_box->signal_button_press_event().connect (mem_fun (*this, &ARDOUR_UI::status_bar_button_press));
264 status_bar_hpacker.pack_start (*status_bar_event_box, true, true, 6);
265 status_bar_hpacker.pack_start (menu_bar_base, false, false, 2);
267 top_packer.pack_start (menu_bar_base, false, false);
270 main_vpacker.pack_start (top_packer, false, false);
272 /* now add the transport frame to the top of main window */
274 main_vpacker.pack_start (transport_frame, false, false);
275 main_vpacker.pack_start (_tabs, true, true);
278 main_vpacker.pack_start (status_bar_hpacker, false, false);
285 _main_window.signal_delete_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::main_window_delete_event));
287 /* pack the main vpacker into the main window and show everything
290 _main_window.add (main_vpacker);
291 transport_frame.show_all ();
293 const XMLNode* mnode = main_window_settings ();
296 const XMLProperty* prop;
302 if ((prop = mnode->property (X_("x"))) != 0) {
303 x = atoi (prop->value());
306 if ((prop = mnode->property (X_("y"))) != 0) {
307 y = atoi (prop->value());
310 if ((prop = mnode->property (X_("w"))) != 0) {
311 w = atoi (prop->value());
314 if ((prop = mnode->property (X_("h"))) != 0) {
315 h = atoi (prop->value());
318 if (x >= 0 && y >= 0 && w >= 0 && h >= 0) {
319 _main_window.set_position (Gtk::WIN_POS_NONE);
322 if (x >= 0 && y >= 0) {
323 _main_window.move (x, y);
326 if (w > 0 && h > 0) {
327 _main_window.set_default_size (w, h);
330 std::string current_tab;
332 if ((prop = mnode->property (X_("current-tab"))) != 0) {
333 current_tab = prop->value();
335 current_tab = "editor";
337 if (mixer && current_tab == "mixer") {
338 _tabs.set_current_page (_tabs.page_num (mixer->contents()));
339 } else if (rc_option_editor && current_tab == "preferences") {
340 _tabs.set_current_page (_tabs.page_num (rc_option_editor->contents()));
342 _tabs.set_current_page (_tabs.page_num (editor->contents()));
346 _main_window.show_all ();
347 setup_toplevel_window (_main_window, "", this);
349 _tabs.signal_switch_page().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_switch));
350 _tabs.signal_page_removed().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_page_removed));
351 _tabs.signal_page_added().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_page_added));
353 /* It would be nice if Gtkmm had wrapped this rather than just
354 * deprecating the old set_window_creation_hook() method, but oh well...
356 g_signal_connect (_tabs.gobj(), "create-window", (GCallback) ::tab_window_root_drop, this);