diff options
author | David Robillard <d@drobilla.net> | 2008-10-07 02:20:42 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-10-07 02:20:42 +0000 |
commit | 3898c80765f00d364c2cab73879e9ffcd05ce4e0 (patch) | |
tree | 6315c76ed4939a1f8dec58b5c4bf904b1aac9a07 /src | |
parent | 7f82c616aef73dc96885db8d3c689350f1c85c19 (diff) | |
download | ingen-3898c80765f00d364c2cab73879e9ffcd05ce4e0.tar.gz ingen-3898c80765f00d364c2cab73879e9ffcd05ce4e0.tar.bz2 ingen-3898c80765f00d364c2cab73879e9ffcd05ce4e0.zip |
Add support for plugin class multiple inheritance (multiple menu entires for a single plugin class).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1629 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/PatchCanvas.cpp | 31 | ||||
-rw-r--r-- | src/gui/PatchCanvas.hpp | 2 |
2 files changed, 19 insertions, 14 deletions
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index f4274e4a..2a7eaa30 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -200,7 +200,7 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu, size_t num_items = 0; SLV2Value class_uri = slv2_plugin_class_get_uri(plugin_class); - _class_menus[slv2_value_as_string(class_uri)] = menu; + _class_menus.insert(make_pair(slv2_value_as_string(class_uri), menu)); // Add submenus for (unsigned i=0; i < slv2_plugin_classes_size(classes); ++i) { @@ -311,21 +311,26 @@ PatchCanvas::add_plugin(SharedPtr<PluginModel> p) } else if (_plugin_menu && p->type() == Plugin::LV2) { SLV2PluginClass pc = slv2_plugin_get_class(p->slv2_plugin()); SLV2Value class_uri = slv2_plugin_class_get_uri(pc); - ClassMenus::iterator i = _class_menus.find(slv2_value_as_string(class_uri)); + const char* class_uri_str = slv2_value_as_string(class_uri); + ClassMenus::iterator i = _class_menus.find(class_uri_str); if (i != _class_menus.end() && i->second != _plugin_menu) { - Gtk::Menu* menu = i->second; Glib::RefPtr<Gdk::Pixbuf> icon = App::instance().icon_from_path( PluginModel::get_lv2_icon_path(p->slv2_plugin()), 16); - if (icon) { - Gtk::Image* image = new Gtk::Image(icon); - menu->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(p->human_name(), - *image, - sigc::bind(sigc::mem_fun(this, &PatchCanvas::load_plugin), p))); - } else { - menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p->human_name(), - sigc::bind(sigc::mem_fun(this, &PatchCanvas::load_plugin), p))); - menu->show(); - } + // For every menu that represents plugin's class (possibly several) + do { + Gtk::Menu* menu = i->second; + if (icon) { + Gtk::Image* image = new Gtk::Image(icon); + menu->items().push_back(Gtk::Menu_Helpers::ImageMenuElem(p->human_name(), + *image, + sigc::bind(sigc::mem_fun(this, &PatchCanvas::load_plugin), p))); + } else { + menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p->human_name(), + sigc::bind(sigc::mem_fun(this, &PatchCanvas::load_plugin), p))); + menu->show(); + } + i++; + } while (i != _class_menus.end() && i->first == class_uri_str); } else { _classless_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p->human_name(), sigc::bind(sigc::mem_fun(this, &PatchCanvas::load_plugin), p))); diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp index b1474495..842f25f6 100644 --- a/src/gui/PatchCanvas.hpp +++ b/src/gui/PatchCanvas.hpp @@ -132,7 +132,7 @@ private: int _last_click_x; int _last_click_y; - typedef std::map<const std::string, Gtk::Menu*> ClassMenus; + typedef std::multimap<const std::string, Gtk::Menu*> ClassMenus; ClassMenus _class_menus; bool _refresh_menu; |