diff options
author | David Robillard <d@drobilla.net> | 2015-10-30 17:02:07 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-10-30 17:02:07 +0000 |
commit | 8510f80faad7a719a97cf14b1a82a1cc2141282b (patch) | |
tree | 11ab0ede29a4a2e29d1e689f6b2cb23ee0da47f1 /src/gui | |
parent | 2fe35cd17f96a1d393fda203ccaa234b0aa69b16 (diff) | |
download | ingen-8510f80faad7a719a97cf14b1a82a1cc2141282b.tar.gz ingen-8510f80faad7a719a97cf14b1a82a1cc2141282b.tar.bz2 ingen-8510f80faad7a719a97cf14b1a82a1cc2141282b.zip |
Update clients when plugins are unloaded/reloaded
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5808 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/GraphCanvas.cpp | 18 | ||||
-rw-r--r-- | src/gui/GraphCanvas.hpp | 2 | ||||
-rw-r--r-- | src/gui/PluginMenu.cpp | 16 | ||||
-rw-r--r-- | src/gui/PluginMenu.hpp | 1 |
4 files changed, 33 insertions, 4 deletions
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 16739a55..85ab4855 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -88,6 +88,7 @@ GraphCanvas::GraphCanvas(App& app, , _plugin_menu(NULL) , _human_names(true) , _show_port_names(true) + , _menu_dirty(false) { Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("canvas_menu"); xml->get_widget("canvas_menu", _menu); @@ -157,6 +158,8 @@ GraphCanvas::GraphCanvas(App& app, _app.store()->signal_new_plugin().connect( sigc::mem_fun(this, &GraphCanvas::add_plugin)); + _app.store()->signal_plugin_deleted().connect( + sigc::mem_fun(this, &GraphCanvas::remove_plugin)); // Connect widget signals to do things _menu_load_plugin->signal_activate().connect( @@ -178,7 +181,7 @@ GraphCanvas::show_menu(bool position, unsigned button, uint32_t time) { _app.request_plugins_if_necessary(); - if (!_internal_menu) + if (!_internal_menu || _menu_dirty) build_menus(); if (position) @@ -205,7 +208,9 @@ GraphCanvas::build_menus() } // Build skeleton LV2 plugin class heirarchy for 'Plugin' menu - if (!_plugin_menu) { + if (_plugin_menu) { + _plugin_menu->clear(); + } else { _plugin_menu = Gtk::manage(new PluginMenu(*_app.world())); _menu->items().push_back( Gtk::Menu_Helpers::ImageMenuElem( @@ -223,6 +228,8 @@ GraphCanvas::build_menus() for (const auto& p : *plugins.get()) { add_plugin(p.second); } + + _menu_dirty = false; } void @@ -308,6 +315,13 @@ GraphCanvas::add_plugin(SPtr<PluginModel> p) } void +GraphCanvas::remove_plugin(const Raul::URI& uri) +{ + // Flag menus as dirty so they will be rebuilt when needed next + _menu_dirty = true; +} + +void GraphCanvas::add_block(SPtr<const BlockModel> bm) { SPtr<const GraphModel> pm = dynamic_ptr_cast<const GraphModel>(bm); diff --git a/src/gui/GraphCanvas.hpp b/src/gui/GraphCanvas.hpp index 8970a88a..b055d530 100644 --- a/src/gui/GraphCanvas.hpp +++ b/src/gui/GraphCanvas.hpp @@ -63,6 +63,7 @@ public: bool show_port_names() const { return _show_port_names; } void add_plugin(SPtr<Client::PluginModel> pm); + void remove_plugin(const Raul::URI& uri); void add_block(SPtr<const Client::BlockModel> bm); void remove_block(SPtr<const Client::BlockModel> bm); void add_port(SPtr<const Client::PortModel> pm); @@ -149,6 +150,7 @@ private: bool _human_names; bool _show_port_names; + bool _menu_dirty; }; } // namespace GUI diff --git a/src/gui/PluginMenu.cpp b/src/gui/PluginMenu.cpp index 9bc47bff..c997bf19 100644 --- a/src/gui/PluginMenu.cpp +++ b/src/gui/PluginMenu.cpp @@ -25,10 +25,22 @@ PluginMenu::PluginMenu(Ingen::World& world) : _world(world) , _classless_menu(NULL, NULL) { + clear(); +} + +void +PluginMenu::clear() +{ const LilvWorld* lworld = _world.lilv_world(); const LilvPluginClass* lv2_plugin = lilv_world_get_plugin_class(lworld); const LilvPluginClasses* classes = lilv_world_get_plugin_classes(lworld); + // Empty completely + _classless_menu = MenuRecord(NULL, NULL); + _class_menus.clear(); + items().clear(); + + // Build skeleton LV2Children children; LILV_FOREACH(plugin_classes, i, classes) { const LilvPluginClass* c = lilv_plugin_classes_get(classes, i); @@ -44,7 +56,7 @@ PluginMenu::PluginMenu(Ingen::World& world) items().push_back(Gtk::Menu_Helpers::MenuElem("_Uncategorized")); _classless_menu.item = &(items().back()); - _classless_menu.menu = new Gtk::Menu(); + _classless_menu.menu = Gtk::manage(new Gtk::Menu()); _classless_menu.item->set_submenu(*_classless_menu.menu); _classless_menu.item->hide(); } @@ -109,7 +121,7 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu, menu->items().push_back(menu_elem); Gtk::MenuItem* menu_item = &(menu->items().back()); - Gtk::Menu* submenu = new Gtk::Menu(); + Gtk::Menu* submenu = Gtk::manage(new Gtk::Menu()); menu_item->set_submenu(*submenu); size_t num_child_items = build_plugin_class_menu( diff --git a/src/gui/PluginMenu.hpp b/src/gui/PluginMenu.hpp index c8fda171..bc654db5 100644 --- a/src/gui/PluginMenu.hpp +++ b/src/gui/PluginMenu.hpp @@ -43,6 +43,7 @@ class PluginMenu : public Gtk::Menu public: PluginMenu(Ingen::World& world); + void clear(); void add_plugin(SPtr<Client::PluginModel> p); sigc::signal< void, WPtr<Client::PluginModel> > signal_load_plugin; |