2 Copyright (C) 2000-2006 Paul Davis
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.
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.
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.
20 #include <sys/types.h>
27 #include "pbd/pthread_utils.h"
28 #include "pbd/basename.h"
29 #include "pbd/shortpath.h"
30 #include "pbd/stateful_diff_command.h"
32 #include "ardour/audio_track.h"
33 #include "ardour/audiofilesource.h"
34 #include "ardour/audioregion.h"
35 #include "ardour/midi_region.h"
36 #include "ardour/midi_track.h"
37 #include "ardour/midi_model.h"
38 #include "ardour/operations.h"
39 #include "ardour/region_factory.h"
40 #include "ardour/smf_source.h"
41 #include "ardour/source_factory.h"
42 #include "ardour/utils.h"
43 #include "ardour/playlist.h"
44 #include "ardour/session.h"
45 #include "pbd/memento_command.h"
47 #include "ptformat/ptfformat.h"
49 #include "ardour_ui.h"
50 #include "cursor_context.h"
54 #include "audio_time_axis.h"
55 #include "midi_time_axis.h"
56 #include "session_import_dialog.h"
57 #include "gui_thread.h"
58 #include "interthread_progress_window.h"
59 #include "mouse_cursors.h"
60 #include "editor_cursors.h"
61 #include "pt_import_selector.h"
66 using namespace ARDOUR;
69 using namespace Gtkmm2ext;
70 using namespace Editing;
73 /* Editor dialogs supporting the incorporation of PT sessions into ardour */
76 Editor::external_pt_dialog ()
81 MessageDialog msg (_("You can't import a PT session until you have a session loaded."));
86 PTImportSelector dialog (import_ptf);
87 dialog.set_session (_session);
90 int result = dialog.run ();
92 if (result == Gtk::RESPONSE_ACCEPT) {
94 import_pt_status.all_done = false;
96 ImportProgressWindow ipw (&import_pt_status, _("PT Import"), _("Cancel Import"));
97 pthread_create_and_store ("import_pt", &import_pt_status.thread, _import_pt_thread, this);
98 pthread_detach (import_pt_status.thread);
102 while (!import_pt_status.all_done) {
103 gtk_main_iteration ();
106 // wait for thread to terminate
107 while (!import_pt_status.done) {
108 gtk_main_iteration ();
111 if (import_pt_status.cancel) {
112 MessageDialog msg (_("PT import may have missing files, check session log for details"));
115 MessageDialog msg (_("PT import complete!"));
119 } else if (result == Gtk::RESPONSE_CANCEL) {
126 Editor::_import_pt_thread (void *arg)
128 SessionEvent::create_per_thread_pool ("import pt events", 64);
130 Editor *ed = (Editor *) arg;
131 return ed->import_pt_thread ();
135 Editor::import_pt_thread ()
137 _session->import_pt (import_ptf, import_pt_status);