Another round of plugin-scan-dialog updates

* Fix API calls (pack_start)
* Fix logic update sensitivity in response to callbacks
* Cleanup white-space and re-indent

TODO: invert timeout behavior: opt-in to timeouts, not opt-out.
This commit is contained in:
Robin Gareus 2021-07-22 06:09:41 +02:00
parent e406a1bd41
commit 4d57c1e85b
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
2 changed files with 61 additions and 80 deletions

View file

@ -53,45 +53,16 @@ PluginScanDialog::PluginScanDialog (bool just_cached, bool v, Gtk::Window* paren
, verbose (v) , verbose (v)
, delayed_close (false) , delayed_close (false)
{ {
VBox* vbox = get_vbox (); message.set_alignment (0.0, 0.5);
vbox->set_size_request (400, -1); timeout_info.set_alignment (0.5, 0.5);
timeout_info.set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Scan is taking a long time.\nPlease check for popup dialogs.")));
Gtk::Table* tbl = manage (new Table (3, 2, false)); timeout_info.set_justify (JUSTIFY_CENTER);
timeout_info.set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Scan is taking a long time. Please check for popup dialogs.")));
timeout_info.set_padding (12, 12);
btn_cancel_all.set_name ("EditorGTKButton");
btn_cancel_all.signal_clicked.connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_scan_all));
ArdourWidgets::set_tooltip(btn_cancel_all, _("Cancel Scanning all plugins, and close this dialog. Your plugin list might be incomplete."));
btn_cancel_one.set_name ("EditorGTKButton");
btn_cancel_one.signal_clicked.connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_scan_one));
ArdourWidgets::set_tooltip(btn_cancel_one, _("Cancel Scanning this plugin. It will be Ignored in the plugin list."));
btn_timeout_one.set_name ("EditorGTKButton");
btn_timeout_one.signal_clicked.connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_scan_timeout_one));
ArdourWidgets::set_tooltip(btn_timeout_one, _("Click this button to puase scanning while you handle any dialogs that the plugin requires."));
btn_timeout_all.set_name ("EditorGTKButton");
btn_timeout_all.signal_toggled().connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_scan_timeout_all));
ArdourWidgets::set_tooltip(btn_timeout_all, _("When enabled, scan progress will pause indefinitely for plugin dialogs."));
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 (_("Plugin Scan Timeout"));
message.set_alignment(0.0, 0.5); int row = 0;
Gtk::Table* tbl = manage (new Table (3, 2, false));
/* Note when changing the layout that, the following widgets are not always visible:
* - timeout_info
* - pbar
* - btn_cancel_one
* - btn_timeout_all
* - btn_timeout_one
*/
int row = 0;
/* clang-format off */ /* clang-format off */
tbl->attach (message, 0, 2, row, row + 1, EXPAND | FILL, EXPAND | FILL, 0, 4); ++row; tbl->attach (message, 0, 2, row, row + 1, EXPAND | FILL, EXPAND | FILL, 0, 4); ++row;
tbl->attach (timeout_info, 0, 2, row, row + 1, EXPAND | FILL, SHRINK, 0, 4); ++row; tbl->attach (timeout_info, 0, 2, row, row + 1, EXPAND | FILL, SHRINK, 0, 4); ++row;
@ -101,30 +72,46 @@ PluginScanDialog::PluginScanDialog (bool just_cached, bool v, Gtk::Window* paren
tbl->show_all (); tbl->show_all ();
/* clang-format on */ /* clang-format on */
tbl->set_spacings(8); tbl->set_spacings (8);
tbl->set_border_width(8); tbl->set_border_width (8);
format_frame.add(*tbl); format_frame.add (*tbl);
format_frame.set_border_width(4); format_frame.set_border_width (4);
format_frame.set_shadow_type(Gtk::SHADOW_ETCHED_IN); format_frame.set_shadow_type (Gtk::SHADOW_ETCHED_IN);
Gtk::HBox* cancel_all_padder = manage (new HBox ()); Gtk::HBox* cancel_all_padder = manage (new HBox ());
cancel_all_padder->set_border_width(4); cancel_all_padder->set_border_width (4);
cancel_all_padder->pack_start(btn_cancel_all); cancel_all_padder->pack_start (btn_cancel_all);
Gtk::HBox* timeout_all_padder = manage (new HBox ()); Gtk::HBox* timeout_all_padder = manage (new HBox ());
timeout_all_padder->set_border_width(4); timeout_all_padder->set_border_width (4);
timeout_all_padder->pack_start(btn_timeout_all); timeout_all_padder->pack_start (btn_timeout_all);
vbox->pack_start (*timeout_all_padder, 0, 10); /* Top level packaging */
vbox->pack_start (format_frame, 0, 6); VBox* vbox = get_vbox ();
vbox->pack_start (*cancel_all_padder, 0, 6); vbox->set_size_request (400, -1);
vbox->pack_start (*timeout_all_padder, false, false);
vbox->pack_start (format_frame, true, true);
vbox->pack_start (*cancel_all_padder, false, false);
vbox->show_all ();
/* connect to signals */
ARDOUR::PluginScanMessage.connect (connections, MISSING_INVALIDATOR, boost::bind (&PluginScanDialog::message_handler, this, _1, _2, _3), gui_context ()); ARDOUR::PluginScanMessage.connect (connections, MISSING_INVALIDATOR, boost::bind (&PluginScanDialog::message_handler, this, _1, _2, _3), gui_context ());
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 (); btn_cancel_all.signal_clicked.connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_scan_all));
btn_cancel_one.signal_clicked.connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_scan_one));
btn_timeout_one.signal_clicked.connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_scan_timeout_one));
btn_timeout_all.signal_toggled ().connect (sigc::mem_fun (*this, &PluginScanDialog::cancel_scan_timeout_all));
/* set tooltips */
ArdourWidgets::set_tooltip (btn_cancel_all, _("Cancel Scanning all plugins, and close this dialog. Your plugin list might be incomplete."));
ArdourWidgets::set_tooltip (btn_cancel_one, _("Cancel Scanning this plugin. It will be Ignored in the plugin list."));
ArdourWidgets::set_tooltip (btn_timeout_one, _("Click this button to puase scanning while you handle any dialogs that the plugin requires."));
ArdourWidgets::set_tooltip (btn_timeout_all, _("When enabled, scan progress will pause indefinitely for plugin dialogs."));
/* window stacking */
if (parent) { if (parent) {
set_transient_for (*parent); set_transient_for (*parent);
set_position (Gtk::WIN_POS_CENTER_ON_PARENT); set_position (Gtk::WIN_POS_CENTER_ON_PARENT);
@ -197,6 +184,7 @@ void
PluginScanDialog::cancel_scan_all () PluginScanDialog::cancel_scan_all ()
{ {
PluginManager::instance ().cancel_scan_all (); PluginManager::instance ().cancel_scan_all ();
btn_timeout_all.set_sensitive (false);
} }
void void
@ -209,7 +197,7 @@ PluginScanDialog::cancel_scan_one ()
void void
PluginScanDialog::cancel_scan_timeout_all () PluginScanDialog::cancel_scan_timeout_all ()
{ {
if (btn_timeout_all.get_active()) { if (btn_timeout_all.get_active ()) {
PluginManager::instance ().cancel_scan_timeout_all (); PluginManager::instance ().cancel_scan_timeout_all ();
btn_timeout_all.set_sensitive (false); btn_timeout_all.set_sensitive (false);
btn_timeout_one.set_sensitive (false); btn_timeout_one.set_sensitive (false);
@ -224,17 +212,13 @@ PluginScanDialog::cancel_scan_timeout_one ()
} }
void void
PluginScanDialog::show_interactive_ctrls (bool show) PluginScanDialog::disable_per_plugin_interaction ()
{ {
if (show) { pbar.set_sensitive (false);
pbar.set_sensitive (true); pbar.set_text ("");
btn_cancel_one.set_sensitive (true); pbar.set_fraction (0);
btn_timeout_one.set_sensitive (true); btn_cancel_one.set_sensitive (false);
} else { btn_timeout_one.set_sensitive (false);
pbar.set_sensitive (false);
btn_cancel_one.set_sensitive (false);
btn_timeout_one.set_sensitive (false);
}
} }
static void static void
@ -280,8 +264,8 @@ PluginScanDialog::plugin_scan_timeout (int timeout)
timeout_info.hide (); timeout_info.hide ();
} }
btn_timeout_one.set_sensitive (timeout < scan_timeout); btn_timeout_one.set_sensitive (timeout < scan_timeout);
pbar.set_sensitive (true);
pbar.set_fraction ((float)timeout / (float)scan_timeout); pbar.set_fraction ((float)timeout / (float)scan_timeout);
show_interactive_ctrls ();
} else if (timeout < 0) { } else if (timeout < 0) {
char buf[128]; char buf[128];
format_time (buf, sizeof (buf), -timeout); format_time (buf, sizeof (buf), -timeout);
@ -289,15 +273,11 @@ PluginScanDialog::plugin_scan_timeout (int timeout)
pbar.set_text (string_compose (_("Scanning since %1"), buf)); pbar.set_text (string_compose (_("Scanning since %1"), buf));
pbar.pulse (); pbar.pulse ();
btn_timeout_one.set_sensitive (false); btn_timeout_one.set_sensitive (false);
show_interactive_ctrls ();
if (timeout <= -300) { if (timeout <= -300) {
timeout_info.show (); timeout_info.show ();
} }
} else { } else {
pbar.set_sensitive (false); disable_per_plugin_interaction ();
btn_timeout_one.set_sensitive (false);
btn_cancel_one.set_sensitive (false);
show_interactive_ctrls (false);
timeout_info.hide (); timeout_info.hide ();
} }
@ -335,10 +315,10 @@ PluginScanDialog::message_handler (std::string type, std::string plugin, bool ca
} }
if (type == X_("closeme")) { if (type == X_("closeme")) {
show_interactive_ctrls (false); disable_per_plugin_interaction ();
connections.drop_connections (); connections.drop_connections ();
btn_cancel_one.set_sensitive (false);
btn_cancel_all.set_sensitive (false); btn_cancel_all.set_sensitive (false);
btn_timeout_all.set_sensitive (false);
queue_draw (); queue_draw ();
for (int i = 0; delayed_close && i < 30; ++i) { // 1.5 sec delay for (int i = 0; delayed_close && i < 30; ++i) { // 1.5 sec delay
Glib::usleep (50000); Glib::usleep (50000);
@ -346,7 +326,7 @@ PluginScanDialog::message_handler (std::string type, std::string plugin, bool ca
} }
hide (); hide ();
} else { } else {
format_frame.set_label(type); format_frame.set_label (type);
message.set_text (_("Scanning: ") + PBD::basename_nosuffix (plugin)); message.set_text (_("Scanning: ") + PBD::basename_nosuffix (plugin));
show (); show ();
} }

View file

@ -35,17 +35,18 @@ public:
void start (); void start ();
private: private:
Gtk::Frame format_frame; Gtk::Frame format_frame;
Gtk::Label message; Gtk::Label message;
Gtk::Label timeout_info; Gtk::Label timeout_info;
Gtk::ProgressBar pbar; Gtk::ProgressBar pbar;
Gtk::CheckButton btn_timeout_all; Gtk::CheckButton btn_timeout_all;
ArdourWidgets::ArdourButton btn_timeout_one; ArdourWidgets::ArdourButton btn_timeout_one;
ArdourWidgets::ArdourButton btn_cancel_all; ArdourWidgets::ArdourButton btn_cancel_all;
ArdourWidgets::ArdourButton btn_cancel_one; ArdourWidgets::ArdourButton btn_cancel_one;
bool cache_only;
bool verbose; bool cache_only;
bool delayed_close; bool verbose;
bool delayed_close;
void on_hide (); void on_hide ();
@ -54,7 +55,7 @@ private:
void cancel_scan_timeout_all (); void cancel_scan_timeout_all ();
void cancel_scan_timeout_one (); void cancel_scan_timeout_one ();
void show_interactive_ctrls (bool show = true); void disable_per_plugin_interaction ();
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);