fix rounding errors and bbox glitches that led to lines missing redraws, plus a few...
[ardour2.git] / gtk2_ardour / new_plugin_preset_dialog.cc
blob7002d5d24096ebfaec421bee56a6705893925b9c
1 /*
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"
24 using namespace std;
25 using namespace Gtk;
27 NewPluginPresetDialog::NewPluginPresetDialog (boost::shared_ptr<ARDOUR::Plugin> p)
28 : ArdourDialog (_("New Preset"))
29 , _replace (_("Replace existing preset with this name"))
31 HBox* h = manage (new HBox);
32 h->set_spacing (6);
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);
42 _add = add_button (Stock::ADD, RESPONSE_ACCEPT);
44 show_all ();
46 _presets = p->get_presets ();
48 _name.signal_changed().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
49 _replace.signal_toggled().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
51 setup_sensitivity ();
54 void
55 NewPluginPresetDialog::setup_sensitivity ()
57 if (_name.get_text().empty()) {
58 _replace.set_sensitive (false);
59 _add->set_sensitive (false);
60 return;
63 vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = _presets.begin ();
64 while (i != _presets.end() && i->label != _name.get_text()) {
65 ++i;
68 if (i != _presets.end ()) {
69 _replace.set_sensitive (true);
70 _add->set_sensitive (_replace.get_active ());
71 } else {
72 _replace.set_sensitive (false);
73 _add->set_sensitive (true);
77 string
78 NewPluginPresetDialog::name () const
80 return _name.get_text ();
83 bool
84 NewPluginPresetDialog::replace () const
86 return _replace.get_active ();