From d67d64ea03c4e722b1c50b4019b989b09a8ff1de Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 12 Aug 2019 16:53:55 +0200 Subject: Add Pref to write mixer-screenshot post-export --- gtk2_ardour/export_dialog.cc | 38 +++++++++++++++++++++++++++++++++++++- gtk2_ardour/rc_option_editor.cc | 10 +++++++++- gtk2_ardour/ui_config_vars.h | 1 + 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/export_dialog.cc b/gtk2_ardour/export_dialog.cc index e366af03d2..cc19965a9c 100644 --- a/gtk2_ardour/export_dialog.cc +++ b/gtk2_ardour/export_dialog.cc @@ -31,8 +31,12 @@ #include #include +#include "pbd/gstdio_compat.h" +#include "pbd/file_utils.h" + #include "ardour/audioregion.h" #include "ardour/export_channel_configuration.h" +#include "ardour/export_format_specification.h" #include "ardour/export_status.h" #include "ardour/export_handler.h" #include "ardour/profile.h" @@ -40,7 +44,9 @@ #include "export_dialog.h" #include "export_report.h" #include "gui_thread.h" +#include "mixer_ui.h" #include "nag.h" +#include "ui_config.h" #include "pbd/i18n.h" @@ -52,7 +58,6 @@ ExportDialog::ExportDialog (PublicEditor & editor, std::string title, ARDOUR::Ex : ArdourDialog (title) , type (type) , editor (editor) - , warn_label ("", Gtk::ALIGN_LEFT) , list_files_label (_("Some already existing files will be overwritten."), Gtk::ALIGN_RIGHT) , list_files_button (_("List files")) @@ -380,6 +385,37 @@ ExportDialog::show_progress () status->finish (); + 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 (); + + std::list paths; + for (ExportProfileManager::FilenameStateList::const_iterator fi = filenames.begin(); fi != filenames.end(); ++fi) { + for (ExportProfileManager::TimespanStateList::const_iterator ti = timespans.begin(); ti != timespans.end(); ++ti) { + ExportProfileManager::TimespanListPtr tlp = (*ti)->timespans; + for (ExportProfileManager::TimespanList::const_iterator eti = tlp->begin(); eti != tlp->end(); ++eti) { + (*fi)->filename->set_timespan (*eti); + paths.push_back ((*fi)->filename->get_path (ExportFormatSpecPtr ()) + "-mixer.png"); + } + } + } + + if (paths.size() > 0) { + PBD::info << string_compose(_("Writing Mixer Screenshot: %1."), paths.front()) << endmsg; + Mixer_UI::instance()->screenshot (paths.front()); + + std::list::const_iterator it = paths.begin (); + ++it; + for (; it != paths.end(); ++it) { + PBD::info << string_compose(_("Copying Mixer Screenshot: %1."), *it) << endmsg; + ::g_unlink (it->c_str()); + if (!hard_link (paths.front(), *it)) { + copy_file (paths.front(), *it); + } + } + } + } + if (!status->aborted() && status->result_map.size() > 0) { hide(); ExportReport er (_session, status); diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index ca2d1c8d06..de2e24f7e3 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -3085,11 +3085,19 @@ RCOptionEditor::RCOptionEditor () add_option (S_("Preferences|Metering"), new BoolOption ( "save-export-analysis-image", - _("Save loudness analysis as image file"), + _("Save loudness analysis as image file after export"), sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_save_export_analysis_image), sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_save_export_analysis_image) )); + add_option (S_("Preferences|Metering"), + new BoolOption ( + "save-export-mixer-screenshot", + _("Save Mixer screenshot after export"), + sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_save_export_mixer_screenshot), + sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_save_export_mixer_screenshot) + )); + /* TRANSPORT & Sync */ add_option (_("Transport"), new OptionEditorHeading (_("General"))); diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h index a84241648d..70d332ab21 100644 --- a/gtk2_ardour/ui_config_vars.h +++ b/gtk2_ardour/ui_config_vars.h @@ -106,6 +106,7 @@ UI_CONFIG_VARIABLE (bool, cairo_image_surface, "cairo-image-surface", false) UI_CONFIG_VARIABLE (uint64_t, waveform_cache_size, "waveform-cache-size", 100) /* units of megagbytes */ UI_CONFIG_VARIABLE (int32_t, recent_session_sort, "recent-session-sort", 0) UI_CONFIG_VARIABLE (bool, save_export_analysis_image, "save-export-analysis-image", false) +UI_CONFIG_VARIABLE (bool, save_export_mixer_screenshot, "save-export-mixer-screenshot", false) UI_CONFIG_VARIABLE (bool, open_gui_after_adding_plugin, "open-gui-after-adding-plugin", true) UI_CONFIG_VARIABLE (bool, show_inline_display_by_default, "show-inline-display-by-default", true) UI_CONFIG_VARIABLE (bool, prefer_inline_over_gui, "prefer-inline-over-gui", true) -- cgit v1.2.3