From 3a1af63fedc4792a3c98de446d031bfe27e9202d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 15 Dec 2010 01:06:57 +0000 Subject: [PATCH] Save and Delete buttons for plugin presets, remove largely useless edit plugin presets dialog. Should fix #2662. git-svn-id: svn://localhost/ardour2/branches/3.0@8278 d708f5d6-7413-0410-9779-e7cbd77b26cf --- .gitignore | 5 ++ gtk2_ardour/ardour3_ui_dark.rc.in | 3 +- gtk2_ardour/edit_plugin_presets_dialog.cc | 105 ---------------------- gtk2_ardour/edit_plugin_presets_dialog.h | 43 --------- gtk2_ardour/generic_pluginui.cc | 3 +- gtk2_ardour/plugin_ui.cc | 59 ++++++++---- gtk2_ardour/plugin_ui.h | 7 +- gtk2_ardour/vst_pluginui.cc | 1 + gtk2_ardour/wscript | 1 - 9 files changed, 58 insertions(+), 169 deletions(-) delete mode 100644 gtk2_ardour/edit_plugin_presets_dialog.cc delete mode 100644 gtk2_ardour/edit_plugin_presets_dialog.h diff --git a/.gitignore b/.gitignore index 4a86e7b277..b86506eb98 100644 --- a/.gitignore +++ b/.gitignore @@ -121,3 +121,8 @@ build tags BROWSE core +gtk2_ardour/po/*.mo +libs/ardour/po/*.mo +gtk2_ardour/*.pot +libs/ardour/libardour.pot + diff --git a/gtk2_ardour/ardour3_ui_dark.rc.in b/gtk2_ardour/ardour3_ui_dark.rc.in index 49e86e3d7b..df0bc4fe70 100644 --- a/gtk2_ardour/ardour3_ui_dark.rc.in +++ b/gtk2_ardour/ardour3_ui_dark.rc.in @@ -1787,9 +1787,10 @@ widget "*PluginAutomatePlayButton" style:highest "small_red_active_and_selected_ widget "*PluginAutomatePlayButton*" style:highest "small_red_active_and_selected_button" widget "*PluginAutomateButton" style:highest "small_button" widget "*PluginAutomateButton*" style:highest "small_button" +widget "*PluginAddButton*" style:highest "small_button" widget "*PluginSaveButton" style:highest "small_button" widget "*PluginSaveButton*" style:highest "small_button" -widget "*PluginEditButton*" style:highest "small_button" +widget "*PluginDeleteButton*" style:highest "small_button" widget "*PluginLoadButton" style:highest "small_button" widget "*PluginLoadButton*" style:highest "small_button" diff --git a/gtk2_ardour/edit_plugin_presets_dialog.cc b/gtk2_ardour/edit_plugin_presets_dialog.cc deleted file mode 100644 index 62d77eb597..0000000000 --- a/gtk2_ardour/edit_plugin_presets_dialog.cc +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright (C) 2010 Paul Davis - Author: Carl Hetherington - - 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 -#include -#include -#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 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); - ScrolledWindow* scr = manage (new ScrolledWindow); - scr->add (_list); - hbox->pack_start (*scr); - - 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 () -{ - ListViewText::SelectionList s = _list.get_selected (); - - ListViewText::SelectionList::const_iterator i = s.begin(); - while (i != s.end()) { - if (*i >= _plugin->first_user_preset_index()) { - break; - } - - ++i; - } - - _delete.set_sensitive (i != s.end ()); -} - -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)); - } -} - -void -EditPluginPresetsDialog::setup_list () -{ - _list.clear_items (); - - vector presets = _plugin->get_presets (); - for (vector::const_iterator i = presets.begin(); i != presets.end(); ++i) { - _list.append_text (i->label); - } - - update_sensitivity (); -} diff --git a/gtk2_ardour/edit_plugin_presets_dialog.h b/gtk2_ardour/edit_plugin_presets_dialog.h deleted file mode 100644 index 82dd986177..0000000000 --- a/gtk2_ardour/edit_plugin_presets_dialog.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2010 Paul Davis - Author: Carl Hetherington - - 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); - -private: - void setup_list (); - void delete_presets (); - void update_sensitivity (); - - boost::shared_ptr _plugin; - Gtk::ListViewText _list; - Gtk::Button _delete; - - PBD::ScopedConnection _preset_added_connection; - PBD::ScopedConnection _preset_removed_connection; -}; diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index 6199f81236..f672af112e 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -93,8 +93,9 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr pi, bool scrol smaller_hbox->pack_start (latency_button, false, false, 10); smaller_hbox->pack_start (preset_combo, false, false); + smaller_hbox->pack_start (add_button, false, false); smaller_hbox->pack_start (save_button, false, false); - smaller_hbox->pack_start (edit_button, false, false); + smaller_hbox->pack_start (delete_button, false, false); smaller_hbox->pack_start (bypass_button, false, true); constraint_hbox->set_spacing (5); diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc index d46f1e9542..165108ae19 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -67,7 +67,6 @@ #include "latency_gui.h" #include "plugin_eq_gui.h" #include "new_plugin_preset_dialog.h" -#include "edit_plugin_presets_dialog.h" #include "i18n.h" @@ -244,7 +243,6 @@ PluginUIWindow::on_hide () void PluginUIWindow::set_title(const std::string& title) { - //cout << "PluginUIWindow::set_title(\"" << title << "\"" << endl; Gtk::Window::set_title(title); _title = title; } @@ -421,24 +419,30 @@ PluginUIWindow::plugin_going_away () PlugUIBase::PlugUIBase (boost::shared_ptr pi) : insert (pi), plugin (insert->plugin()), - save_button (_("Add")), - edit_button (_("Edit")), + add_button (_("Add")), + save_button (_("Save")), + delete_button (_("Delete")), bypass_button (_("Bypass")), latency_gui (0), plugin_analysis_expander (_("Plugin analysis")) { //preset_combo.set_use_arrows_always(true); - update_presets(); + update_presets (); + update_sensitivity (); + preset_combo.set_size_request (100, -1); preset_combo.set_active_text (""); preset_combo.signal_changed().connect(sigc::mem_fun(*this, &PlugUIBase::setting_selected)); no_load_preset = false; + add_button.set_name ("PluginAddButton"); + add_button.signal_clicked().connect (sigc::mem_fun (*this, &PlugUIBase::add_plugin_setting)); + 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)); + delete_button.set_name ("PluginDeleteButton"); + delete_button.signal_clicked().connect (sigc::mem_fun (*this, &PlugUIBase::delete_plugin_setting)); insert->ActiveChanged.connect (active_connection, invalidator (*this), boost::bind (&PlugUIBase::processor_active_changed, this, boost::weak_ptr(insert)), gui_context()); @@ -524,7 +528,7 @@ PlugUIBase::processor_active_changed (boost::weak_ptr weak_p) } void -PlugUIBase::setting_selected() +PlugUIBase::setting_selected () { if (no_load_preset) { return; @@ -533,7 +537,8 @@ PlugUIBase::setting_selected() if (preset_combo.get_active_text().length() > 0) { const Plugin::PresetRecord* pr = plugin->preset_by_label(preset_combo.get_active_text()); if (pr) { - plugin->load_preset(pr->uri); + plugin->load_preset (pr->uri); + update_sensitivity (); } else { warning << string_compose(_("Plugin preset %1 not found"), preset_combo.get_active_text()) << endmsg; @@ -542,7 +547,7 @@ PlugUIBase::setting_selected() } void -PlugUIBase::save_plugin_setting () +PlugUIBase::add_plugin_setting () { NewPluginPresetDialog d (plugin); @@ -557,20 +562,32 @@ PlugUIBase::save_plugin_setting () } if (plugin->save_preset (d.name())) { - update_presets (); - no_load_preset = true; preset_combo.set_active_text (d.name()); - no_load_preset = false; } break; } } void -PlugUIBase::edit_plugin_settings () +PlugUIBase::save_plugin_setting () { - EditPluginPresetsDialog d (plugin); - d.run (); + string const name = preset_combo.get_active_text (); + plugin->remove_preset (name); + plugin->save_preset (name); + preset_combo.set_active_text (name); +} + +void +PlugUIBase::delete_plugin_setting () +{ + plugin->remove_preset (preset_combo.get_active_text ()); + + vector presets = plugin->get_presets(); + if (presets.empty ()) { + preset_combo.set_active_text (""); + } else { + preset_combo.set_active_text (presets.front().label); + } } void @@ -663,4 +680,14 @@ PlugUIBase::update_presets () set_popdown_strings (preset_combo, preset_labels); no_load_preset = false; + + update_sensitivity (); +} + +void +PlugUIBase::update_sensitivity () +{ + bool const have_preset = !preset_combo.get_model()->children().empty(); + save_button.set_sensitive (have_preset); + delete_button.set_sensitive (have_preset); } diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index 0caed4ac95..e1d9cfafce 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -102,8 +102,9 @@ class PlugUIBase : public virtual sigc::trackable boost::shared_ptr insert; boost::shared_ptr plugin; Gtk::ComboBoxText preset_combo; + Gtk::Button add_button; Gtk::Button save_button; - Gtk::Button edit_button; + Gtk::Button delete_button; Gtk::ToggleButton bypass_button; Gtk::EventBox focus_button; @@ -121,13 +122,15 @@ class PlugUIBase : public virtual sigc::trackable bool no_load_preset; void setting_selected(); + void add_plugin_setting (); void save_plugin_setting (); - void edit_plugin_settings (); + void delete_plugin_setting (); bool focus_toggled(GdkEventButton*); void bypass_toggled(); void toggle_plugin_analysis (); void processor_active_changed (boost::weak_ptr p); void plugin_going_away (); + void update_sensitivity (); PBD::ScopedConnection death_connection; PBD::ScopedConnection active_connection; diff --git a/gtk2_ardour/vst_pluginui.cc b/gtk2_ardour/vst_pluginui.cc index ea19eeaf86..134ae6f2c1 100644 --- a/gtk2_ardour/vst_pluginui.cc +++ b/gtk2_ardour/vst_pluginui.cc @@ -51,6 +51,7 @@ VSTPluginUI::VSTPluginUI (boost::shared_ptr pi, boost::shared_ptr< preset_box.pack_end (bypass_button, false, false, 10); preset_box.pack_end (edit_button, false, false); preset_box.pack_end (save_button, false, false); + preset_box.pack_end (add_button, false, false); preset_box.pack_end (vst_preset_combo, false, false); vst_preset_combo.signal_changed().connect (sigc::mem_fun (*this, &VSTPluginUI::preset_chosen)); diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 9d48504f23..ae673f06d6 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -69,7 +69,6 @@ gtk2_ardour_sources = [ 'debug.cc', 'diamond.cc', 'edit_note_dialog.cc', - 'edit_plugin_presets_dialog.cc', 'editing.cc', 'editor.cc', 'editor_actions.cc',