Revert afedd2 and associated commits (method to generate initial tag file)
[ardour.git] / gtk2_ardour / plugin_selector.cc
index 077c600ffde002253ae5d3b89cc2841b1ba1581f..314e36ebb75572799b5c16d6e6338f29fd3d8fdb 100644 (file)
@@ -68,10 +68,12 @@ PluginSelector::PluginSelector (PluginManager& mgr)
        _plugin_menu = 0;
        in_row_change = false;
 
+       //anytime the list changes ( Status, Tags, or scanned plugins ) we need to rebuild redirect-box plugin selector menu
        manager.PluginListChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::build_plugin_menu, this), gui_context());
-       manager.PluginListChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::refill, this), gui_context());
-       manager.PluginStatusesChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::plugin_status_changed, this, _1, _2, _3), gui_context());
-       manager.PluginTagsChanged.connect(plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::tags_changed, this, _1, _2, _3), gui_context());
+
+       //these are used to update the info of specific entries, while they are being edited
+       manager.PluginStatusChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::plugin_status_changed, this, _1, _2, _3), gui_context());
+       manager.PluginTagChanged.connect(plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::tags_changed, this, _1, _2, _3), gui_context());
 
        plugin_model = Gtk::ListStore::create (plugin_columns);
        plugin_display.set_model (plugin_model);
@@ -160,17 +162,19 @@ PluginSelector::PluginSelector (PluginManager& mgr)
        _search_ignore_checkbox->set_active(true);
        _search_ignore_checkbox->set_name ("pluginlist filter button");
 
-       Gtk::Label* search_help_label = manage (new Label(
-                       _("All search terms must be matched.\n"
-                         "Ex: \"ess dyn\" will find \"dynamic de-esser\" but not \"de-esser\"."
-                        ), Gtk::ALIGN_LEFT));
+       Gtk::Label* search_help_label1 = manage (new Label(
+               _("All search terms must be matched."), Gtk::ALIGN_LEFT));
+
+       Gtk::Label* search_help_label2 = manage (new Label(
+               _("Ex: \"ess dyn\" will find \"dynamic de-esser\" but not \"de-esser\"."), Gtk::ALIGN_LEFT));
 
        search_table->attach (search_entry,            0, 3, 0, 1, FILL|EXPAND, FILL);
        search_table->attach (search_clear_button,     3, 4, 0, 1, FILL, FILL);
        search_table->attach (*_search_name_checkbox,  0, 1, 1, 2, FILL, FILL);
        search_table->attach (*_search_tags_checkbox,  1, 2, 1, 2, FILL, FILL);
        search_table->attach (*_search_ignore_checkbox,2, 3, 1, 2, FILL, FILL);
-       search_table->attach (*search_help_label,      0, 3, 2, 3, FILL, FILL);
+       search_table->attach (*search_help_label1,     0, 3, 2, 3, FILL, FILL);
+       search_table->attach (*search_help_label2,     0, 3, 3, 4, FILL, FILL);
 
        search_table->set_border_width (4);
        search_table->set_col_spacings (4);
@@ -268,16 +272,21 @@ PluginSelector::PluginSelector (PluginManager& mgr)
        tag_reset_button = manage (new Button (_("Reset")));
        tag_reset_button->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::tag_reset_button_clicked));
 
-       Gtk::Label* tagging_help_label = manage (new Label(
-                       _("Enter space-separated, one-word Tags for the selected plugin.\n"
-                         "You can include dashes, colons or underscores in a Tag.\n"
-                         "Ex: \"dynamic de-esser vocal\" applies 3 Tags."
-                        ), Gtk::ALIGN_LEFT));
+       Gtk::Label* tagging_help_label1 = manage (new Label(
+               _("Enter space-separated, one-word Tags for the selected plugin."), Gtk::ALIGN_LEFT));
+
+       Gtk::Label* tagging_help_label2 = manage (new Label(
+               _("You can include dashes, colons or underscores in a Tag."), Gtk::ALIGN_LEFT));
+
+       Gtk::Label* tagging_help_label3 = manage (new Label(
+               _("Ex: \"dynamic de-esser vocal\" applies 3 Tags."), Gtk::ALIGN_LEFT));
 
        int p = 0;
        tagging_table->attach (*tag_entry,           0, 1, p, p+1, FILL|EXPAND, FILL);
        tagging_table->attach (*tag_reset_button,    1, 2, p, p+1, FILL, FILL); p++;
