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