2 * Copyright (C) 2015-2016 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2015-2019 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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <gtkmm/stock.h>
22 #include "ardour/session.h"
24 #include "gtkmm2ext/utils.h"
26 #include "save_as_dialog.h"
32 using namespace ARDOUR;
34 SaveAsDialog::SaveAsDialog ()
35 : ArdourDialog (_("Save As"))
36 , switch_to_button (_("Switch to newly-saved version"))
37 , copy_media_button (_("Copy media to new session"))
38 , copy_external_button (_("Copy external media into new session"))
39 , no_include_media_button (_("Newly-saved session should be empty"))
41 VBox* vbox = get_vbox();
43 vbox->set_spacing (6);
48 hbox = manage (new HBox);
49 hbox->set_spacing (6);
50 label = manage (new Label (_("Save as session name")));
51 hbox->pack_start (*label, false, false);
52 hbox->pack_start (new_name_entry, true, true);
53 vbox->pack_start (*hbox, false, false);
55 hbox = manage (new HBox);
56 hbox->set_spacing (6);
57 label = manage (new Label (_("Parent directory/folder")));
58 hbox->pack_start (*label, false, false);
59 hbox->pack_start (new_parent_folder_selector, true, true);
60 vbox->pack_start (*hbox, false, false);
62 vbox->pack_start (switch_to_button, false, false);
64 VBox* sub_vbox = manage (new VBox);
65 HBox* sub_hbox = manage (new HBox);
66 HBox* empty = manage (new HBox);
68 sub_vbox->pack_start (copy_media_button, false, false);
69 sub_vbox->pack_start (copy_external_button, false, false);
71 /* indent the two media-related buttons by some amount */
72 sub_hbox->set_spacing (24);
73 sub_hbox->pack_start (*empty, false, false);
74 sub_hbox->pack_start (*sub_vbox, false, false);
76 vbox->pack_start (no_include_media_button, false, false);
77 vbox->pack_start (*sub_hbox, false, false);
79 switch_to_button.set_active (true);
80 copy_media_button.set_active (true);
84 add_button (Stock::CANCEL, RESPONSE_CANCEL);
85 add_button (Stock::OK, RESPONSE_OK);
87 no_include_media_button.signal_toggled ().connect (sigc::mem_fun (*this, &SaveAsDialog::no_include_toggled));
89 Gtkmm2ext::add_volume_shortcuts (new_parent_folder_selector);
90 new_parent_folder_selector.set_action (FILE_CHOOSER_ACTION_SELECT_FOLDER);
91 new_parent_folder_selector.set_current_folder (Config->get_default_session_parent_dir ());
93 new_name_entry.signal_changed().connect (sigc::mem_fun (*this, &SaveAsDialog::name_entry_changed));
94 new_parent_folder_selector.signal_current_folder_changed().connect (sigc::mem_fun (*this, &SaveAsDialog::name_entry_changed));
95 new_parent_folder_selector.signal_selection_changed().connect (sigc::mem_fun (*this, &SaveAsDialog::name_entry_changed));
96 set_response_sensitive (RESPONSE_OK, false);
100 SaveAsDialog::no_include_toggled ()
102 if (no_include_media_button.get_active()) {
103 copy_media_button.set_sensitive (false);
104 copy_external_button.set_sensitive (false);
106 copy_media_button.set_sensitive (true);
107 copy_external_button.set_sensitive (true);
112 SaveAsDialog::name_entry_changed ()
114 if (new_name_entry.get_text().empty()) {
115 set_response_sensitive (RESPONSE_OK, false);
119 std::string dir = Glib::build_filename (new_parent_folder(), new_name_entry.get_text());
121 if (Glib::file_test (dir, Glib::FILE_TEST_EXISTS)) {
122 set_response_sensitive (RESPONSE_OK, false);
126 set_response_sensitive (RESPONSE_OK);
130 SaveAsDialog::new_parent_folder () const
132 return new_parent_folder_selector.get_filename ();
136 SaveAsDialog::new_name () const
138 return new_name_entry.get_text ();
142 SaveAsDialog::switch_to () const
144 return switch_to_button.get_active ();
148 SaveAsDialog::copy_media () const
150 return copy_media_button.get_active ();
154 SaveAsDialog::copy_external () const
156 return copy_external_button.get_active ();
160 SaveAsDialog::clear_name ()
162 new_name_entry.set_text ("");
163 set_response_sensitive (RESPONSE_OK, false);
167 SaveAsDialog::set_name (std::string name)
169 new_name_entry.set_text (name);
170 name_entry_changed ();
174 SaveAsDialog::include_media () const
176 return !no_include_media_button.get_active ();