1 /* 2 * Copyright (C) 2019 Paul Davis <paul@linuxaudiosystems.com> 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 along 15 * with this program; if not, write to the Free Software Foundation, Inc., 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 */ 18 19 #ifndef __gtk2_ardour_startup_fsm_h__ 20 #define __gtk2_ardour_startup_fsm_h__ 21 22 #include <string> 23 24 #include <sigc++/trackable.h> 25 26 #include "ardour/types.h" 27 28 class ArdourDialog; 29 class NewUserWizard; 30 class EngineControl; 31 class SessionDialog; 32 class PluginScanDialog; 33 34 class StartupFSM : public sigc::trackable 35 { 36 public: 37 enum DialogID { 38 PreReleaseDialog, 39 NewUserDialog, 40 NewSessionDialog, 41 AudioMIDISetup, 42 PluginDialog, 43 ApplicationPseudoDialog, 44 }; 45 46 enum Result { 47 LoadSession, 48 ExitProgram, 49 }; 50 51 enum MainState { 52 WaitingForPreRelease, 53 WaitingForNewUser, 54 WaitingForSessionPath, 55 WaitingForEngineParams, 56 WaitingForPlugins 57 }; 58 59 StartupFSM (EngineControl&); 60 ~StartupFSM (); 61 62 void start (); 63 void reset (); 64 65 std::string session_path; 66 std::string session_name; 67 std::string session_template; 68 int session_existing_sample_rate; 69 XMLNode session_engine_hints; 70 bool session_is_new; 71 bool session_name_edited; 72 73 ARDOUR::BusProfile bus_profile; 74 75 /* It's not a dialog but we provide this to make it behave like a (non-modal) 76 * dialog 77 */ 78 signal_response()79 sigc::signal1<void,Result>& signal_response() { return _signal_response; } 80 brand_new_user()81 bool brand_new_user() const { return new_user; } 82 void handle_path (std::string const & path); 83 84 private: 85 bool new_user; 86 bool new_session_required; 87 88 MainState _state; 89 90 void set_state (MainState); 91 void dialog_response_handler (int response, DialogID); 92 template<typename T> void end_dialog (T**); 93 template<typename T> void end_dialog (T&); 94 95 void show_new_user_dialog (); 96 void show_session_dialog (bool new_session_required); 97 void show_audiomidi_dialog (); 98 void show_pre_release_dialog (); 99 void show_plugin_scan_dialog (); 100 101 void copy_demo_sessions (); 102 bool get_session_parameters_from_command_line (bool new_session_required); 103 bool get_session_parameters_from_path (std::string const & path, std::string const & template_name, bool new_session_required); 104 void queue_finish (); 105 bool ask_about_loading_existing_session (const std::string& session_path); 106 int check_session_parameters (bool must_be_new); 107 void start_audio_midi_setup (); 108 void engine_running (); 109 void handle_waiting_for_session_path (); 110 111 /* the Audio/MIDI dialog needs to be persistent and is thus owned by 112 * ARDOUR_UI and we use it by reference. All other dialogs can be 113 * created and destroyed within the scope of startup. 114 */ 115 116 EngineControl& audiomidi_dialog; 117 NewUserWizard* new_user_dialog; 118 SessionDialog* session_dialog; 119 ArdourDialog* pre_release_dialog; 120 PluginScanDialog* plugin_scan_dialog; 121 122 sigc::connection current_dialog_connection; 123 124 sigc::signal1<void,Result> _signal_response; 125 126 void dialog_hidden (Gtk::Window*); 127 }; 128 129 #endif /* __gtk2_ardour_startup_fsm_h__ */ 130