Let the user add a template description on saving session templates
[ardour.git] / gtk2_ardour / save_template_dialog.cc
1 /*
2     Copyright (C) 2017 Paul Davis
3     Author: Johannes Mueller
4
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.
9
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.
14
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.
18
19 */
20
21 #include <gtkmm/box.h>
22 #include <gtkmm/frame.h>
23 #include <gtkmm/label.h>
24 #include <gtkmm/stock.h>
25
26 #include "pbd/i18n.h"
27 #include "ardour/session.h"
28
29 #include "save_template_dialog.h"
30
31 using namespace Gtk;
32 using namespace ARDOUR;
33
34 SaveTemplateDialog::SaveTemplateDialog (const Session& s)
35         : ArdourDialog (_("Save as template"))
36 {
37         _name_editor.get_buffer()->set_text (s.name() + _("-template"));
38         _description_editor.set_wrap_mode (Gtk::WRAP_WORD);
39         _description_editor.set_size_request(400, 300);
40
41         HBox* hb = manage (new HBox);
42         hb->set_spacing (8);
43         Label* lb = manage (new Label(_("Template name:")));
44         hb->pack_start (*lb, false, true);
45         hb->pack_start (_name_editor, true, true);
46
47         Frame* fd = manage (new Frame(_("Description:")));
48         fd->add (_description_editor);
49
50         get_vbox()->set_spacing (8);
51         get_vbox()->pack_start (*fd);
52         get_vbox()->pack_start (*hb);
53
54         add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
55         add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
56
57         show_all_children ();
58 }
59
60
61 std::string
62 SaveTemplateDialog::get_template_name () const
63 {
64         return _name_editor.get_buffer()->get_text();
65 }
66
67 std::string
68 SaveTemplateDialog::get_description () const
69 {
70         return _description_editor.get_buffer()->get_text();
71 }