diff options
Diffstat (limited to 'src/gui/NodeMenu.cpp')
-rw-r--r-- | src/gui/NodeMenu.cpp | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index b9b6467c..f63384d3 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -73,46 +73,53 @@ NodeMenu::init(App& app, SharedPtr<const NodeModel> node) } if (plugin && plugin->type() == PluginModel::LV2) { - LilvNode* preset_pred = lilv_new_uri( - plugin->lilv_world(), - "http://lv2plug.in/ns/ext/presets#hasPreset"); - LilvNode* title_pred = lilv_new_uri( - plugin->lilv_world(), - "http://www.w3.org/2000/01/rdf-schema#label"); - LilvNodes* presets = lilv_plugin_get_value( - plugin->lilv_plugin(), preset_pred); + + LilvNode* pset_Preset = lilv_new_uri(plugin->lilv_world(), + LV2_PRESETS__Preset); + LilvNode* rdfs_label = lilv_new_uri(plugin->lilv_world(), + LILV_NS_RDFS "label"); + LilvNodes* presets = lilv_plugin_get_related(plugin->lilv_plugin(), + pset_Preset); if (presets) { _presets_menu = Gtk::manage(new Gtk::Menu()); LILV_FOREACH(nodes, i, presets) { - const LilvNode* uri = lilv_nodes_get(presets, i); - LilvNodes* titles = lilv_world_find_nodes( - plugin->lilv_world(), uri, title_pred, NULL); - if (titles) { - const LilvNode* title = lilv_nodes_get_first(titles); + const LilvNode* preset = lilv_nodes_get(presets, i); + lilv_world_load_resource(plugin->lilv_world(), preset); + LilvNodes* labels = lilv_world_find_nodes( + plugin->lilv_world(), preset, rdfs_label, NULL); + if (labels) { + const LilvNode* label = lilv_nodes_get_first(labels); _presets_menu->items().push_back( Gtk::Menu_Helpers::MenuElem( - lilv_node_as_string(title), + lilv_node_as_string(label), sigc::bind( sigc::mem_fun(this, &NodeMenu::on_preset_activated), - string(lilv_node_as_string(uri))))); + string(lilv_node_as_string(preset))))); // I have no idea why this is necessary, signal_activated doesn't work // in this menu (and only this menu) Gtk::MenuItem* item = &(_presets_menu->items().back()); item->signal_button_release_event().connect( sigc::bind<0>(sigc::mem_fun(this, &NodeMenu::on_preset_clicked), - string(lilv_node_as_string(uri)))); + string(lilv_node_as_string(preset)))); + + lilv_nodes_free(labels); + } else { + Raul::error << "Preset <" + << lilv_node_as_string(lilv_nodes_get(presets, i)) + << "> has no rdfs:label" << std::endl; } } + items().push_front(Gtk::Menu_Helpers::ImageMenuElem("_Presets", - *(manage(new Gtk::Image(Gtk::Stock::INDEX, Gtk::ICON_SIZE_MENU))))); + *(manage(new Gtk::Image(Gtk::Stock::INDEX, Gtk::ICON_SIZE_MENU))))); Gtk::MenuItem* presets_menu_item = &(items().front()); presets_menu_item->set_submenu(*_presets_menu); + lilv_nodes_free(presets); } - lilv_nodes_free(presets); - lilv_node_free(title_pred); - lilv_node_free(preset_pred); + lilv_node_free(pset_Preset); + lilv_node_free(rdfs_label); } if (has_control_inputs()) |