Merge branch 'master' into windows
[ardour.git] / gtk2_ardour / editor_videotimeline.cc
index a58a896fdd6f0341e4bfb0af82fc1da3b851959f..e9360d9d09e457e690f9977df0e559cf8a00c900 100644 (file)
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 */
-#ifdef WITH_VIDEOTIMELINE
 
 #include <jack/types.h>
 
+#include <glib/gstdio.h>
+
 #include "ardour/profile.h"
 #include "ardour/rc_configuration.h"
+#include "ardour/audio_track.h"
+#include "ardour/audioregion.h"
 
 #include "ardour_ui.h"
 #include "editor.h"
@@ -33,7 +36,9 @@
 #include "video_image_frame.h"
 #include "export_video_dialog.h"
 #include "export_video_infobox.h"
+#include "interthread_progress_window.h"
 
+#include "pbd/openuri.h"
 #include "i18n.h"
 
 using namespace std;
@@ -95,11 +100,27 @@ Editor::embed_audio_from_video (std::string path, framepos_t n)
        vector<std::string> paths;
        paths.push_back(path);
 #if 0
-       do_embed (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, n);
-#else
        do_import (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, ARDOUR::SrcBest, n);
-       unlink(path.c_str());
+#else
+       current_interthread_info = &import_status;
+       import_status.current = 1;
+       import_status.total = paths.size ();
+       import_status.all_done = false;
+
+       ImportProgressWindow ipw (&import_status, _("Import"), _("Cancel Import"));
+       ipw.show ();
+
+       boost::shared_ptr<ARDOUR::Track> track;
+       bool ok = (import_sndfiles (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, ARDOUR::SrcBest, n, 1, 1, track, false) == 0);
+       if (ok && track) {
+               boost::shared_ptr<ARDOUR::Playlist> pl = track->playlist();
+               pl->find_next_region(n, ARDOUR::End, 0)->set_video_locked(true);
+               _session->save_state ("");
+       }
+
+       import_status.all_done = true;
 #endif
+       ::g_unlink(path.c_str());
 }
 
 void
@@ -107,10 +128,17 @@ Editor::export_video ()
 {
        if (ARDOUR::Config->get_show_video_export_info()) {
                ExportVideoInfobox infobox (_session);
-               infobox.run();
+               Gtk::ResponseType rv = (Gtk::ResponseType) infobox.run();
                if (infobox.show_again()) {
                        ARDOUR::Config->set_show_video_export_info(false);
                }
+               switch (rv) {
+                       case GTK_RESPONSE_YES:
+                               PBD::open_uri (ARDOUR::Config->get_reference_manual_url() + "/video-timeline/operations/#export");
+                               break;
+                       default:
+                               break;
+               }
        }
        ExportVideoDialog dialog (*this, _session);
        Gtk::ResponseType r = (Gtk::ResponseType) dialog.run();
@@ -121,5 +149,3 @@ Editor::export_video ()
        }
 #endif
 }
-
-#endif /* WITH_VIDEOTIMELINE */