-       tagging_table->attach (*tagging_help_label,  0, 2, p, p+1, FILL, FILL); p++;
+       tagging_table->attach (*tagging_help_label1, 0, 2, p, p+1, FILL, FILL); p++;
+       tagging_table->attach (*tagging_help_label2, 0, 2, p, p+1, FILL, FILL); p++;
+       tagging_table->attach (*tagging_help_label3, 0, 2, p, p+1, FILL, FILL); p++;
 
        Frame* tag_frame = manage (new Frame);
        tag_frame->set_name ("BaseFrame");
@@ -377,6 +386,9 @@ PluginSelector::show_this_plugin (const PluginInfoPtr& info, const std::string&
 
                /* user asked to ignore filters */
                if (maybe_show && _search_ignore_checkbox->get_active()) {
+                       if (manager.get_status (info) == PluginManager::Hidden) {
+                               return false;
+                       }
                        return true;
                }
        }
@@ -401,10 +413,8 @@ PluginSelector::show_this_plugin (const PluginInfoPtr& info, const std::string&
                return false;
        }
 
-       if (manager.get_status (info) == PluginManager::Hidden) {
-               if (!_fil_hidden_radio->get_active() && !_fil_all_radio->get_active()) {
-                       return false;
-               }
+       if (!_fil_hidden_radio->get_active() && manager.get_status (info) == PluginManager::Hidden) {
+               return false;
        }
 
        /* Filter "type" combobox */
@@ -810,8 +820,8 @@ PluginSelector::run ()
                manager.save_statuses();
        }
 
-       if (_need_menu_rebuild) {
-               build_plugin_menu();
+       if ( _need_tag_save || _need_status_save || _need_menu_rebuild ) {
+               manager.PluginListChanged();  //emit signal
        }
 
        return (int) r;
@@ -832,6 +842,7 @@ PluginSelector::tag_reset_button_clicked ()
                manager.reset_tags (pi);
                display_selection_changed ();
                _need_tag_save = true;
+               _need_menu_rebuild = true;
        }
 }
 
@@ -854,6 +865,7 @@ PluginSelector::tag_entry_changed ()
                manager.set_tags (pi->type, pi->unique_id, tag_entry->get_text(), false);
 
                _need_tag_save = true;
+               _need_menu_rebuild = true;
        }
 }
 
@@ -868,11 +880,6 @@ PluginSelector::tags_changed (PluginType t, std::string unique_id, std::string t
                }
                row[plugin_columns.tags] = tags;
        }
-
-       /* A plugin's tags change while the user is entering them.
-        * defer a rebuilding of the "tag" menu until the dialog is closed.
-        */
-       _need_menu_rebuild = true;
 }
 
 void
@@ -898,9 +905,6 @@ PluginSelector::plugin_status_changed (PluginType t, std::string uid, PluginMana
                                        plugin_model->erase(i);
                        }
 
-                       /* plugin menu must be re-built to accommodate Hidden and Favorite plugins */
-                       build_plugin_menu();
-
                        return;
                }
        }
@@ -1126,7 +1130,7 @@ PluginSelector::create_by_tags_menu (ARDOUR::PluginInfoList& all_plugs)
        by_tags->set_name("ArdourContextMenu");
        MenuList& by_tags_items = by_tags->items();
 
-       std::vector<std::string> all_tags = manager.get_all_tags(false);
+       std::vector<std::string> all_tags = manager.get_all_tags (PluginManager::NoHidden);
        for (vector<string>::iterator t = all_tags.begin(); t != all_tags.end(); ++t) {
                Gtk::Menu *submenu = new Gtk::Menu;
                by_tags_items.push_back (MenuElem (*t, *manage (submenu)));
@@ -1148,12 +1152,11 @@ PluginSelector::create_by_tags_menu (ARDOUR::PluginInfoList& all_plugs)
                        Gtk::Menu* submenu;
                        if ((x = tags_submenu_map.find (*t)) != tags_submenu_map.end()) {
                                submenu = x->second;
-                       } else {
+                               string typ = GetPluginTypeStr(*i);
+                               MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
+                               elem.get_child()->set_use_underline (false);
+                               submenu->items().push_back (elem);
                        }
-                       string typ = GetPluginTypeStr(*i);
-                       MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
-                       elem.get_child()->set_use_underline (false);
-                       submenu->items().push_back (elem);
                }
        }
        return by_tags;
@@ -1201,6 +1204,7 @@ PluginSelector::favorite_changed (const std::string& path)
                manager.set_status (pi->type, pi->unique_id, status);
 
                _need_status_save = true;
+               _need_menu_rebuild = true;
        }
        in_row_change = false;
 }
@@ -1233,6 +1237,7 @@ PluginSelector::hidden_changed (const std::string& path)
                manager.set_status (pi->type, pi->unique_id, status);
 
                _need_status_save = true;
+               _need_menu_rebuild = true;
        }
        in_row_change = false;
 }