13
0

Update plugin scan dialog (timeout, transient)

This commit is contained in:
Robin Gareus 2021-06-25 01:10:13 +02:00
parent 6a9c9d547c
commit 349a41a448
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 54 additions and 16 deletions

View File

@ -41,12 +41,14 @@ using namespace PBD;
using namespace Gtk; using namespace Gtk;
using namespace std; using namespace std;
PluginScanDialog::PluginScanDialog (bool just_cached, bool v) PluginScanDialog::PluginScanDialog (bool just_cached, bool v, Gtk::Window* parent)
: ArdourDialog (_("Scanning for plugins")) : ArdourDialog (_("Scanning for plugins"))
, timeout_button (_("Stop Timeout")) , timeout_button (_("Stop Timeout"))
, all_timeout_button (_("Ignore all Timeouts"))
, cancel_button (_("Cancel Plugin Scan")) , cancel_button (_("Cancel Plugin Scan"))
, cache_only (just_cached) , cache_only (just_cached)
, verbose (v) , verbose (v)
, delayed_close (false)
{ {
VBox* vbox = get_vbox(); VBox* vbox = get_vbox();
vbox->set_size_request(400,-1); vbox->set_size_request(400,-1);
@ -61,9 +63,13 @@ PluginScanDialog::PluginScanDialog (bool just_cached, bool v)
vbox->pack_start (cancel_button, PACK_SHRINK); vbox->pack_start (cancel_button, PACK_SHRINK);
timeout_button.set_name ("EditorGTKButton"); timeout_button.set_name ("EditorGTKButton");
timeout_button.signal_clicked().connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_plugin_timeout)); timeout_button.signal_clicked().connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_plugin_scan_timeout));
timeout_button.show(); timeout_button.show();
all_timeout_button.set_name ("EditorGTKButton");
all_timeout_button.signal_clicked().connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_plugin_all_scan_timeout));
all_timeout_button.show();
pbar.set_orientation(Gtk::PROGRESS_RIGHT_TO_LEFT); pbar.set_orientation(Gtk::PROGRESS_RIGHT_TO_LEFT);
pbar.set_pulse_step (0.1); pbar.set_pulse_step (0.1);
pbar.set_text(_("Scan Timeout")); pbar.set_text(_("Scan Timeout"));
@ -71,6 +77,7 @@ PluginScanDialog::PluginScanDialog (bool just_cached, bool v)
tbox.pack_start (pbar, PACK_EXPAND_WIDGET, 4); tbox.pack_start (pbar, PACK_EXPAND_WIDGET, 4);
tbox.pack_start (timeout_button, PACK_SHRINK, 4); tbox.pack_start (timeout_button, PACK_SHRINK, 4);
tbox.pack_start (all_timeout_button, PACK_SHRINK, 4);
vbox->pack_start (tbox, PACK_SHRINK, 4); vbox->pack_start (tbox, PACK_SHRINK, 4);
@ -78,6 +85,12 @@ PluginScanDialog::PluginScanDialog (bool just_cached, bool v)
ARDOUR::PluginScanTimeout.connect (connections, MISSING_INVALIDATOR, boost::bind(&PluginScanDialog::plugin_scan_timeout, this, _1), gui_context()); ARDOUR::PluginScanTimeout.connect (connections, MISSING_INVALIDATOR, boost::bind(&PluginScanDialog::plugin_scan_timeout, this, _1), gui_context());
vbox->show_all (); vbox->show_all ();
if (parent) {
set_transient_for (*parent);
set_position (Gtk::WIN_POS_CENTER_ON_PARENT);
delayed_close = true;
}
} }
void void
@ -149,9 +162,17 @@ PluginScanDialog::cancel_plugin_scan ()
} }
void void
PluginScanDialog::cancel_plugin_timeout () PluginScanDialog::cancel_plugin_all_scan_timeout ()
{ {
//PluginManager::instance().cancel_plugin_scan_timeout(); PluginManager::instance().cancel_plugin_all_scan_timeout ();
all_timeout_button.set_sensitive (false);
timeout_button.set_sensitive (false);
}
void
PluginScanDialog::cancel_plugin_scan_timeout ()
{
PluginManager::instance().cancel_plugin_scan_timeout ();
timeout_button.set_sensitive (false); timeout_button.set_sensitive (false);
} }
@ -162,19 +183,29 @@ PluginScanDialog::plugin_scan_timeout (int timeout)
return; return;
} }
int scan_timeout = Config->get_vst_scan_timeout();
if (timeout > 0) { if (timeout > 0) {
pbar.set_sensitive (true); pbar.set_sensitive (true);
timeout_button.set_sensitive (true); if (timeout < scan_timeout) {
pbar.set_fraction ((float) timeout / (float) Config->get_vst_scan_timeout()); pbar.set_text(_("Scan Timeout"));
} else {
pbar.set_text(_("Scanning"));
}
timeout_button.set_sensitive (timeout < scan_timeout);
all_timeout_button.set_sensitive (timeout < scan_timeout);
pbar.set_fraction ((float) timeout / (float) scan_timeout);
tbox.show(); tbox.show();
} else if (timeout < 0) { } else if (timeout < 0) {
pbar.set_sensitive (true); pbar.set_sensitive (true);
pbar.set_text(_("Scanning"));
pbar.pulse (); pbar.pulse ();
timeout_button.set_sensitive (false); timeout_button.set_sensitive (false);
tbox.show(); tbox.show();
} else { } else {
pbar.set_sensitive (false); pbar.set_sensitive (false);
timeout_button.set_sensitive (false); timeout_button.set_sensitive (false);
all_timeout_button.set_sensitive (false);
tbox.hide(); tbox.hide();
} }
@ -192,23 +223,26 @@ PluginScanDialog::message_handler (std::string type, std::string plugin, bool ca
const bool cancelled = PluginManager::instance().cancelled(); const bool cancelled = PluginManager::instance().cancelled();
if (type != X_("closeme") && (!UIConfiguration::instance().get_show_plugin_scan_window()) && !verbose) { if (type != X_("closeme") && !UIConfiguration::instance().get_show_plugin_scan_window() && !verbose) {
if (is_mapped()) {
if (cancelled && is_mapped()) { hide ();
hide();
connections.drop_connections(); connections.drop_connections();
ARDOUR_UI::instance()->gui_idle_handler (); ARDOUR_UI::instance()->gui_idle_handler ();
return; return;
} }
if (cancelled || !can_cancel) { return;
return;
}
} }
if (type == X_("closeme")) { if (type == X_("closeme")) {
tbox.hide(); tbox.hide();
hide();
connections.drop_connections (); connections.drop_connections ();
cancel_button.set_sensitive(false);
queue_draw ();
for (int i = 0; delayed_close && i < 30; ++i) { // 1.5 sec delay
Glib::usleep (50000);
ARDOUR_UI::instance()->gui_idle_handler ();
}
hide ();
} else { } else {
message.set_text (type + ": " + PBD::basename_nosuffix (plugin)); message.set_text (type + ": " + PBD::basename_nosuffix (plugin));
show(); show();
@ -216,6 +250,7 @@ PluginScanDialog::message_handler (std::string type, std::string plugin, bool ca
if (!can_cancel || !cancelled) { if (!can_cancel || !cancelled) {
timeout_button.set_sensitive(false); timeout_button.set_sensitive(false);
all_timeout_button.set_sensitive(false);
} }
cancel_button.set_sensitive(can_cancel && !cancelled); cancel_button.set_sensitive(can_cancel && !cancelled);

View File

@ -29,7 +29,7 @@
class PluginScanDialog : public ArdourDialog class PluginScanDialog : public ArdourDialog
{ {
public: public:
PluginScanDialog (bool cache_only, bool verbose); PluginScanDialog (bool cache_only, bool verbose, Gtk::Window* parent = NULL);
void start (); void start ();
private: private:
@ -37,12 +37,15 @@ class PluginScanDialog : public ArdourDialog
Gtk::ProgressBar pbar; Gtk::ProgressBar pbar;
Gtk::HBox tbox; Gtk::HBox tbox;
Gtk::Button timeout_button; Gtk::Button timeout_button;
Gtk::Button all_timeout_button;
Gtk::Button cancel_button; Gtk::Button cancel_button;
bool cache_only; bool cache_only;
bool verbose; bool verbose;
bool delayed_close;
void cancel_plugin_scan (); void cancel_plugin_scan ();
void cancel_plugin_timeout (); void cancel_plugin_scan_timeout ();
void cancel_plugin_all_scan_timeout ();
void plugin_scan_timeout (int timeout); void plugin_scan_timeout (int timeout);
void message_handler (std::string type, std::string plugin, bool can_cancel); void message_handler (std::string type, std::string plugin, bool can_cancel);