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