2010-12-05 21:42:36 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2010-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2011-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2010-12-05 21:42:36 -05:00
|
|
|
|
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
#include "new_plugin_preset_dialog.h"
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2010-12-05 21:42:36 -05:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Gtk;
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
NewPluginPresetDialog::NewPluginPresetDialog (std::shared_ptr<ARDOUR::Plugin> p, std::string title, bool favorite_btn)
|
2015-12-28 10:08:35 -05:00
|
|
|
: ArdourDialog (title)
|
2010-12-05 21:42:36 -05:00
|
|
|
, _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);
|
2015-12-28 10:08:35 -05:00
|
|
|
if (favorite_btn) {
|
|
|
|
add_button (_("New Favorite Only"), RESPONSE_NO);
|
|
|
|
}
|
2010-12-05 21:42:36 -05:00
|
|
|
_add = add_button (Stock::ADD, RESPONSE_ACCEPT);
|
2011-11-09 05:58:02 -05:00
|
|
|
set_default_response (RESPONSE_ACCEPT);
|
|
|
|
_name.set_activates_default(true);
|
2010-12-05 21:42:36 -05:00
|
|
|
|
2015-12-28 10:08:35 -05:00
|
|
|
|
2010-12-05 21:42:36 -05:00
|
|
|
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;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-05 21:42:36 -05:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|