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 <gtkmm/listviewtext.h>
23 #include "gtkmm2ext/gui_thread.h"
24 #include "ardour/plugin.h"
25 #include "edit_plugin_presets_dialog.h"
30 EditPluginPresetsDialog::EditPluginPresetsDialog (boost::shared_ptr<ARDOUR::Plugin> plugin)
31 : ArdourDialog (_("Edit Presets"))
33 , _list (1, false, SELECTION_MULTIPLE)
34 , _delete (_("Delete"))
36 _list.set_headers_visible (false);
40 HBox* hbox = manage (new HBox);
41 hbox->set_spacing (6);
42 hbox->pack_start (_list);
44 VBox* vbox = manage (new VBox);
45 vbox->pack_start (_delete, false, false);
47 hbox->pack_start (*vbox, false, false);
49 get_vbox()->pack_start (*hbox);
51 add_button (Stock::CLOSE, RESPONSE_ACCEPT);
53 set_size_request (250, 300);
54 update_sensitivity ();
58 _list.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditPluginPresetsDialog::update_sensitivity));
59 _delete.signal_clicked().connect (sigc::mem_fun (*this, &EditPluginPresetsDialog::delete_presets));
61 _plugin->PresetAdded.connect (_preset_added_connection, invalidator (*this), boost::bind (&EditPluginPresetsDialog::setup_list, this), gui_context ());
62 _plugin->PresetRemoved.connect (_preset_removed_connection, invalidator (*this), boost::bind (&EditPluginPresetsDialog::setup_list, this), gui_context ());
66 EditPluginPresetsDialog::update_sensitivity ()
68 _delete.set_sensitive (!_list.get_selected().empty());
72 EditPluginPresetsDialog::delete_presets ()
74 ListViewText::SelectionList const s = _list.get_selected ();
75 for (ListViewText::SelectionList::const_iterator i = s.begin(); i != s.end(); ++i) {
76 _plugin->remove_preset (_list.get_text (*i));
83 EditPluginPresetsDialog::setup_list ()
87 vector<ARDOUR::Plugin::PresetRecord> presets = _plugin->get_presets ();
88 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
89 _list.append_text (i->label);