+ ARDOUR_UI::instance()->set_tip (focus_button, string_compose (_("Click to allow the plugin to receive keyboard events that %1 would normally use as a shortcut"), PROGRAM_NAME));
+ ARDOUR_UI::instance()->set_tip (bypass_button, _("Click to enable/disable this plugin"));
+
+ plugin_analysis_expander.property_expanded().signal_changed().connect( sigc::mem_fun(*this, &PlugUIBase::toggle_plugin_analysis));
+ plugin_analysis_expander.set_expanded(false);
+
+ insert->DropReferences.connect (death_connection, invalidator (*this), boost::bind (&PlugUIBase::plugin_going_away, this), gui_context());
+
+ plugin->PresetAdded.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::preset_added_or_removed, this), gui_context ());
+ plugin->PresetRemoved.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::preset_added_or_removed, this), gui_context ());
+ plugin->PresetLoaded.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::update_preset, this), gui_context ());
+ plugin->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&PlugUIBase::parameter_changed, this, _1, _2), gui_context ());
+}
+
+PlugUIBase::~PlugUIBase()
+{
+ delete latency_gui;
+}
+
+void
+PlugUIBase::plugin_going_away ()
+{
+ /* drop references to the plugin/insert */
+ insert.reset ();
+ plugin.reset ();
+ death_connection.disconnect ();
+}
+
+void
+PlugUIBase::set_latency_label ()
+{
+ framecnt_t const l = insert->effective_latency ();
+ framecnt_t const sr = insert->session().frame_rate ();
+
+ string t;
+
+ if (l < sr / 1000) {
+ t = string_compose (_("latency (%1 samples)"), l);
+ } else {
+ t = string_compose (_("latency (%1 ms)"), (float) l / ((float) sr / 1000.0f));
+ }
+
+ latency_label.set_text (t);
+}
+
+void
+PlugUIBase::latency_button_clicked ()
+{
+ if (!latency_gui) {
+ latency_gui = new LatencyGUI (*(insert.get()), insert->session().frame_rate(), insert->session().get_block_size());
+ latency_dialog = new ArdourDialog ("Edit Latency", false, false);
+ latency_dialog->get_vbox()->pack_start (*latency_gui);
+ latency_dialog->signal_hide().connect (sigc::mem_fun (*this, &PlugUIBase::set_latency_label));
+ }
+
+ latency_dialog->show_all ();