Prefer testing the session instead of using a global variable
[ardour.git] / gtk2_ardour / ardour_ui.h
1 /*
2     Copyright (C) 1999-2002 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 #ifndef __ardour_gui_h__
21 #define __ardour_gui_h__
22
23 #include <time.h>
24
25 /* need _BSD_SOURCE to get timersub macros */
26
27 #ifdef _BSD_SOURCE
28 #include <sys/time.h>
29 #else
30 #define _BSD_SOURCE
31 #include <sys/time.h>
32 #undef _BSD_SOURCE
33 #endif
34
35 #include <list>
36 #include <cmath>
37
38
39 #include "pbd/xml++.h"
40 #include <gtkmm/box.h>
41 #include <gtkmm/frame.h>
42 #include <gtkmm/label.h>
43 #include <gtkmm/table.h>
44 #include <gtkmm/fixed.h>
45 #include <gtkmm/drawingarea.h>
46 #include <gtkmm/eventbox.h>
47 #include <gtkmm/menu.h>
48 #include <gtkmm/menuitem.h>
49 #include <gtkmm/messagedialog.h>
50 #include <gtkmm/notebook.h>
51 #include <gtkmm/button.h>
52 #include <gtkmm/togglebutton.h>
53 #include <gtkmm/treeview.h>
54 #include <gtkmm/menubar.h>
55 #include <gtkmm/textbuffer.h>
56 #include <gtkmm/adjustment.h>
57
58 #include "gtkmm2ext/gtk_ui.h"
59 #include "gtkmm2ext/bindings.h"
60 #include "gtkmm2ext/visibility_tracker.h"
61
62 #include "ardour/ardour.h"
63 #include "ardour/types.h"
64 #include "ardour/utils.h"
65 #include "ardour/plugin.h"
66 #include "ardour/session_handle.h"
67 #include "ardour/system_exec.h"
68
69 #include "video_timeline.h"
70
71 #include "widgets/ardour_button.h"
72 #include "widgets/ardour_spacer.h"
73
74 #include "add_route_dialog.h"
75 #include "ardour_dialog.h"
76 #include "ardour_window.h"
77 #include "editing.h"
78 #include "enums.h"
79 #include "mini_timeline.h"
80 #include "shuttle_control.h"
81 #include "transport_control.h"
82 #include "transport_control_ui.h"
83 #include "visibility_group.h"
84 #include "window_manager.h"
85
86 #ifdef COMPILER_MSVC
87 #include "about.h"
88 #include "add_video_dialog.h"
89 #include "big_clock_window.h"
90 #include "big_transport_window.h"
91 #include "bundle_manager.h"
92 #include "engine_dialog.h"
93 #include "export_video_dialog.h"
94 #include "global_port_matrix.h"
95 #include "idleometer.h"
96 #include "keyeditor.h"
97 #include "location_ui.h"
98 #include "lua_script_manager.h"
99 #include "plugin_dspload_window.h"
100 #include "rc_option_editor.h"
101 #include "route_dialogs.h"
102 #include "route_params_ui.h"
103 #include "session_option_editor.h"
104 #include "speaker_dialog.h"
105 #include "transport_masters_dialog.h"
106 #else
107 class About;
108 class AddRouteDialog;
109 class AddVideoDialog;
110 class BigClockWindow;
111 class BigTransportWindow;
112 class BundleManager;
113 class EngineControl;
114 class ExportVideoDialog;
115 class KeyEditor;
116 class LocationUIWindow;
117 class LuaScriptManager;
118 class RCOptionEditor;
119 class RouteParams_UI;
120 class SessionOptionEditor;
121 class SpeakerDialog;
122 class GlobalPortMatrixWindow;
123 class IdleOMeter;
124 class PluginDSPLoadWindow;
125 class TransportMastersWindow;
126 #endif
127
128 class VideoTimeLine;
129 class ArdourKeyboard;
130 class AudioClock;
131 class ConnectionEditor;
132 class DuplicateRouteDialog;
133 class MainClock;
134 class Mixer_UI;
135 class PublicEditor;
136 class SaveAsDialog;
137 class SaveTemplateDialog;
138 class SessionDialog;
139 class SessionOptionEditorWindow;
140 class Splash;
141 class TimeInfoBox;
142 class Meterbridge;
143 class LuaWindow;
144 class MidiTracer;
145 class NSM_Client;
146 class LevelMeterHBox;
147 class GUIObjectState;
148
149 namespace ARDOUR {
150         class ControlProtocolInfo;
151         class IO;
152         class Port;
153         class Route;
154         class RouteGroup;
155         class Location;
156         class ProcessThread;
157 }
158
159 namespace Gtk {
160         class ProgressBar;
161 }
162
163 namespace ArdourWidgets {
164         class Prompter;
165         class Tabbable;
166 }
167
168 #define MAX_LUA_ACTION_SCRIPTS 12
169
170 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr, public TransportControlProvider
171 {
172 public:
173         ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
174         ~ARDOUR_UI();
175
176         bool run_startup (bool should_be_new, std::string load_template);
177
178         void show_splash ();
179         void hide_splash ();
180
181         void launch_chat ();
182         void launch_manual ();
183         void launch_reference ();
184         void launch_tracker ();
185         void launch_subscribe ();
186         void launch_cheat_sheet ();
187         void launch_website ();
188         void launch_website_dev ();
189         void launch_forums ();
190         void launch_howto_report ();
191         void show_about ();
192         void hide_about ();
193
194         void load_from_application_api (const std::string& path);
195         void finish();
196
197         int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
198         bool session_load_in_progress;
199         int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile*);
200         bool session_is_new() const { return _session_is_new; }
201
202         ARDOUR::Session* the_session() { return _session; }
203
204         bool get_smart_mode () const;
205
206         RCOptionEditor* get_rc_option_editor() { return rc_option_editor; }
207         void show_tabbable (ArdourWidgets::Tabbable*);
208
209         int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
210         int  build_session_from_dialog (SessionDialog&, const std::string& session_name, const std::string& session_path);
211         bool ask_about_loading_existing_session (const std::string& session_path);
212
213         /// @return true if session was successfully unloaded.
214         int unload_session (bool hide_stuff = false);
215         void close_session();
216
217         int  save_state_canfail (std::string state_name = "", bool switch_to_it = false);
218         void save_state (const std::string & state_name = "", bool switch_to_it = false);
219
220         static ARDOUR_UI *instance () { return theArdourUI; }
221
222         /* signal emitted when escape key is pressed. All UI components that
223            need to respond to Escape in some way (e.g. break drag, clear
224            selection, etc) should connect to and handle this.
225         */
226         PBD::Signal0<void> Escape;
227
228         PublicEditor&     the_editor() { return *editor;}
229         Mixer_UI* the_mixer() { return mixer; }
230
231         void new_midi_tracer_window ();
232         void toggle_editing_space();
233         void toggle_mixer_space();
234         void toggle_mixer_list();
235         void toggle_monitor_section_visibility ();
236         void toggle_keep_tearoffs();
237
238         void toggle_vca_pane();
239 #ifdef MIXBUS
240         void toggle_mixbus_pane();
241 #endif
242
243         void reset_focus (Gtk::Widget*);
244
245         static PublicEditor* _instance;
246
247         /** Emitted frequently with the audible sample, false, and the edit point as
248          *  parameters respectively.
249          *
250          *  (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
251          */
252         static sigc::signal<void, samplepos_t> Clock;
253
254         static void close_all_dialogs () { CloseAllDialogs(); }
255         static sigc::signal<void> CloseAllDialogs;
256
257         XMLNode* main_window_settings() const;
258         XMLNode* editor_settings() const;
259         XMLNode* preferences_settings() const;
260         XMLNode* mixer_settings () const;
261         XMLNode* keyboard_settings () const;
262         XMLNode* tearoff_settings (const char*) const;
263
264         void save_ardour_state ();
265         gboolean configure_handler (GdkEventConfigure* conf);
266
267         void halt_on_xrun_message ();
268         void xrun_handler (samplepos_t);
269         void create_xrun_marker (samplepos_t);
270
271         GUIObjectState* gui_object_state;
272
273         MainClock* primary_clock;
274         MainClock* secondary_clock;
275         void focus_on_clock ();
276         AudioClock*   big_clock;
277
278         VideoTimeLine *video_timeline;
279
280         void store_clock_modes ();
281         void restore_clock_modes ();
282         void reset_main_clocks ();
283
284         void synchronize_sync_source_and_video_pullup ();
285
286         void add_route ();
287         void add_route_dialog_response (int);
288
289         void add_routes_part_two ();
290         void add_routes_thread ();
291
292         void start_duplicate_routes ();
293
294         void add_video (Gtk::Window* float_window);
295         void remove_video ();
296         void start_video_server_menu (Gtk::Window* float_window);
297         bool start_video_server (Gtk::Window* float_window, bool popup_msg);
298         void stop_video_server (bool ask_confirm=false);
299         void flush_videotimeline_cache (bool localcacheonly=false);
300         void export_video (bool range = false);
301
302         void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *,
303                                       uint32_t, std::string const &, bool, ARDOUR::PresentationInfo::order_t order);
304
305         void session_add_mixed_track (const ARDOUR::ChanCount&, const ARDOUR::ChanCount&, ARDOUR::RouteGroup*,
306                                       uint32_t, std::string const &, bool strict_io,
307                                       ARDOUR::PluginInfoPtr, ARDOUR::Plugin::PresetRecord* pset,
308                                       ARDOUR::PresentationInfo::order_t order);
309
310         void session_add_midi_bus (ARDOUR::RouteGroup*, uint32_t, std::string const &, bool strict_io,
311                                    ARDOUR::PluginInfoPtr, ARDOUR::Plugin::PresetRecord* pset,
312                                    ARDOUR::PresentationInfo::order_t order);
313
314         void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, bool,
315                                      ARDOUR::PluginInfoPtr, ARDOUR::Plugin::PresetRecord*,
316                                      ARDOUR::PresentationInfo::order_t order);
317
318         void session_add_foldback_bus (uint32_t, std::string const &);
319
320         void display_insufficient_ports_message ();
321
322         void attach_to_engine ();
323         void post_engine ();
324
325         gint exit_on_main_window_close (GdkEventAny *);
326
327         void maximise_editing_space ();
328         void restore_editing_space ();
329
330         void show_ui_prefs ();
331
332         bool check_audioengine(Gtk::Window&);
333
334         void setup_profile ();
335         void setup_tooltips ();
336
337         void set_shuttle_fract (double);
338
339         void get_process_buffers ();
340         void drop_process_buffers ();
341
342         void reset_peak_display ();
343         void reset_route_peak_display (ARDOUR::Route*);
344         void reset_group_peak_display (ARDOUR::RouteGroup*);
345
346         const std::string& announce_string() const { return _announce_string; }
347
348         void hide_application ();
349
350         Gtk::Notebook& tabs();
351         Gtk::Window& main_window () { return _main_window; }
352
353         void setup_toplevel_window (Gtk::Window&, const std::string& name, void* owner);
354
355         /* called from a static C function */
356
357         GtkNotebook* tab_window_root_drop (GtkNotebook* src,
358                                            GtkWidget* w,
359                                            gint x,
360                                            gint y,
361                                            gpointer user_data);
362
363         bool tabbed_window_state_event_handler (GdkEventWindowState*, void* object);
364         bool key_event_handler (GdkEventKey*, Gtk::Window* window);
365
366         Gtkmm2ext::ActionMap global_actions;
367
368         ARDOUR::PresentationInfo::order_t translate_order (RouteDialogs::InsertAt);
369
370         std::map<std::string, std::string> route_setup_info (const std::string& script_path);
371
372 protected:
373         friend class PublicEditor;
374
375         void toggle_auto_play ();
376         void toggle_auto_input ();
377         void toggle_punch ();
378         void unset_dual_punch ();
379         bool ignore_dual_punch;
380         void toggle_punch_in ();
381         void toggle_punch_out ();
382         void toggle_session_monitoring_in ();
383         void toggle_session_monitoring_disk ();
384         void show_loop_punch_ruler_and_disallow_hide ();
385         void reenable_hide_loop_punch_ruler_if_appropriate ();
386         void toggle_auto_return ();
387         void toggle_click ();
388         void toggle_audio_midi_setup ();
389         void toggle_session_auto_loop ();
390         void toggle_rc_options_window ();
391         void toggle_session_options_window ();
392
393 private:
394
395         Gtk::Window   _main_window;
396         Gtkmm2ext::VisibilityTracker* main_window_visibility;
397         Gtk::VBox      main_vpacker;
398         Gtk::HBox      status_bar_hpacker;
399         Gtk::Notebook _tabs;
400         PublicEditor*  editor;
401         Mixer_UI*      mixer;
402         Gtk::Tooltips _tooltips;
403         NSM_Client*    nsm;
404         bool          _was_dirty;
405         bool          _mixer_on_top;
406         bool          _initial_verbose_plugin_scan;
407         bool           first_time_engine_run;
408
409         void hide_tabbable (ArdourWidgets::Tabbable*);
410         void detach_tabbable (ArdourWidgets::Tabbable*);
411         void attach_tabbable (ArdourWidgets::Tabbable*);
412         void button_change_tabbable_visibility (ArdourWidgets::Tabbable*);
413         void key_change_tabbable_visibility (ArdourWidgets::Tabbable*);
414         void toggle_editor_and_mixer ();
415
416         void tabbable_state_change (ArdourWidgets::Tabbable&);
417
418         void toggle_meterbridge ();
419         void toggle_luawindow ();
420
421         int  setup_windows ();
422         void setup_transport ();
423         void setup_clock ();
424
425         static ARDOUR_UI *theArdourUI;
426         SessionDialog *_session_dialog;
427
428         int starting ();
429
430         int  ask_about_saving_session (const std::vector<std::string>& actions);
431
432         void save_session_at_its_request (std::string);
433         /* periodic safety backup, to be precise */
434         gint autosave_session();
435         void update_autosave();
436         sigc::connection _autosave_connection;
437
438         void session_dirty_changed ();
439         void update_title ();
440
441         void map_transport_state ();
442         int32_t do_engine_start ();
443
444         void engine_halted (const char* reason, bool free_reason);
445         void engine_stopped ();
446         void engine_running ();
447
448         void use_config ();
449
450         void about_signal_response(int response);
451
452         Gtk::VBox    top_packer;
453
454         sigc::connection clock_signal_connection;
455         void         update_clocks ();
456         void         start_clocking ();
457         void         stop_clocking ();
458
459         void update_transport_clocks (samplepos_t pos);
460         void record_state_changed ();
461
462         std::list<MidiTracer*> _midi_tracer_windows;
463
464         /* Transport Control */
465
466         Gtk::Table               transport_table;
467         Gtk::Frame               transport_frame;
468         Gtk::HBox                transport_hbox;
469
470         ArdourWidgets::ArdourVSpacer* secondary_clock_spacer;
471         void repack_transport_hbox ();
472         void update_clock_visibility ();
473         void toggle_follow_edits ();
474
475         void set_transport_controllable_state (const XMLNode&);
476         XMLNode& get_transport_controllable_state ();
477
478         TransportControlUI transport_ctrl;
479
480         ArdourWidgets::ArdourButton punch_in_button;
481         ArdourWidgets::ArdourButton punch_out_button;
482         ArdourWidgets::ArdourButton layered_button;
483
484         ArdourWidgets::ArdourVSpacer recpunch_spacer;
485         ArdourWidgets::ArdourVSpacer monitoring_spacer;
486
487         ArdourWidgets::ArdourButton monitor_in_button;
488         ArdourWidgets::ArdourButton monitor_disk_button;
489         ArdourWidgets::ArdourButton auto_input_button;
490
491         Gtk::Label   punch_label;
492         Gtk::Label   layered_label;
493
494         Gtk::Label   punch_space;
495         Gtk::Label   mon_space;
496
497         void toggle_external_sync ();
498         void toggle_time_master ();
499         void toggle_video_sync ();
500
501         ShuttleControl     shuttle_box;
502         MiniTimeline       mini_timeline;
503         TimeInfoBox*       time_info_box;
504
505
506         ArdourWidgets::ArdourVSpacer      meterbox_spacer;
507         ArdourWidgets::ArdourVSpacer      meterbox_spacer2;
508
509         ArdourWidgets::ArdourButton auto_return_button;
510         ArdourWidgets::ArdourButton follow_edits_button;
511         ArdourWidgets::ArdourButton sync_button;
512
513         ArdourWidgets::ArdourButton auditioning_alert_button;
514         ArdourWidgets::ArdourButton solo_alert_button;
515         ArdourWidgets::ArdourButton feedback_alert_button;
516         ArdourWidgets::ArdourButton error_alert_button;
517
518         ArdourWidgets::ArdourButton action_script_call_btn[MAX_LUA_ACTION_SCRIPTS];
519         Gtk::Table action_script_table;
520
521         Gtk::VBox alert_box;
522         Gtk::Table editor_meter_table;
523         ArdourWidgets::ArdourButton editor_meter_peak_display;
524         LevelMeterHBox *            editor_meter;
525         float                       editor_meter_max_peak;
526         bool                        editor_meter_peak_button_release (GdkEventButton*);
527
528         bool editor_meter_button_press (GdkEventButton* ev);
529         void popup_editor_meter_menu (GdkEventButton* ev);
530         void add_editor_meter_type_item (Gtk::Menu_Helpers::MenuList&, Gtk::RadioMenuItem::Group&, std::string const &, ARDOUR::MeterType);
531         bool _suspend_editor_meter_callbacks;
532
533         void blink_handler (bool);
534         sigc::connection blink_connection;
535
536         void cancel_solo ();
537         void solo_blink (bool);
538         void sync_blink (bool);
539         void audition_blink (bool);
540         void feedback_blink (bool);
541         void error_blink (bool);
542
543         void set_flat_buttons();
544
545         void soloing_changed (bool);
546         void auditioning_changed (bool);
547         void _auditioning_changed (bool);
548
549         bool solo_alert_press (GdkEventButton* ev);
550         void audition_alert_clicked ();
551         bool error_alert_press (GdkEventButton *);
552
553         void layered_button_clicked ();
554
555         void big_clock_value_changed ();
556         void primary_clock_value_changed ();
557         void secondary_clock_value_changed ();
558
559         /* called by Blink signal */
560
561         void transport_rec_enable_blink (bool onoff);
562
563         Gtk::Menu*        session_popup_menu;
564
565         /* menu bar and associated stuff */
566
567         Gtk::MenuBar* menu_bar;
568         Gtk::EventBox menu_bar_base;
569         Gtk::HBox     menu_hbox;
570
571         void use_menubar_as_top_menubar ();
572         void build_menu_bar ();
573
574         Gtk::Label   wall_clock_label;
575         gint update_wall_clock ();
576
577         Gtk::Label  disk_space_label;
578         void update_disk_space ();
579         void format_disk_space_label (float);
580
581         Gtk::Label   timecode_format_label;
582         void update_timecode_format ();
583
584         Gtk::Label  dsp_load_label;
585         void update_cpu_load ();
586
587         Gtk::Label   peak_thread_work_label;
588         void update_peak_thread_work ();
589
590         Gtk::Label   sample_rate_label;
591         void update_sample_rate (ARDOUR::samplecnt_t);
592
593         Gtk::Label    format_label;
594         void update_format ();
595
596         void every_second ();
597         void every_point_one_seconds ();
598         void every_point_zero_something_seconds ();
599
600         sigc::connection second_connection;
601         sigc::connection point_one_second_connection;
602         sigc::connection point_zero_something_second_connection;
603         sigc::connection fps_connection;
604
605         void set_fps_timeout_connection ();
606
607         void open_session ();
608         void open_recent_session ();
609         void save_template_dialog_response (int response, SaveTemplateDialog* d);
610         void save_template ();
611         void manage_templates ();
612
613         void meta_session_setup (const std::string& script_path);
614         void meta_route_setup (const std::string& script_path);
615
616         void edit_metadata ();
617         void import_metadata ();
618
619         void set_transport_sensitivity (bool);
620
621         //stuff for ProTools-style numpad
622         void transport_numpad_event (int num);
623         void transport_numpad_decimal ();
624         bool _numpad_locate_happening;
625         int _pending_locate_num;
626         gint transport_numpad_timeout ();
627         sigc::connection _numpad_timeout_connection;
628
629         void transport_goto_nth_marker (int nth);
630         void transport_goto_zero ();
631         void transport_goto_start ();
632         void transport_goto_end ();
633         void transport_goto_wallclock ();
634         void transport_stop ();
635         void transport_record (bool roll);
636         void transport_roll ();
637         void transport_play_selection();
638         void transport_play_preroll();
639         void transport_rec_preroll();
640         void transport_rec_count_in();
641         void transport_forward (int option);
642         void transport_rewind (int option);
643         void transport_loop ();
644         void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
645         bool trx_record_enable_all_tracks ();
646
647         bool _session_is_new;
648         void set_session (ARDOUR::Session *);
649         void connect_dependents_to_session (ARDOUR::Session *);
650         void we_have_dependents ();
651
652         void setup_session_options ();
653
654         guint32  last_key_press_time;
655
656         bool process_snapshot_session_prompter (ArdourWidgets::Prompter& prompter, bool switch_to_it);
657         void snapshot_session (bool switch_to_it);
658
659         void quick_snapshot_session (bool switch_to_it);  //does not promtp for name, just makes a timestamped file
660
661         SaveAsDialog* save_as_dialog;
662
663         bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
664         void save_session_as ();
665         void archive_session ();
666         void rename_session ();
667
668         int         create_mixer ();
669         int         create_editor ();
670         int         create_meterbridge ();
671         int         create_luawindow ();
672         int         create_masters ();
673
674         Meterbridge  *meterbridge;
675         LuaWindow    *luawindow;
676
677         /* Dialogs that can be created via new<T> */
678
679         RCOptionEditor* rc_option_editor;
680         Gtk::HBox rc_option_editor_placeholder;
681
682         WM::Proxy<SpeakerDialog> speaker_config_window;
683         WM::Proxy<AddRouteDialog> add_route_dialog;
684         WM::Proxy<About> about;
685         WM::Proxy<LocationUIWindow> location_ui;
686         WM::Proxy<RouteParams_UI> route_params;
687         WM::Proxy<EngineControl> audio_midi_setup;
688         WM::Proxy<ExportVideoDialog> export_video_dialog;
689         WM::Proxy<LuaScriptManager> lua_script_window;
690         WM::Proxy<IdleOMeter> idleometer;
691         WM::Proxy<PluginDSPLoadWindow> plugin_dsp_load_window;
692         WM::Proxy<TransportMastersWindow> transport_masters_window;
693
694         /* Windows/Dialogs that require a creator method */
695
696         WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
697         WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
698         WM::ProxyWithConstructor<BundleManager> bundle_manager;
699         WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
700         WM::ProxyWithConstructor<BigTransportWindow> big_transport_window;
701         WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
702         WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
703         WM::ProxyWithConstructor<KeyEditor> key_editor;
704
705         /* creator methods */
706
707         SessionOptionEditor*    create_session_option_editor ();
708         BundleManager*          create_bundle_manager ();
709         AddVideoDialog*         create_add_video_dialog ();
710         BigClockWindow*         create_big_clock_window();
711         BigTransportWindow*     create_big_transport_window();
712         GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
713         KeyEditor*              create_key_editor ();
714
715         ARDOUR::SystemExec *video_server_process;
716
717         void handle_locations_change (ARDOUR::Location*);
718
719         /* Keyboard Handling */
720
721         ArdourKeyboard* keyboard;
722
723         /* Keymap handling */
724
725         void install_actions ();
726
727         void toggle_record_enable (uint16_t);
728
729         uint32_t rec_enabled_streams;
730         void count_recenabled_streams (ARDOUR::Route&);
731
732         Splash* splash;
733
734         void pop_back_splash (Gtk::Window&);
735
736         /* cleanup */
737
738         Gtk::MenuItem *cleanup_item;
739
740         void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
741         void cleanup ();
742         void cleanup_peakfiles ();
743         void flush_trash ();
744
745         bool have_configure_timeout;
746         ARDOUR::microseconds_t last_configure_time;
747         gint configure_timeout ();
748
749         ARDOUR::microseconds_t last_peak_grab;
750         ARDOUR::microseconds_t last_shuttle_request;
751
752         bool have_disk_speed_dialog_displayed;
753         void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
754         void disk_overrun_handler ();
755         void disk_underrun_handler ();
756         void gui_idle_handler ();
757
758         void cancel_plugin_scan ();
759         void cancel_plugin_timeout ();
760         void plugin_scan_dialog (std::string type, std::string plugin, bool);
761         void plugin_scan_timeout (int);
762
763         void session_format_mismatch (std::string, std::string);
764
765         void session_dialog (std::string);
766         int pending_state_dialog ();
767         int sr_mismatch_dialog (ARDOUR::samplecnt_t, ARDOUR::samplecnt_t);
768         void sr_mismatch_message (ARDOUR::samplecnt_t, ARDOUR::samplecnt_t);
769
770         Gtk::MenuItem* jack_disconnect_item;
771         Gtk::MenuItem* jack_reconnect_item;
772         Gtk::Menu*     jack_bufsize_menu;
773
774         Glib::RefPtr<Gtk::ActionGroup> common_actions;
775
776         void editor_realized ();
777
778         std::vector<std::string> positional_sync_strings;
779
780         void toggle_use_mmc ();
781         void toggle_send_mmc ();
782         void toggle_send_mtc ();
783         void toggle_send_midi_clock ();
784
785         void toggle_use_osc ();
786
787         void parameter_changed (std::string);
788         void session_parameter_changed (std::string);
789
790         bool first_idle ();
791
792         void check_memory_locking ();
793
794         void audioengine_setup ();
795
796         void display_message (const char* prefix, gint prefix_len, Glib::RefPtr<Gtk::TextBuffer::Tag>, Glib::RefPtr<Gtk::TextBuffer::Tag>, const char* msg);
797         Gtk::Label status_bar_label;
798         bool status_bar_button_press (GdkEventButton*);
799
800         void loading_message (const std::string& msg);
801
802         PBD::ScopedConnectionList forever_connections;
803         PBD::ScopedConnection halt_connection;
804         PBD::ScopedConnection editor_meter_connection;
805
806         /* these are used only in response to a platform-specific "ShouldQuit" signal */
807         bool idle_finish ();
808         void queue_finish ();
809         void fontconfig_dialog ();
810
811         int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
812         int ambiguous_file (std::string file, std::vector<std::string> hits);
813
814         bool click_button_clicked (GdkEventButton *);
815         bool sync_button_clicked (GdkEventButton *);
816
817         VisibilityGroup _status_bar_visibility;
818
819         /** A ProcessThread so that we have some thread-local buffers for use by
820          *  PluginEqGui::impulse_analysis ().
821          */
822         ARDOUR::ProcessThread* _process_thread;
823
824         void feedback_detected ();
825
826         ArdourWidgets::ArdourButton             midi_panic_button;
827         void                     midi_panic ();
828
829         void successful_graph_sort ();
830         bool _feedback_exists;
831
832         enum ArdourLogLevel {
833                 LogLevelNone = 0,
834                 LogLevelInfo,
835                 LogLevelWarning,
836                 LogLevelError
837         };
838
839         ArdourLogLevel _log_not_acknowledged;
840
841         void resize_text_widgets ();
842
843         bool xrun_button_release (GdkEventButton* ev);
844
845         std::string _announce_string;
846         void check_announcements ();
847
848         int do_audio_midi_setup (uint32_t);
849         void audioengine_became_silent ();
850
851         DuplicateRouteDialog* duplicate_routes_dialog;
852
853         void grab_focus_after_dialog ();
854
855         void tabs_switch (GtkNotebookPage*, guint page_number);
856         void tabs_page_added (Gtk::Widget*, guint);
857         void tabs_page_removed (Gtk::Widget*, guint);
858         ArdourWidgets::ArdourButton editor_visibility_button;
859         ArdourWidgets::ArdourButton mixer_visibility_button;
860         ArdourWidgets::ArdourButton prefs_visibility_button;
861
862         bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev, Gtkmm2ext::Bindings*);
863         bool try_gtk_accel_binding (GtkWindow* win, GdkEventKey* ev, bool translate, GdkModifierType modifier);
864
865         bool main_window_delete_event (GdkEventAny*);
866         bool idle_ask_about_quit ();
867
868         void load_bindings ();
869         bool tabbable_visibility_button_press (GdkEventButton* ev, std::string const& tabbable_name);
870
871         void step_up_through_tabs ();
872         void step_down_through_tabs ();
873
874         void escape ();
875         void close_current_dialog ();
876         void pre_release_dialog ();
877
878         bool bind_lua_action_script (GdkEventButton*, int);
879         void update_action_script_btn (int i, const std::string&);
880 };
881
882 #endif /* __ardour_gui_h__ */