2 * Copyright (C) 2017-2018 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2017 Johannes Mueller <github@johannes-mueller.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/box.h>
21 #include <gtkmm/frame.h>
22 #include <gtkmm/label.h>
23 #include <gtkmm/stock.h>
25 #include "ardour/session.h"
27 #include "save_template_dialog.h"
32 using namespace ARDOUR;
34 SaveTemplateDialog::SaveTemplateDialog (const std::string& name, const std::string& desc)
35 : ArdourDialog (_("Save as template"))
37 _name_entry.get_buffer()->set_text (name);
38 _description_editor.get_buffer()->set_text (desc);
39 _description_editor.set_wrap_mode (Gtk::WRAP_WORD);
40 _description_editor.set_size_request(400, 300);
42 HBox* hb = manage (new HBox);
44 Label* lb = manage (new Label(_("Template name:")));
45 hb->pack_start (*lb, false, true);
46 hb->pack_start (_name_entry, true, true);
48 Frame* fd = manage (new Frame(_("Description:")));
49 fd->add (_description_editor);
51 get_vbox()->set_spacing (8);
52 get_vbox()->pack_start (*fd);
53 get_vbox()->pack_start (*hb);
55 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
56 add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
63 SaveTemplateDialog::get_template_name () const
65 return _name_entry.get_buffer()->get_text();
69 SaveTemplateDialog::get_description () const
71 std::string desc_txt = _description_editor.get_buffer()->get_text ();
72 std::string::reverse_iterator wss = desc_txt.rbegin();
73 while (wss != desc_txt.rend() && isspace (*wss)) {
74 desc_txt.erase (--(wss++).base());