ardour
new_plugin_preset_dialog.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Paul Davis
3  Author: Carl Hetherington <cth@carlh.net>
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/stock.h>
23 #include "i18n.h"
24 
25 using namespace std;
26 using namespace Gtk;
27 
29  : ArdourDialog (_("New Preset"))
30  , _replace (_("Replace existing preset with this name"))
31 {
32  HBox* h = manage (new HBox);
33  h->set_spacing (6);
34  h->pack_start (*manage (new Label (_("Name of new preset"))));
35  h->pack_start (_name);
36 
37  get_vbox()->set_spacing (6);
38  get_vbox()->pack_start (*h);
39 
40  get_vbox()->pack_start (_replace);
41 
42  add_button (Stock::CANCEL, RESPONSE_CANCEL);
43  _add = add_button (Stock::ADD, RESPONSE_ACCEPT);
44  set_default_response (RESPONSE_ACCEPT);
45  _name.set_activates_default(true);
46 
47  show_all ();
48 
49  _presets = p->get_presets ();
50 
51  _name.signal_changed().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
52  _replace.signal_toggled().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
53 
55 }
56 
57 void
59 {
60  if (_name.get_text().empty()) {
61  _replace.set_sensitive (false);
62  _add->set_sensitive (false);
63  return;
64  }
65 
66  vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = _presets.begin ();
67  while (i != _presets.end() && i->label != _name.get_text()) {
68  ++i;
69  }
70 
71  if (i != _presets.end ()) {
72  _replace.set_sensitive (true);
73  _add->set_sensitive (_replace.get_active ());
74  } else {
75  _replace.set_sensitive (false);
76  _add->set_sensitive (true);
77  }
78 }
79 
80 string
82 {
83  return _name.get_text ();
84 }
85 
86 bool
88 {
89  return _replace.get_active ();
90 }
91 
Definition: ardour_ui.h:130
Definition: Beats.hpp:239
#define _(Text)
Definition: i18n.h:11
std::vector< ARDOUR::Plugin::PresetRecord > _presets
NewPluginPresetDialog(boost::shared_ptr< ARDOUR::Plugin >)
std::vector< PresetRecord > get_presets()
Definition: plugin.cc:313