Update Session-Archive Dialog: add compression-option

This commit is contained in:
Robin Gareus 2017-10-03 02:20:33 +02:00
parent 0802a0872f
commit f9710f4624
4 changed files with 77 additions and 24 deletions

View File

@ -2877,7 +2877,7 @@ ARDOUR_UI::archive_session ()
return;
}
if (_session->archive_session (sad.target_folder(), sad.name(), sad.encode_option (), sad.only_used_sources (), &sad)) {
if (_session->archive_session (sad.target_folder(), sad.name(), sad.encode_option (), sad.compression_level (), sad.only_used_sources (), &sad)) {
MessageDialog msg (_("Session Archiving failed."));
msg.run ();
}

View File

@ -19,8 +19,7 @@
*/
#include <gtkmm/stock.h>
#include "ardour/session.h"
#include <gtkmm/table.h>
#include "session_archive_dialog.h"
@ -39,9 +38,6 @@ SessionArchiveDialog::SessionArchiveDialog ()
vbox->set_spacing (6);
HBox* hbox;
Label* label;
format_selector.append_text (".tar.xz");
format_selector.set_active_text (".tar.xz");
@ -50,34 +46,56 @@ SessionArchiveDialog::SessionArchiveDialog ()
encode_selector.append_text (_("FLAC 24bit"));
encode_selector.set_active_text ("FLAC 16bit"); // TODO remember
hbox = manage (new HBox);
compression_selector.append_text (_("None"));
compression_selector.append_text (_("Fast"));
compression_selector.append_text (_("Good"));
compression_selector.set_active_text ("Good"); // TODO remember
Gtk::Table* table = manage (new Gtk::Table ());
table->set_col_spacings (10);
table->set_row_spacings (8);
Label* label;
int row = 0;
label = manage (new Label (_("Archive Name:"), Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false));
table->attach (*label, 0, 1, row, row + 1, Gtk::FILL, Gtk::SHRINK);
HBox* hbox = manage (new HBox);
hbox->set_spacing (6);
label = manage (new Label (_("Archive Name")));
hbox->pack_start (*label, false, false);
hbox->pack_start (name_entry, true, true);
hbox->pack_start (format_selector, false, false);
vbox->pack_start (*hbox, false, false);
table->attach (*hbox, 1, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
hbox = manage (new HBox);
hbox->set_spacing (6);
label = manage (new Label (_("Target directory/folder")));
hbox->pack_start (*label, false, false);
hbox->pack_start (target_folder_selector, true, true);
vbox->pack_start (*hbox, false, false);
++row;
hbox = manage (new HBox);
hbox->set_spacing (6);
label = manage (new Label (_("Audio Compression")));
hbox->pack_start (*label, false, false);
hbox->pack_start (encode_selector, true, true);
vbox->pack_start (*hbox, false, false);
label = manage (new Label (_("Target directory/folder:"), Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false));
table->attach (*label, 0, 1, row, row + 1, Gtk::FILL, Gtk::SHRINK);
table->attach (target_folder_selector, 1, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
vbox->pack_start (only_used_checkbox, false, false);
++row;
label = manage (new Label (_("Audio Compression:"), Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false));
table->attach (*label, 0, 1, row, row + 1, Gtk::FILL, Gtk::SHRINK);
table->attach (encode_selector, 1, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
++row;
label = manage (new Label (_("Archive Compression:"), Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false));
table->attach (*label, 0, 1, row, row + 1, Gtk::FILL, Gtk::SHRINK);
table->attach (compression_selector, 1, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
++row;
table->attach (only_used_checkbox, 0, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
++row;
label = manage (new Label (_("Note: This archives only the current session state, snapshots are not included."), ALIGN_START));
label->set_line_wrap (true);
vbox->pack_start (*label, false, false);
table->attach (*label, 0, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
vbox->pack_start (*table, false, false);
vbox->pack_start (progress_bar, true, true, 12);
vbox->show_all ();
@ -180,6 +198,34 @@ SessionArchiveDialog::set_encode_option (ARDOUR::Session::ArchiveEncode e)
}
}
PBD::FileArchive::CompressionLevel
SessionArchiveDialog::compression_level () const
{
string codec = compression_selector.get_active_text ();
if (codec == _("Fast")) {
return PBD::FileArchive::CompressFast;
} else if (codec == _("None")) {
return PBD::FileArchive::CompressNone;
}
return PBD::FileArchive::CompressGood;
}
void
SessionArchiveDialog::set_compression_level (PBD::FileArchive::CompressionLevel l)
{
switch (l) {
case PBD::FileArchive::CompressFast:
encode_selector.set_active_text (_("Fast"));
break;
case PBD::FileArchive::CompressNone:
encode_selector.set_active_text (_("None"));
break;
case PBD::FileArchive::CompressGood:
encode_selector.set_active_text (_("Good"));
break;
}
}
void
SessionArchiveDialog::update_progress_gui (float p)
{

View File

@ -27,6 +27,9 @@
#include <gtkmm/filechooserbutton.h>
#include <gtkmm/progressbar.h>
#include "pbd/file_archive.h"
#include "ardour/session.h"
#include "ardour_dialog.h"
#include "progress_reporter.h"
@ -38,11 +41,13 @@ public:
std::string target_folder () const;
std::string name () const;
ARDOUR::Session::ArchiveEncode encode_option () const;
PBD::FileArchive::CompressionLevel compression_level () const;
bool only_used_sources () const;
void set_name (const std::string&);
void set_target_folder (const std::string&);
void set_encode_option (ARDOUR::Session::ArchiveEncode);
void set_compression_level (PBD::FileArchive::CompressionLevel);
void set_only_used_sources (bool);
void on_response (int response_id) {
@ -54,6 +59,7 @@ private:
Gtk::Entry name_entry;
Gtk::ComboBoxText format_selector;
Gtk::ComboBoxText encode_selector;
Gtk::ComboBoxText compression_selector;
Gtk::CheckButton only_used_checkbox;
Gtk::ProgressBar progress_bar;

View File

@ -481,6 +481,7 @@ SessionDialog::setup_initial_choice_box ()
existing_session_chooser.add_filter (session_filter);
FileFilter archive_filter;
session_filter.add_pattern (string_compose(X_("*%1"), ARDOUR::session_archive_suffix));
archive_filter.add_pattern (X_("*.tar.xz"));
archive_filter.set_name (_("Session Archives"));
existing_session_chooser.add_filter (archive_filter);