Add dialog to allow removal of plugin presets. Should fix #2662.

git-svn-id: svn://localhost/ardour2/branches/3.0@8196 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-12-06 04:29:06 +00:00
parent bf7b8df028
commit 3975355a5f
9 changed files with 167 additions and 3 deletions

View file

@ -1783,6 +1783,7 @@ widget "*PluginAutomateButton" style:highest "small_button"
widget "*PluginAutomateButton*" style:highest "small_button"
widget "*PluginSaveButton" style:highest "small_button"
widget "*PluginSaveButton*" style:highest "small_button"
widget "*PluginEditButton*" style:highest "small_button"
widget "*PluginLoadButton" style:highest "small_button"
widget "*PluginLoadButton*" style:highest "small_button"

View file

@ -0,0 +1,91 @@
/*
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 <gtkmm/listviewtext.h>
#include "gtkmm2ext/gui_thread.h"
#include "ardour/plugin.h"
#include "edit_plugin_presets_dialog.h"
using namespace std;
using namespace Gtk;
EditPluginPresetsDialog::EditPluginPresetsDialog (boost::shared_ptr<ARDOUR::Plugin> plugin)
: ArdourDialog (_("Edit Presets"))
, _plugin (plugin)
, _list (1, false, SELECTION_MULTIPLE)
, _delete (_("Delete"))
{
_list.set_headers_visible (false);
setup_list ();
HBox* hbox = manage (new HBox);
hbox->set_spacing (6);
hbox->pack_start (_list);
VBox* vbox = manage (new VBox);
vbox->pack_start (_delete, false, false);
hbox->pack_start (*vbox, false, false);
get_vbox()->pack_start (*hbox);
add_button (Stock::CLOSE, RESPONSE_ACCEPT);
set_size_request (250, 300);
update_sensitivity ();
show_all ();
_list.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditPluginPresetsDialog::update_sensitivity));
_delete.signal_clicked().connect (sigc::mem_fun (*this, &EditPluginPresetsDialog::delete_presets));
_plugin->PresetAdded.connect (_preset_added_connection, invalidator (*this), boost::bind (&EditPluginPresetsDialog::setup_list, this), gui_context ());
_plugin->PresetRemoved.connect (_preset_removed_connection, invalidator (*this), boost::bind (&EditPluginPresetsDialog::setup_list, this), gui_context ());
}
void
EditPluginPresetsDialog::update_sensitivity ()
{
_delete.set_sensitive (!_list.get_selected().empty());
}
void
EditPluginPresetsDialog::delete_presets ()
{
ListViewText::SelectionList const s = _list.get_selected ();
for (ListViewText::SelectionList::const_iterator i = s.begin(); i != s.end(); ++i) {
_plugin->remove_preset (_list.get_text (*i));
}
setup_list ();
}
void
EditPluginPresetsDialog::setup_list ()
{
_list.clear_items ();
vector<ARDOUR::Plugin::PresetRecord> presets = _plugin->get_presets ();
for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
_list.append_text (i->label);
}
}

View file

@ -0,0 +1,43 @@
/*
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 "ardour_dialog.h"
namespace ARDOUR {
class Plugin;
}
class EditPluginPresetsDialog : public ArdourDialog
{
public:
EditPluginPresetsDialog (boost::shared_ptr<ARDOUR::Plugin>);
private:
void setup_list ();
void delete_presets ();
void update_sensitivity ();
boost::shared_ptr<ARDOUR::Plugin> _plugin;
Gtk::ListViewText _list;
Gtk::Button _delete;
PBD::ScopedConnection _preset_added_connection;
PBD::ScopedConnection _preset_removed_connection;
};

View file

@ -94,6 +94,7 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr<PluginInsert> pi, bool scrol
smaller_hbox->pack_start (latency_button, false, false, 10);
smaller_hbox->pack_start (preset_combo, false, false);
smaller_hbox->pack_start (save_button, false, false);
smaller_hbox->pack_start (edit_button, false, false);
smaller_hbox->pack_start (bypass_button, false, true);
constraint_hbox->set_spacing (5);

View file

@ -67,6 +67,7 @@
#include "latency_gui.h"
#include "plugin_eq_gui.h"
#include "new_plugin_preset_dialog.h"
#include "edit_plugin_presets_dialog.h"
#include "i18n.h"
@ -412,7 +413,8 @@ PluginUIWindow::plugin_going_away ()
PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
: insert (pi),
plugin (insert->plugin()),
save_button(_("Add")),
save_button (_("Add")),
edit_button (_("Edit")),
bypass_button (_("Bypass")),
latency_gui (0),
plugin_analysis_expander (_("Plugin analysis"))
@ -427,6 +429,9 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
save_button.set_name ("PluginSaveButton");
save_button.signal_clicked().connect(sigc::mem_fun(*this, &PlugUIBase::save_plugin_setting));
edit_button.set_name ("PluginEditButton");
edit_button.signal_clicked().connect (sigc::mem_fun (*this, &PlugUIBase::edit_plugin_settings));
insert->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&PlugUIBase::processor_active_changed, this, boost::weak_ptr<Processor>(insert)), gui_context());
bypass_button.set_active (!pi->active());
@ -452,6 +457,9 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
plugin_analysis_expander.set_expanded(false);
insert->DropReferences.connect (death_connection, invalidator (*this), boost::bind (&PlugUIBase::plugin_going_away, this), gui_context());
plugin->PresetAdded.connect (preset_added_connection, invalidator (*this), boost::bind (&PlugUIBase::update_presets, this), gui_context ());
plugin->PresetRemoved.connect (preset_removed_connection, invalidator (*this), boost::bind (&PlugUIBase::update_presets, this), gui_context ());
}
PlugUIBase::~PlugUIBase()
@ -550,6 +558,13 @@ PlugUIBase::save_plugin_setting ()
}
}
void
PlugUIBase::edit_plugin_settings ()
{
EditPluginPresetsDialog d (plugin);
d.run ();
}
void
PlugUIBase::bypass_toggled ()
{

View file

@ -103,6 +103,7 @@ class PlugUIBase : public virtual sigc::trackable
boost::shared_ptr<ARDOUR::Plugin> plugin;
Gtk::ComboBoxText preset_combo;
Gtk::Button save_button;
Gtk::Button edit_button;
Gtk::ToggleButton bypass_button;
Gtk::EventBox focus_button;
@ -120,7 +121,8 @@ class PlugUIBase : public virtual sigc::trackable
bool no_load_preset;
void setting_selected();
void save_plugin_setting (void);
void save_plugin_setting ();
void edit_plugin_settings ();
bool focus_toggled(GdkEventButton*);
void bypass_toggled();
void toggle_plugin_analysis ();
@ -129,6 +131,8 @@ class PlugUIBase : public virtual sigc::trackable
PBD::ScopedConnection death_connection;
PBD::ScopedConnection active_connection;
PBD::ScopedConnection preset_added_connection;
PBD::ScopedConnection preset_removed_connection;
PBD::ScopedConnectionList control_connections;
};

View file

@ -68,6 +68,7 @@ gtk2_ardour_sources = [
'debug.cc',
'diamond.cc',
'edit_note_dialog.cc',
'edit_plugin_presets_dialog.cc',
'editing.cc',
'editor.cc',
'editor_actions.cc',

View file

@ -148,6 +148,8 @@ class Plugin : public PBD::StatefulDestructible, public Latent
virtual bool has_editor() const = 0;
PBD::Signal0<void> PresetAdded;
PBD::Signal0<void> PresetRemoved;
PBD::Signal2<void,uint32_t,float> ParameterChanged;
/* NOTE: this block of virtual methods looks like the interface

View file

@ -221,6 +221,8 @@ Plugin::remove_preset (string name, string domain)
presets.erase (p->uri);
write_preset_file (envvar, domain);
PresetRemoved (); /* EMIT SIGNAL */
}
string
@ -309,7 +311,11 @@ Plugin::save_preset (string name, string domain)
presets.insert (make_pair (uri, PresetRecord (uri, name)));
free (uri);
return write_preset_file (envvar, domain);
bool const r = write_preset_file (envvar, domain);
PresetAdded (); /* EMIT SIGNAL */
return r;
}
PluginPtr