+ARDOUR_UI::edit_metadata ()
+{
+ SessionMetadataEditor dialog;
+ dialog.set_session (session);
+ editor->ensure_float (dialog);
+ dialog.run ();
+}
+
+void
+ARDOUR_UI::import_metadata ()
+{
+ SessionMetadataImporter dialog;
+ dialog.set_session (session);
+ editor->ensure_float (dialog);
+ dialog.run ();
+}
+
+void
+ARDOUR_UI::fontconfig_dialog ()
+{
+#ifdef GTKOSX
+ /* X11 users will always have fontconfig info around, but new GTK-OSX users
+ may not and it can take a while to build it. Warn them.
+ */
+
+ Glib::ustring fontconfig = Glib::build_filename (Glib::get_home_dir(), ".fontconfig");
+
+ if (!Glib::file_test (fontconfig, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_DIR)) {
+ MessageDialog msg (*new_session_dialog,
+ _("Welcome to Ardour.\n\n"
+ "The program will take a bit longer to start up\n"
+ "while the system fonts are checked.\n\n"
+ "This will only be done once, and you will\n"
+ "not see this message again\n"),
+ true,
+ Gtk::MESSAGE_INFO,
+ Gtk::BUTTONS_OK);
+ pop_back_splash ();
+ msg.show_all ();
+ msg.present ();
+ msg.run ();
+ }
+#endif
+}
+
+void
+ARDOUR_UI::parse_cmdline_path (const Glib::ustring& cmdline_path, Glib::ustring& session_name, Glib::ustring& session_path, bool& existing_session)
+{
+ existing_session = false;
+
+ if (Glib::file_test (cmdline_path, Glib::FILE_TEST_IS_DIR)) {
+ session_path = cmdline_path;
+ existing_session = true;
+ } else if (Glib::file_test (cmdline_path, Glib::FILE_TEST_IS_REGULAR)) {
+ session_path = Glib::path_get_dirname (string (cmdline_path));
+ existing_session = true;
+ } else {
+ /* it doesn't exist, assume the best */
+ session_path = Glib::path_get_dirname (string (cmdline_path));
+ }
+
+ session_name = basename_nosuffix (string (cmdline_path));
+}
+
+int
+ARDOUR_UI::load_cmdline_session (const Glib::ustring& session_name, const Glib::ustring& session_path, bool& existing_session)
+{
+ /* when this is called, the backend audio system must be running */
+
+ /* the main idea here is to deal with the fact that a cmdline argument for the session
+ can be interpreted in different ways - it could be a directory or a file, and before
+ we load, we need to know both the session directory and the snapshot (statefile) within it
+ that we are supposed to use.
+ */
+
+ if (session_name.length() == 0 || session_path.length() == 0) {
+ return false;
+ }
+
+ if (Glib::file_test (session_path, Glib::FILE_TEST_IS_DIR)) {
+
+ Glib::ustring predicted_session_file;
+
+ predicted_session_file = session_path;
+ predicted_session_file += '/';
+ predicted_session_file += session_name;
+ predicted_session_file += ARDOUR::statefile_suffix;
+
+ if (Glib::file_test (predicted_session_file, Glib::FILE_TEST_EXISTS)) {
+ existing_session = true;
+ }
+
+ } else if (Glib::file_test (session_path, Glib::FILE_TEST_EXISTS)) {
+
+ if (session_path.find (ARDOUR::statefile_suffix) == session_path.length() - 7) {
+ /* existing .ardour file */
+ existing_session = true;
+ }
+
+ } else {
+ existing_session = false;
+ }
+
+ /* lets just try to load it */
+
+ if (create_engine ()) {
+ backend_audio_error (false, new_session_dialog);
+ return -1;
+ }
+
+ return load_session (session_path, session_name);
+}
+
+bool
+ARDOUR_UI::ask_about_loading_existing_session (const Glib::ustring& session_path)
+{
+ Glib::ustring str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
+
+ MessageDialog msg (str,
+ false,
+ Gtk::MESSAGE_WARNING,
+ Gtk::BUTTONS_YES_NO,
+ true);
+
+
+ msg.set_name (X_("CleanupDialog"));
+ msg.set_wmclass (X_("existing_session"), "Ardour");
+ msg.set_position (Gtk::WIN_POS_MOUSE);
+ pop_back_splash ();
+
+ switch (msg.run()) {
+ case RESPONSE_YES:
+ return true;
+ break;
+ }
+ return false;
+}
+
+int
+ARDOUR_UI::build_session_from_nsd (const Glib::ustring& session_path, const Glib::ustring& session_name)
+{
+
+ uint32_t cchns;
+ uint32_t mchns;
+ AutoConnectOption iconnect;
+ AutoConnectOption oconnect;
+ uint32_t nphysin;
+ uint32_t nphysout;
+
+ if (Profile->get_sae()) {
+
+ cchns = 0;
+ mchns = 2;
+ iconnect = AutoConnectPhysical;
+ oconnect = AutoConnectMaster;
+ nphysin = 0; // use all available
+ nphysout = 0; // use all available
+
+ } else {
+
+ /* get settings from advanced section of NSD */
+
+ if (new_session_dialog->create_control_bus()) {
+ cchns = (uint32_t) new_session_dialog->control_channel_count();
+ } else {
+ cchns = 0;
+ }
+
+ if (new_session_dialog->create_master_bus()) {
+ mchns = (uint32_t) new_session_dialog->master_channel_count();
+ } else {
+ mchns = 0;
+ }
+
+ if (new_session_dialog->connect_inputs()) {
+ iconnect = AutoConnectPhysical;
+ } else {
+ iconnect = AutoConnectOption (0);
+ }
+
+ /// @todo some minor tweaks.
+
+ if (new_session_dialog->connect_outs_to_master()) {
+ oconnect = AutoConnectMaster;
+ } else if (new_session_dialog->connect_outs_to_physical()) {
+ oconnect = AutoConnectPhysical;
+ } else {
+ oconnect = AutoConnectOption (0);
+ }
+
+ nphysin = (uint32_t) new_session_dialog->input_limit_count();
+ nphysout = (uint32_t) new_session_dialog->output_limit_count();
+ }
+
+ if (build_session (session_path,
+ session_name,
+ cchns,
+ mchns,
+ iconnect,
+ oconnect,
+ nphysin,
+ nphysout,
+ engine->frame_rate() * 60 * 5)) {
+
+ return -1;
+ }
+
+ return 0;
+}
+
+void
+ARDOUR_UI::end_loading_messages ()
+{
+ // hide_splash ();
+}
+
+void
+ARDOUR_UI::loading_message (const std::string& msg)
+{
+ show_splash ();
+ splash->message (msg);
+ flush_pending ();
+}
+
+void
+ARDOUR_UI::idle_load (const Glib::ustring& path)
+{
+ if (session) {
+ if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
+ /* /path/to/foo => /path/to/foo, foo */
+ load_session (path, basename_nosuffix (path));
+ } else {
+ /* /path/to/foo/foo.ardour => /path/to/foo, foo */
+ load_session (Glib::path_get_dirname (path), basename_nosuffix (path));
+ }
+ } else {
+
+ ARDOUR_COMMAND_LINE::session_name = path;
+
+ if (new_session_dialog) {
+
+
+ /* make it break out of Dialog::run() and
+ start again.
+ */
+
+ new_session_dialog->response (1);
+ }
+ }
+}
+
+/** @param offer_quit true to offer a Cancel button, otherwise call it Quit */
+bool
+ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be_new, bool offer_cancel)