summaryrefslogtreecommitdiff
path: root/gtk2_ardour/new_plugin_preset_dialog.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-12-06 02:42:36 +0000
committerCarl Hetherington <carl@carlh.net>2010-12-06 02:42:36 +0000
commit3639918e43bf96f83bfc630c02530dd6e030f8f5 (patch)
tree0eeb7636c041227e0e713f3ae0895fa8976d3b6e /gtk2_ardour/new_plugin_preset_dialog.cc
parent610656f448133ca4b9b0f4f4b4de7a18663f1f3a (diff)
Add missing files.
git-svn-id: svn://localhost/ardour2/branches/3.0@8193 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/new_plugin_preset_dialog.cc')
-rw-r--r--gtk2_ardour/new_plugin_preset_dialog.cc88
1 files changed, 88 insertions, 0 deletions
diff --git a/gtk2_ardour/new_plugin_preset_dialog.cc b/gtk2_ardour/new_plugin_preset_dialog.cc
new file mode 100644
index 0000000000..7002d5d240
--- /dev/null
+++ b/gtk2_ardour/new_plugin_preset_dialog.cc
@@ -0,0 +1,88 @@
+/*
+ Copyright (C) 2010 Paul Davis
+ Author: Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <gtkmm/stock.h>
+#include "new_plugin_preset_dialog.h"
+
+using namespace std;
+using namespace Gtk;
+
+NewPluginPresetDialog::NewPluginPresetDialog (boost::shared_ptr<ARDOUR::Plugin> p)
+ : ArdourDialog (_("New Preset"))
+ , _replace (_("Replace existing preset with this name"))
+{
+ HBox* h = manage (new HBox);
+ h->set_spacing (6);
+ h->pack_start (*manage (new Label (_("Name of new preset"))));
+ h->pack_start (_name);
+
+ get_vbox()->set_spacing (6);
+ get_vbox()->pack_start (*h);
+
+ get_vbox()->pack_start (_replace);
+
+ add_button (Stock::CANCEL, RESPONSE_CANCEL);
+ _add = add_button (Stock::ADD, RESPONSE_ACCEPT);
+
+ show_all ();
+
+ _presets = p->get_presets ();
+
+ _name.signal_changed().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
+ _replace.signal_toggled().connect (sigc::mem_fun (*this, &NewPluginPresetDialog::setup_sensitivity));
+
+ setup_sensitivity ();
+}
+
+void
+NewPluginPresetDialog::setup_sensitivity ()
+{
+ if (_name.get_text().empty()) {
+ _replace.set_sensitive (false);
+ _add->set_sensitive (false);
+ return;
+ }
+
+ vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = _presets.begin ();
+ while (i != _presets.end() && i->label != _name.get_text()) {
+ ++i;
+ }
+
+ if (i != _presets.end ()) {
+ _replace.set_sensitive (true);
+ _add->set_sensitive (_replace.get_active ());
+ } else {
+ _replace.set_sensitive (false);
+ _add->set_sensitive (true);
+ }
+}
+
+string
+NewPluginPresetDialog::name () const
+{
+ return _name.get_text ();
+}
+
+bool
+NewPluginPresetDialog::replace () const
+{
+ return _replace.get_active ();
+}
+