From 406d7376bf8faf0965fb87feaf6401962d357962 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 14 Aug 2008 20:22:45 +0000 Subject: Only show GUI menu items for nodes with available GUIs. git-svn-id: http://svn.drobilla.net/lad/ingen@1378 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/PluginModel.cpp | 20 +++++++++++++++++++- src/libs/client/PluginModel.hpp | 2 ++ src/libs/gui/NodeMenu.cpp | 6 +++++- 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp index 80d6a9f1..c798294d 100644 --- a/src/libs/client/PluginModel.cpp +++ b/src/libs/client/PluginModel.cpp @@ -44,6 +44,25 @@ PluginModel::default_node_name() #ifdef HAVE_SLV2 +bool +PluginModel::has_ui() const +{ + Glib::Mutex::Lock lock(_rdf_world->mutex()); + + SLV2Value gtk_gui_uri = slv2_value_new_uri(_slv2_world, + "http://lv2plug.in/ns/extensions/ui#GtkUI"); + + SLV2UIs uis = slv2_plugin_get_uis(_slv2_plugin); + + if (slv2_values_size(uis) > 0) + for (unsigned i=0; i < slv2_uis_size(uis); ++i) + if (slv2_ui_is_a(slv2_uis_get_at(uis, i), gtk_gui_uri)) + return true; + + return false; +} + + SharedPtr PluginModel::ui(Ingen::Shared::World* world, SharedPtr node) const { @@ -87,7 +106,6 @@ PluginModel::get_lv2_icon_path(SLV2Plugin plugin) slv2_value_free(svg_icon_pred); return result; } - #endif } // namespace Client diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp index a7adc735..f8630e94 100644 --- a/src/libs/client/PluginModel.hpp +++ b/src/libs/client/PluginModel.hpp @@ -100,6 +100,8 @@ public: _slv2_plugins = slv2_world_get_all_plugins(_slv2_world); } + bool has_ui() const; + SharedPtr ui(Ingen::Shared::World* world, SharedPtr node) const; diff --git a/src/libs/gui/NodeMenu.cpp b/src/libs/gui/NodeMenu.cpp index 6051ec7c..05139540 100644 --- a/src/libs/gui/NodeMenu.cpp +++ b/src/libs/gui/NodeMenu.cpp @@ -64,7 +64,11 @@ NodeMenu::init(SharedPtr node) _embed_gui_menuitem->signal_toggled().connect(sigc::mem_fun(this, &NodeMenu::on_menu_embed_gui)); - if ((!node->plugin()) || node->plugin()->type() != PluginModel::LV2) { + const PluginModel* plugin = dynamic_cast(node->plugin()); + if (plugin && plugin->type() == PluginModel::LV2 && plugin->has_ui()) { + _popup_gui_menuitem->show(); + _embed_gui_menuitem->show(); + } else { _popup_gui_menuitem->hide(); _embed_gui_menuitem->hide(); } -- cgit v1.2.1