2 Copyright (C) 2015 Paul Davis
3 Copyright (C) 2016 Robin Gareus <robin@gareus.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gtkmm/stock.h>
23 #include "ardour/session.h"
25 #include "session_archive_dialog.h"
31 using namespace ARDOUR;
33 SessionArchiveDialog::SessionArchiveDialog ()
34 : ArdourDialog (_("Zip/Archive Current Session"))
36 , only_used_checkbox (_("Exclude unused audio sources"))
38 VBox* vbox = get_vbox();
40 vbox->set_spacing (6);
45 format_selector.append_text (".tar.xz");
46 format_selector.set_active_text (".tar.xz");
48 encode_selector.append_text (_("None"));
49 encode_selector.append_text (_("FLAC 16bit"));
50 encode_selector.append_text (_("FLAC 24bit"));
51 encode_selector.set_active_text ("FLAC 16bit"); // TODO remember
53 hbox = manage (new HBox);
54 hbox->set_spacing (6);
55 label = manage (new Label (_("Archive Name")));
56 hbox->pack_start (*label, false, false);
57 hbox->pack_start (name_entry, true, true);
58 hbox->pack_start (format_selector, false, false);
59 vbox->pack_start (*hbox, false, false);
61 hbox = manage (new HBox);
62 hbox->set_spacing (6);
63 label = manage (new Label (_("Target directory/folder")));
64 hbox->pack_start (*label, false, false);
65 hbox->pack_start (target_folder_selector, true, true);
66 vbox->pack_start (*hbox, false, false);
68 hbox = manage (new HBox);
69 hbox->set_spacing (6);
70 label = manage (new Label (_("Audio Compression")));
71 hbox->pack_start (*label, false, false);
72 hbox->pack_start (encode_selector, true, true);
73 vbox->pack_start (*hbox, false, false);
75 vbox->pack_start (only_used_checkbox, false, false);
77 label = manage (new Label (_("Note: This archives only the current session state, snapshots are not included."), ALIGN_START));
78 label->set_line_wrap (true);
79 vbox->pack_start (*label, false, false);
81 vbox->pack_start (progress_bar, true, true, 12);
86 add_button (Stock::CANCEL, RESPONSE_CANCEL);
87 add_button (Stock::OK, RESPONSE_OK);
89 target_folder_selector.set_action (FILE_CHOOSER_ACTION_SELECT_FOLDER);
90 target_folder_selector.set_current_folder (Config->get_default_session_parent_dir ()); // TODO get/set default_archive_dir
91 name_entry.signal_changed().connect (sigc::mem_fun (*this, &SessionArchiveDialog::name_entry_changed));
92 target_folder_selector.signal_current_folder_changed().connect (sigc::mem_fun (*this, &SessionArchiveDialog::name_entry_changed));
93 target_folder_selector.signal_selection_changed().connect (sigc::mem_fun (*this, &SessionArchiveDialog::name_entry_changed));
94 set_response_sensitive (RESPONSE_OK, false);
99 SessionArchiveDialog::name_entry_changed ()
101 if (name_entry.get_text().empty()) {
102 set_response_sensitive (RESPONSE_OK, false);
106 std::string dir = Glib::build_filename (target_folder(), name_entry.get_text() + format_selector.get_active_text ());
108 if (Glib::file_test (dir, Glib::FILE_TEST_EXISTS)) {
109 set_response_sensitive (RESPONSE_OK, false);
113 set_response_sensitive (RESPONSE_OK);
117 SessionArchiveDialog::target_folder () const
119 return target_folder_selector.get_filename ();
123 SessionArchiveDialog::set_target_folder (const std::string& name)
125 target_folder_selector.set_current_folder (name);
126 name_entry_changed ();
130 SessionArchiveDialog::name () const
132 return name_entry.get_text ();
136 SessionArchiveDialog::set_name (const std::string& name)
138 name_entry.set_text (name);
139 name_entry_changed ();
143 SessionArchiveDialog::only_used_sources () const
145 return only_used_checkbox.get_active ();
149 SessionArchiveDialog::set_only_used_sources (bool en)
151 only_used_checkbox.set_active (en);
154 ARDOUR::Session::ArchiveEncode
155 SessionArchiveDialog::encode_option () const
157 string codec = encode_selector.get_active_text ();
158 if (codec == _("FLAC 16bit")) {
159 return ARDOUR::Session::FLAC_16BIT;
161 if (codec == _("FLAC 24bit")) {
162 return ARDOUR::Session::FLAC_24BIT;
164 return ARDOUR::Session::NO_ENCODE;
168 SessionArchiveDialog::set_encode_option (ARDOUR::Session::ArchiveEncode e)
171 case ARDOUR::Session::FLAC_16BIT:
172 encode_selector.set_active_text (_("FLAC 16bit"));
174 case ARDOUR::Session::FLAC_24BIT:
175 encode_selector.set_active_text (_("FLAC 24bit"));
178 encode_selector.set_active_text (_("None"));
184 SessionArchiveDialog::update_progress_gui (float p)
186 set_response_sensitive (RESPONSE_OK, false);
187 set_response_sensitive (RESPONSE_CANCEL, false);
188 progress_bar.show ();
190 progress_bar.set_text (_("Archiving Session"));
194 progress_bar.set_text (_("Encoding Audio"));
197 progress_bar.set_fraction (p);