summaryrefslogtreecommitdiffstats
path: root/src/libs/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-24 01:58:15 +0000
committerDavid Robillard <d@drobilla.net>2007-07-24 01:58:15 +0000
commit5c0d12b6a96e1a0468f81ee14e6440f4f6d570bb (patch)
tree8a55bb3d649c74ddc7abc6bf89094d833aba5b91 /src/libs/gui
parent69d18d7f335c5f19c13ff09d6fd04557de048ea1 (diff)
downloadingen-5c0d12b6a96e1a0468f81ee14e6440f4f6d570bb.tar.gz
ingen-5c0d12b6a96e1a0468f81ee14e6440f4f6d570bb.tar.bz2
ingen-5c0d12b6a96e1a0468f81ee14e6440f4f6d570bb.zip
Don't show empty plugin category menus.
git-svn-id: http://svn.drobilla.net/lad/ingen@607 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/gui')
-rw-r--r--src/libs/gui/PatchCanvas.cpp28
-rw-r--r--src/libs/gui/PatchCanvas.h2
2 files changed, 20 insertions, 10 deletions
diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp
index f37b81c5..d08b7b86 100644
--- a/src/libs/gui/PatchCanvas.cpp
+++ b/src/libs/gui/PatchCanvas.cpp
@@ -109,10 +109,12 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height)
}
-void
+size_t
PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu,
SLV2PluginClass plugin_class, SLV2PluginClasses classes)
{
+ size_t num_items = 0;
+
#ifdef HAVE_SLV2
// Add submenus
for (unsigned i=0; i < slv2_plugin_classes_size(classes); ++i) {
@@ -120,12 +122,18 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu,
const char* parent = slv2_plugin_class_get_parent_uri(c);
if (parent && !strcmp(parent, slv2_plugin_class_get_uri(plugin_class))) {
- menu->items().push_back(Gtk::Menu_Helpers::MenuElem(
- slv2_plugin_class_get_label(c)));
- Gtk::MenuItem* menu_item = &(menu->items().back());
+ Gtk::Menu_Helpers::MenuElem menu_elem = Gtk::Menu_Helpers::MenuElem(
+ slv2_plugin_class_get_label(c));
+
Gtk::Menu* submenu = Gtk::manage(new Gtk::Menu());
- menu_item->set_submenu(*submenu);
- build_plugin_class_menu(submenu, c, classes);
+ size_t sub_num_items = build_plugin_class_menu(submenu, c, classes);
+
+ if (sub_num_items > 0) {
+ menu->items().push_back(menu_elem);
+ Gtk::MenuItem* menu_item = &(menu->items().back());
+ menu_item->set_submenu(*submenu);
+ ++num_items;
+ }
}
}
@@ -135,14 +143,16 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu,
// Add plugins
for (Store::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) {
SLV2Plugin p = i->second->slv2_plugin();
- if (p && slv2_plugin_get_class(p) == plugin_class)
+ if (p && slv2_plugin_get_class(p) == plugin_class) {
menu->items().push_back(Gtk::Menu_Helpers::MenuElem(i->second->name(),
sigc::bind(sigc::mem_fun(this, &PatchCanvas::load_plugin),
i->second)));
+ ++num_items;
+ }
}
-
-
#endif
+
+ return num_items;
}
diff --git a/src/libs/gui/PatchCanvas.h b/src/libs/gui/PatchCanvas.h
index da33142b..1cf9f410 100644
--- a/src/libs/gui/PatchCanvas.h
+++ b/src/libs/gui/PatchCanvas.h
@@ -87,7 +87,7 @@ private:
void menu_load_patch();
void load_plugin(SharedPtr<PluginModel> plugin);
void build_plugin_menu();
- void build_plugin_class_menu(Gtk::Menu* menu,
+ size_t build_plugin_class_menu(Gtk::Menu* menu,
SLV2PluginClass plugin_class, SLV2PluginClasses classes);
MetadataMap get_initial_data();