2 Copyright (C) 2010 Paul Davis
3 Author: Carl Hetherington <cth@carlh.net>
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
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gtkmm/stock.h>
22 #include "new_plugin_preset_dialog.h"
28 NewPluginPresetDialog::NewPluginPresetDialog (boost::shared_ptr<ARDOUR::Plugin> p, std::string title, bool favorite_btn)
29 : ArdourDialog (title)
30 , _replace (_("Replace existing preset with this name"))
32 HBox* h = manage (new HBox);
34 h->pack_start (*manage (new Label (_("Name of new preset"))));
35 h->pack_start (_name);
37 get_vbox()->set_spacing (6);
38 get_vbox()->pack_start (*h);
40 get_vbox()->pack_start (_replace);
42 add_button (Stock::CANCEL, RESPONSE_CANCEL);
44 add_button (_("New Favorite Only"), RESPONSE_NO);
46 _add = add_button (Stock::ADD, RESPONSE_ACCEPT);
47 set_default_response (RESPONSE_ACCEPT);
48 _name.set_activates_default(true);
53 _presets = p->get_presets ();
55 _name.signal_changed().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
56 _replace.signal_toggled().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
62 NewPluginPresetDialog::setup_sensitivity ()
64 if (_name.get_text().empty()) {
65 _replace.set_sensitive (false);
66 _add->set_sensitive (false);
70 vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = _presets.begin ();
71 while (i != _presets.end() && i->label != _name.get_text()) {
75 if (i != _presets.end ()) {
76 _replace.set_sensitive (true);
77 _add->set_sensitive (_replace.get_active ());
79 _replace.set_sensitive (false);
80 _add->set_sensitive (true);
85 NewPluginPresetDialog::name () const
87 return _name.get_text ();
91 NewPluginPresetDialog::replace () const
93 return _replace.get_active ();