+
+bool
+PlugUIBase::focus_toggled (GdkEventButton*)
+{
+ if (Keyboard::the_keyboard().some_magic_widget_has_focus()) {
+ Keyboard::the_keyboard().magic_widget_drop_focus();
+ focus_button.remove ();
+ focus_button.add (*focus_out_image);
+ focus_out_image->show ();
+ 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));
+ KeyboardFocused (false);
+ } else {
+ Keyboard::the_keyboard().magic_widget_grab_focus();
+ focus_button.remove ();
+ focus_button.add (*focus_in_image);
+ focus_in_image->show ();
+ ARDOUR_UI::instance()->set_tip (focus_button, string_compose (_("Click to allow normal use of %1 keyboard shortcuts"), PROGRAM_NAME));
+ KeyboardFocused (true);
+ }
+
+ return true;
+}
+
+void
+PlugUIBase::toggle_plugin_analysis()
+{
+ if (plugin_analysis_expander.get_expanded() &&
+ !plugin_analysis_expander.get_child()) {
+ // Create the GUI
+ PluginEqGui *foo = new PluginEqGui(insert);
+ plugin_analysis_expander.add( *foo );
+ plugin_analysis_expander.show_all();
+ }
+
+ Gtk::Widget *gui;
+
+ if (!plugin_analysis_expander.get_expanded() &&
+ (gui = plugin_analysis_expander.get_child())) {
+ // Hide & remove
+ gui->hide();
+ //plugin_analysis_expander.remove(*gui);
+ plugin_analysis_expander.remove();
+
+ delete gui;
+
+ Gtk::Widget *toplevel = plugin_analysis_expander.get_toplevel();
+ if (!toplevel) {
+ std::cerr << "No toplevel widget?!?!" << std::endl;
+ return;
+ }
+
+ Gtk::Container *cont = dynamic_cast<Gtk::Container *>(toplevel);
+ if (!cont) {
+ std::cerr << "Toplevel widget is not a container?!?" << std::endl;
+ return;
+ }
+
+ Gtk::Allocation alloc(0, 0, 50, 50); // Just make it small
+ toplevel->size_allocate(alloc);
+ }
+}
+
+void
+PlugUIBase::update_preset_list ()
+{
+ vector<string> preset_labels;
+ vector<ARDOUR::Plugin::PresetRecord> presets = plugin->get_presets();
+
+ ++_no_load_preset;
+
+ for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
+ preset_labels.push_back (i->label);
+ }
+
+ set_popdown_strings (_preset_combo, preset_labels);
+
+ --_no_load_preset;
+}
+
+void
+PlugUIBase::update_preset ()
+{
+ Plugin::PresetRecord p = plugin->last_preset();
+
+ ++_no_load_preset;
+ _preset_combo.set_active_text (p.label);
+ --_no_load_preset;
+
+ save_button.set_sensitive (!p.uri.empty() && p.user);
+ delete_button.set_sensitive (!p.uri.empty() && p.user);
+
+ update_preset_modified ();
+}
+
+void
+PlugUIBase::update_preset_modified ()
+{
+ if (plugin->last_preset().uri.empty()) {
+ _preset_modified.set_text ("");
+ return;
+ }
+
+ bool const c = plugin->parameter_changed_since_last_preset ();
+ if (_preset_modified.get_text().empty() == c) {
+ _preset_modified.set_text (c ? "*" : "");
+ }
+}
+
+void
+PlugUIBase::parameter_changed (uint32_t, float)
+{
+ update_preset_modified ();
+}
+
+void
+PlugUIBase::preset_added_or_removed ()
+{
+ /* Update both the list and the currently-displayed preset */
+ update_preset_list ();
+ update_preset ();
+}