13
0

Tweak VST path edit window

This correctly sets transient parent. Previously this
could cause a crash when the rc_option_editor window
was detached and not realized.
This commit is contained in:
Robin Gareus 2021-07-07 18:07:52 +02:00
parent aaf7d3227c
commit b5338ce220
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 73 additions and 51 deletions

View File

@ -28,6 +28,7 @@
#include "ardour/types_convert.h"
#include "gtkmm2ext/gui_thread.h"
#include "widgets/paths_dialog.h"
#include "ardour_message.h"
#include "plugin_manager_ui.h"
@ -150,17 +151,17 @@ PluginManagerUI::PluginManagerUI ()
#if defined LXVST_SUPPORT
ArdourWidgets::ArdourButton* btn_lxvst = Gtk::manage (new ArdourWidgets::ArdourButton (_("Linux VST2 Path")));
btn_lxvst->signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginManagerUI::edit_vst_path), LXVST));
btn_lxvst->signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginManagerUI::vst_path_cb), LXVST));
b_paths->pack_start (*btn_lxvst);
#endif
#ifdef WINDOWS_VST_SUPPORT
ArdourWidgets::ArdourButton* btn_winvst = Gtk::manage (new ArdourWidgets::ArdourButton (_("Windows VST2 Path")));
btn_winvst->signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginManagerUI::edit_vst_path), Windows_VST));
btn_winvst->signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginManagerUI::vst_path_cb), Windows_VST));
b_paths->pack_start (*btn_winvst);
#endif
#ifdef VST3_SUPPORT
ArdourWidgets::ArdourButton* btn_vst3 = Gtk::manage (new ArdourWidgets::ArdourButton (_("VST3 Path")));
btn_vst3->signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginManagerUI::edit_vst_path), VST3));
btn_vst3->signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginManagerUI::vst_path_cb), VST3));
b_paths->pack_start (*btn_vst3);
#endif
b_paths->pack_start (_btn_prefs);
@ -431,44 +432,62 @@ PluginManagerUI::show_plugin_prefs ()
}
void
PluginManagerUI::edit_vst_path (ARDOUR::PluginType t)
PluginManagerUI::edit_vst_path (std::string const& title, std::string const& dflt, sigc::slot<std::string> get, sigc::slot<bool, std::string> set)
{
RCOptionEditor* rc_option_editor = ARDOUR_UI::instance()->get_rc_option_editor();
if (rc_option_editor) {
switch (t) {
/* see also RCOptionEditor::edit_vst_path */
ArdourWidgets::PathsDialog pd (*this, title, get (), dflt);
if (pd.run () != Gtk::RESPONSE_ACCEPT) {
return;
}
pd.hide();
set (pd.get_serialized_paths ());
ArdourMessageDialog msg (_("Re-scan Plugins now?"), false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true);
msg.set_default_response (Gtk::RESPONSE_YES);
if (msg.run() != Gtk::RESPONSE_YES) {
return;
}
msg.hide ();
PluginScanDialog psd (false, true, this);
psd.start ();
}
void
PluginManagerUI::vst_path_cb (ARDOUR::PluginType t)
{
switch (t) {
#ifdef WINDOWS_VST_SUPPORT
case Windows_VST:
rc_option_editor->edit_vst_path (
_("Set Windows VST2 Search Path"),
PluginManager::instance().get_default_windows_vst_path (),
sigc::mem_fun (*Config, &RCConfiguration::get_plugin_path_vst),
sigc::mem_fun (*Config, &RCConfiguration::set_plugin_path_vst)
);
break;
case Windows_VST:
edit_vst_path (
_("Set Windows VST2 Search Path"),
PluginManager::instance().get_default_windows_vst_path (),
sigc::mem_fun (*Config, &RCConfiguration::get_plugin_path_vst),
sigc::mem_fun (*Config, &RCConfiguration::set_plugin_path_vst)
);
break;
#endif
#ifdef LXVST_SUPPORT
case LXVST:
rc_option_editor->edit_vst_path (
_("Set Linux VST2 Search Path"),
PluginManager::instance().get_default_lxvst_path (),
sigc::mem_fun (*Config, &RCConfiguration::get_plugin_path_lxvst),
sigc::mem_fun (*Config, &RCConfiguration::set_plugin_path_lxvst)
);
break;
case LXVST:
edit_vst_path (
_("Set Linux VST2 Search Path"),
PluginManager::instance().get_default_lxvst_path (),
sigc::mem_fun (*Config, &RCConfiguration::get_plugin_path_lxvst),
sigc::mem_fun (*Config, &RCConfiguration::set_plugin_path_lxvst)
);
break;
#endif
#ifdef VST3_SUPPORT
case VST3:
rc_option_editor->edit_vst_path (
_("Set Additional VST3 Search Path"),
"", /* default is blank */
sigc::mem_fun (*Config, &RCConfiguration::get_plugin_path_vst3),
sigc::mem_fun (*Config, &RCConfiguration::set_plugin_path_vst3)
);
break;
case VST3:
edit_vst_path (
_("Set Additional VST3 Search Path"),
"", /* default is blank */
sigc::mem_fun (*Config, &RCConfiguration::get_plugin_path_vst3),
sigc::mem_fun (*Config, &RCConfiguration::set_plugin_path_vst3)
);
break;
#endif
default:
break;
}
default:
break;
}
}

View File

@ -55,7 +55,8 @@ private:
void rescan_selected ();
void clear_log ();
void show_plugin_prefs ();
void edit_vst_path (ARDOUR::PluginType);
void vst_path_cb (ARDOUR::PluginType);
void edit_vst_path (std::string const&, std::string const&, sigc::slot<std::string>, sigc::slot<bool, std::string>);
void plugin_status_changed (ARDOUR::PluginType, std::string, ARDOUR::PluginManager::PluginStatusType);

View File

@ -4651,7 +4651,7 @@ void RCOptionEditor::show_transport_masters () {
void RCOptionEditor::plugin_scan_refresh () {
/* first argument says discover new plugins, second means be verbose */
PluginScanDialog psd (false, true);
PluginScanDialog psd (false, true, current_toplevel ());
psd.start ();
}
@ -4683,21 +4683,23 @@ void RCOptionEditor::clear_au_blacklist () {
PluginManager::instance().clear_au_blacklist();
}
void RCOptionEditor::edit_vst_path (std::string const& title, std::string const& dflt, sigc::slot<string> get, sigc::slot<bool, string> set) {
PathsDialog *pd = new PathsDialog (*current_toplevel(), title, get (), dflt);
ResponseType r = (ResponseType) pd->run ();
pd->hide();
if (r == RESPONSE_ACCEPT) {
set (pd->get_serialized_paths());
MessageDialog msg (_("Re-scan Plugins now?"),
false /*no markup*/, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true /*modal*/);
msg.set_default_response (Gtk::RESPONSE_YES);
if (msg.run() == Gtk::RESPONSE_YES) {
msg.hide ();
plugin_scan_refresh ();
}
void
RCOptionEditor::edit_vst_path (std::string const& title, std::string const& dflt, sigc::slot<string> get, sigc::slot<bool, string> set)
{
/* see also PluginManagerUI::edit_vst_path */
PathsDialog pd (*current_toplevel(), title, get (), dflt);
if (pd.run () != Gtk::RESPONSE_ACCEPT) {
return;
}
delete pd;
pd.hide();
set (pd.get_serialized_paths());
MessageDialog msg (_("Re-scan Plugins now?"), false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true);
msg.set_default_response (Gtk::RESPONSE_YES);
if (msg.run() != Gtk::RESPONSE_YES) {
return;
}
msg.hide ();
plugin_scan_refresh ();
}

View File

@ -47,7 +47,6 @@ public:
XMLNode& get_state ();
bool on_key_release_event (GdkEventKey*);
void edit_vst_path (std::string const& title, std::string const& dflt, sigc::slot<std::string>, sigc::slot<bool, std::string>);
private:
void parameter_changed (std::string const &);
@ -78,6 +77,7 @@ private:
void clear_vst3_blacklist ();
void clear_au_cache ();
void clear_au_blacklist ();
void edit_vst_path (std::string const&, std::string const&, sigc::slot<std::string>, sigc::slot<bool, std::string>);
};
#endif /* __gtk_ardour_rc_option_editor_h__ */