From 9c087492c7b009b76d51510e333fa84dc55fdf49 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 11 Mar 2022 04:22:56 +0100 Subject: [PATCH] GUI implementation to re-import exported file(s) --- gtk2_ardour/export_dialog.cc | 12 ++++++++++++ gtk2_ardour/export_dialog.h | 2 +- gtk2_ardour/export_file_notebook.cc | 20 ++++++++++++++++++++ gtk2_ardour/export_file_notebook.h | 4 ++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/export_dialog.cc b/gtk2_ardour/export_dialog.cc index 95f8c598b7..851552ed7b 100644 --- a/gtk2_ardour/export_dialog.cc +++ b/gtk2_ardour/export_dialog.cc @@ -367,6 +367,12 @@ ExportDialog::do_export () gui_context() ); #endif + + _files_to_reimport.clear (); + Session::Exported.connect_same_thread (*this, sigc::bind ( + [] (std::string, std::string fn, bool re, std::vector* v) { if (re) { (*v).push_back (fn); } }, + &_files_to_reimport)); + handler->do_export (); show_progress (); } catch(std::exception & e) { @@ -401,6 +407,12 @@ ExportDialog::show_progress () status->finish (TRS_UI); + if (!status->aborted() && !_files_to_reimport.empty ()) { + timepos_t pos (0); + Editing::ImportDisposition disposition = Editing::ImportDistinctFiles; + editor.do_import (_files_to_reimport, disposition, Editing::ImportAsTrack, SrcBest, SMFTrackNumber, SMFTempoIgnore, pos); + } + if (!status->aborted() && UIConfiguration::instance().get_save_export_mixer_screenshot ()) { ExportProfileManager::TimespanStateList const& timespans = profile_manager->get_timespans(); ExportProfileManager::FilenameStateList const& filenames = profile_manager->get_filenames (); diff --git a/gtk2_ardour/export_dialog.h b/gtk2_ardour/export_dialog.h index d2cc5ec719..3455768ff4 100644 --- a/gtk2_ardour/export_dialog.h +++ b/gtk2_ardour/export_dialog.h @@ -127,7 +127,7 @@ private: PublicEditor & editor; StatusPtr status; - + std::vector _files_to_reimport; /* Warning area */ diff --git a/gtk2_ardour/export_file_notebook.cc b/gtk2_ardour/export_file_notebook.cc index f53421d032..6e558e1739 100644 --- a/gtk2_ardour/export_file_notebook.cc +++ b/gtk2_ardour/export_file_notebook.cc @@ -128,6 +128,19 @@ ExportFileNotebook::FilePage::update_analysis_button () analysis_button.set_active (format_state->format->analyse()); } +void +ExportFileNotebook::FilePage::reimport_changed () +{ + format_state->format->set_reimport(reimport_button.get_active ()); + profile_manager->save_format_to_disk (format_state->format); +} + +void +ExportFileNotebook::FilePage::update_reimport_button () +{ + reimport_button.set_active (format_state->format->reimport ()); +} + void ExportFileNotebook::update_example_filenames () { @@ -209,6 +222,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, filename_label (_("Location"), Gtk::ALIGN_LEFT), soundcloud_upload_button (_("Upload to Soundcloud")), analysis_button (_("Analyze Exported Audio")), + reimport_button (_("Re-Import Exported Audio")), tab_number (number) { set_border_width (12); @@ -224,6 +238,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, hbox->pack_start (soundcloud_upload_button, false, false, 0); #endif hbox->pack_start (analysis_button, false, false, 0); + hbox->pack_start (reimport_button, false, false, 0); pack_start (*hbox, false, false, 0); format_align.add (format_selector); @@ -244,6 +259,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, format_selector.set_state (format_state, s); filename_selector.set_state (filename_state, s); analysis_button.set_active (format_state->format->analyse()); + reimport_button.set_active (format_state->format->reimport()); soundcloud_upload_button.set_active (format_state->format->soundcloud_upload()); /* Signals */ @@ -265,6 +281,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager, soundcloud_upload_button.signal_toggled().connect (sigc::mem_fun (*parent, &ExportFileNotebook::update_soundcloud_upload)); soundcloud_button_connection = soundcloud_upload_button.signal_toggled().connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::soundcloud_upload_changed)); analysis_button_connection = analysis_button.signal_toggled().connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::analysis_changed)); + reimport_button_connection = reimport_button.signal_toggled().connect (sigc::mem_fun (*this, &ExportFileNotebook::FilePage::reimport_changed)); /* Tab widget */ tab_close_button.add (*Gtk::manage (new Gtk::Image (::get_icon("close")))); @@ -367,10 +384,13 @@ ExportFileNotebook::FilePage::critical_selection_changed () soundcloud_button_connection.block (); analysis_button_connection.block (); + reimport_button_connection.block (); update_analysis_button(); + update_reimport_button(); update_soundcloud_upload_button(); + reimport_button_connection.unblock (); analysis_button_connection.unblock (); soundcloud_button_connection.unblock (); diff --git a/gtk2_ardour/export_file_notebook.h b/gtk2_ardour/export_file_notebook.h index 9182465fb7..c5d1d3334a 100644 --- a/gtk2_ardour/export_file_notebook.h +++ b/gtk2_ardour/export_file_notebook.h @@ -96,6 +96,7 @@ private: void update_example_filename(); void update_analysis_button (); + void update_reimport_button (); void update_soundcloud_upload_button (); ARDOUR::ExportProfileManager::FormatStatePtr get_format_state () const { return format_state; } @@ -108,6 +109,7 @@ private: void update_tab_label (); void critical_selection_changed (); void analysis_changed (); + void reimport_changed (); void soundcloud_upload_changed (); ARDOUR::ExportProfileManager::FormatStatePtr format_state; @@ -127,6 +129,7 @@ private: Gtk::CheckButton soundcloud_upload_button; Gtk::CheckButton analysis_button; + Gtk::CheckButton reimport_button; Gtk::HBox tab_widget; Gtk::Label tab_label; Gtk::Alignment tab_close_alignment; @@ -136,6 +139,7 @@ private: sigc::connection soundcloud_button_connection; sigc::connection analysis_button_connection; + sigc::connection reimport_button_connection; }; };