2 * Copyright (C) 2010-2011 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2011-2016 Paul Davis <paul@linuxaudiosystems.com>
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>
21 #include "new_plugin_preset_dialog.h"
27 NewPluginPresetDialog::NewPluginPresetDialog (boost::shared_ptr<ARDOUR::Plugin> p, std::string title, bool favorite_btn)
28 : ArdourDialog (title)
29 , _replace (_("Replace existing preset with this name"))
31 HBox* h = manage (new HBox);
33 h->pack_start (*manage (new Label (_("Name of new preset"))));
34 h->pack_start (_name);
36 get_vbox()->set_spacing (6);
37 get_vbox()->pack_start (*h);
39 get_vbox()->pack_start (_replace);
41 add_button (Stock::CANCEL, RESPONSE_CANCEL);
43 add_button (_("New Favorite Only"), RESPONSE_NO);
45 _add = add_button (Stock::ADD, RESPONSE_ACCEPT);
46 set_default_response (RESPONSE_ACCEPT);
47 _name.set_activates_default(true);
52 _presets = p->get_presets ();
54 _name.signal_changed().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
55 _replace.signal_toggled().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
61 NewPluginPresetDialog::setup_sensitivity ()
63 if (_name.get_text().empty()) {
64 _replace.set_sensitive (false);
65 _add->set_sensitive (false);
69 vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = _presets.begin ();
70 while (i != _presets.end() && i->label != _name.get_text()) {
74 if (i != _presets.end ()) {
75 _replace.set_sensitive (true);
76 _add->set_sensitive (_replace.get_active ());
78 _replace.set_sensitive (false);
79 _add->set_sensitive (true);
84 NewPluginPresetDialog::name () const
86 return _name.get_text ();
90 NewPluginPresetDialog::replace () const
92 return _replace.get_active ();