2 * Copyright (C) 2015-2019 Damien Zammit <damien@zamaudio.com>
3 * Copyright (C) 2016-2017 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2016-2018 Robin Gareus <robin@gareus.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <sys/types.h>
28 #include "pbd/pthread_utils.h"
29 #include "pbd/basename.h"
30 #include "pbd/shortpath.h"
31 #include "pbd/stateful_diff_command.h"
33 #include "ardour/audio_track.h"
34 #include "ardour/audiofilesource.h"
35 #include "ardour/audioregion.h"
36 #include "ardour/midi_region.h"
37 #include "ardour/midi_track.h"
38 #include "ardour/midi_model.h"
39 #include "ardour/operations.h"
40 #include "ardour/region_factory.h"
41 #include "ardour/smf_source.h"
42 #include "ardour/source_factory.h"
43 #include "ardour/utils.h"
44 #include "ardour/playlist.h"
45 #include "ardour/session.h"
46 #include "pbd/memento_command.h"
48 #include "ptformat/ptformat.h"
50 #include "ardour_ui.h"
51 #include "cursor_context.h"
55 #include "audio_time_axis.h"
56 #include "midi_time_axis.h"
57 #include "session_import_dialog.h"
58 #include "gui_thread.h"
59 #include "interthread_progress_window.h"
60 #include "mouse_cursors.h"
61 #include "editor_cursors.h"
62 #include "pt_import_selector.h"
67 using namespace ARDOUR;
70 using namespace Gtkmm2ext;
71 using namespace Editing;
74 /* Editor dialogs supporting the incorporation of PT sessions into ardour */
77 Editor::external_pt_dialog ()
82 MessageDialog msg (_("You can't import a PT session until you have a session loaded."));
87 PTImportSelector dialog (import_ptf);
88 dialog.set_session (_session);
91 int result = dialog.run ();
93 if (result == Gtk::RESPONSE_ACCEPT) {
95 import_pt_status.all_done = false;
97 ImportProgressWindow ipw (&import_pt_status, _("PT Import"), _("Cancel Import"));
98 pthread_create_and_store ("import_pt", &import_pt_status.thread, _import_pt_thread, this);
99 pthread_detach (import_pt_status.thread);
103 while (!import_pt_status.all_done) {
104 gtk_main_iteration ();
107 // wait for thread to terminate
108 while (!import_pt_status.done) {
109 gtk_main_iteration ();
112 if (import_pt_status.cancel) {
113 MessageDialog msg (_("PT import may have missing files, check session log for details"));
116 MessageDialog msg (_("PT import complete!"));
120 } else if (result == Gtk::RESPONSE_CANCEL) {
127 Editor::_import_pt_thread (void *arg)
129 SessionEvent::create_per_thread_pool ("import pt events", 64);
131 Editor *ed = (Editor *) arg;
132 return ed->import_pt_thread ();
136 Editor::import_pt_thread ()
138 _session->import_pt (import_ptf, import_pt_status);