make save-as dialog be persistent, to retain settings across save-as
[ardour.git] / gtk2_ardour / save_as_dialog.cc
1 /*
2     Copyright (C) 2015 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <gtkmm/stock.h>
21
22 #include "ardour/session.h"
23
24 #include "save_as_dialog.h"
25
26 #include "i18n.h"
27
28 using namespace std;
29 using namespace Gtk;
30 using namespace ARDOUR;
31
32 SaveAsDialog::SaveAsDialog ()
33         : ArdourDialog (_("Save As"))
34         , switch_to_button (_("Switch to newly-saved version"))
35         , copy_media_button (_("Copy media to new session"))
36         , copy_external_button (_("Copy external media into new session"))
37 {
38         VBox* vbox = get_vbox();
39
40         vbox->set_spacing (6);
41         
42         HBox* hbox;
43         Label* label;
44
45         hbox = manage (new HBox);
46         hbox->set_spacing (6);
47         label = manage (new Label (_("Save as session name")));
48         hbox->pack_start (*label, false, false);
49         hbox->pack_start (new_name_entry, true, true);
50         vbox->pack_start (*hbox, false, false);
51
52         hbox = manage (new HBox);
53         hbox->set_spacing (6);
54         label = manage (new Label (_("Parent directory/folder")));
55         hbox->pack_start (*label, false, false);
56         hbox->pack_start (new_parent_folder_selector, true, true);
57         vbox->pack_start (*hbox, false, false);
58
59         vbox->pack_start (switch_to_button, false, false);
60         vbox->pack_start (copy_media_button, false, false);
61         vbox->pack_start (copy_external_button, false, false);
62
63         switch_to_button.set_active (true);
64         copy_media_button.set_active (true);
65         
66         vbox->show_all ();
67
68         add_button (Stock::CANCEL, RESPONSE_CANCEL);
69         add_button (Stock::OK, RESPONSE_OK);
70
71         new_parent_folder_selector.set_action (FILE_CHOOSER_ACTION_SELECT_FOLDER);
72         new_parent_folder_selector.set_current_folder (Glib::get_home_dir());
73         new_name_entry.signal_changed().connect (sigc::mem_fun (*this, &SaveAsDialog::name_entry_changed));
74         set_response_sensitive (RESPONSE_OK, false);
75 }
76
77 void
78 SaveAsDialog::name_entry_changed ()
79 {
80         if (!new_name_entry.get_text().empty()) {
81                 set_response_sensitive (RESPONSE_OK);
82         }
83 }
84
85 string
86 SaveAsDialog::new_parent_folder () const
87 {
88         return new_parent_folder_selector.get_current_folder ();
89 }
90
91 string
92 SaveAsDialog::new_name () const
93 {
94         return new_name_entry.get_text ();
95 }
96
97 bool
98 SaveAsDialog::switch_to () const
99 {
100         return switch_to_button.get_active ();
101 }
102
103 bool
104 SaveAsDialog::copy_media () const
105 {
106         return copy_media_button.get_active ();
107 }
108
109 bool
110 SaveAsDialog::copy_external () const
111 {
112         return copy_external_button.get_active ();
113 }
114
115 void
116 SaveAsDialog::clear_name ()
117 {
118         new_name_entry.set_text ("");
119         set_response_sensitive (RESPONSE_OK, false);
120 }