summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-02-14 02:11:58 +0000
committerDavid Robillard <d@drobilla.net>2009-02-14 02:11:58 +0000
commit12e74d4a26eede059f016cc8a7806a57d5c9338e (patch)
tree644ff21b05996230cb20716ce492c097f8137dea
parentf4958d2d28f89fa8aaa3e31e6bdf87106ca784a6 (diff)
downloadingen-12e74d4a26eede059f016cc8a7806a57d5c9338e.tar.gz
ingen-12e74d4a26eede059f016cc8a7806a57d5c9338e.tar.bz2
ingen-12e74d4a26eede059f016cc8a7806a57d5c9338e.zip
LV2 preset support (except you have to press entire on the menu items, clicking doesn't work because Gtk is fucking retarded).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1934 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/client/PluginModel.hpp4
-rw-r--r--src/gui/NodeMenu.cpp59
-rw-r--r--src/gui/NodeMenu.hpp2
3 files changed, 60 insertions, 5 deletions
diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp
index 41ed0d93..cd9598b3 100644
--- a/src/client/PluginModel.hpp
+++ b/src/client/PluginModel.hpp
@@ -61,8 +61,8 @@ public:
string port_human_name(uint32_t index) const;
#ifdef HAVE_SLV2
- static SLV2World slv2_world() { return _slv2_world; }
- SLV2Plugin slv2_plugin() { return _slv2_plugin; }
+ static SLV2World slv2_world() { return _slv2_world; }
+ SLV2Plugin slv2_plugin() const { return _slv2_plugin; }
SLV2Port slv2_port(uint32_t index) {
Glib::Mutex::Lock lock(_rdf_world->mutex());
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index 468364d1..defce091 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.cpp
@@ -34,6 +34,7 @@ namespace GUI {
NodeMenu::NodeMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml)
: ObjectMenu(cobject, xml)
, _controls_menuitem(NULL)
+ , _presets_menu(NULL)
{
Gtk::Menu* node_menu = NULL;
xml->get_widget("node_menu", node_menu);
@@ -65,11 +66,9 @@ NodeMenu::init(SharedPtr<NodeModel> node)
_learn_menuitem->signal_activate().connect(sigc::mem_fun(this,
&NodeMenu::on_menu_learn));
-
_controls_menuitem->signal_activate().connect(sigc::bind(
sigc::mem_fun(App::instance().window_factory(), &WindowFactory::present_controls),
node));
-
_popup_gui_menuitem->signal_activate().connect(sigc::mem_fun(signal_popup_gui,
&sigc::signal<void>::emit));
_embed_gui_menuitem->signal_toggled().connect(sigc::mem_fun(this,
@@ -85,6 +84,34 @@ NodeMenu::init(SharedPtr<NodeModel> node)
_popup_gui_menuitem->hide();
_embed_gui_menuitem->hide();
}
+
+#ifdef HAVE_SLV2
+ if (plugin && plugin->type() == PluginModel::LV2) {
+ SLV2Results presets = slv2_plugin_query_sparql(plugin->slv2_plugin(),
+ "PREFIX lv2p: <http://lv2plug.in/ns/dev/presets#>\n"
+ "PREFIX dc: <http://dublincore.org/documents/dcmi-namespace/>\n"
+ "SELECT ?p ?name WHERE { <> lv2p:hasPreset ?p . ?p dc:title ?name }\n");
+ if (!slv2_results_finished(presets)) {
+ items().push_front(Gtk::Menu_Helpers::SeparatorElem());
+ items().push_front(Gtk::Menu_Helpers::ImageMenuElem("_Presets",
+ *(manage(new Gtk::Image(Gtk::Stock::INDEX, Gtk::ICON_SIZE_MENU)))));
+ Gtk::MenuItem* presets_menu_item = &(items().front());
+ _presets_menu = Gtk::manage(new Gtk::Menu());
+ presets_menu_item->set_submenu(*_presets_menu);
+ for (; !slv2_results_finished(presets); slv2_results_next(presets)) {
+ SLV2Value uri = slv2_results_get_binding_value(presets, 0);
+ SLV2Value name = slv2_results_get_binding_value(presets, 1);
+ Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(slv2_value_as_string(name)));
+ _presets_menu->items().push_back(*item);
+ item->show();
+ item->signal_activate().connect(
+ sigc::bind(sigc::mem_fun(this, &NodeMenu::on_preset_activated),
+ string(slv2_value_as_string(uri))), false);
+ }
+ }
+ slv2_results_free(presets);
+ }
+#endif
if (has_control_inputs())
_randomize_menuitem->show();
@@ -141,6 +168,33 @@ NodeMenu::on_menu_disconnect()
}
+void
+NodeMenu::on_preset_activated(const std::string uri)
+{
+#ifdef HAVE_SLV2
+ const NodeModel* const node = (NodeModel*)_object.get();
+ const PluginModel* const plugin = dynamic_cast<const PluginModel*>(node->plugin());
+ const string query = string(
+ "PREFIX lv2p: <http://lv2plug.in/ns/dev/presets#>\n"
+ "PREFIX dc: <http://dublincore.org/documents/dcmi-namespace/>\n"
+ "SELECT ?sym ?val WHERE { <") + uri + "> lv2:port ?port . "
+ " ?port lv2:symbol ?sym ; lv2p:value ?val . }";
+ SLV2Results values = slv2_plugin_query_sparql(plugin->slv2_plugin(), query.c_str());
+ App::instance().engine()->bundle_begin();
+ for (; !slv2_results_finished(values); slv2_results_next(values)) {
+ SLV2Value sym = slv2_results_get_binding_value(values, 0);
+ SLV2Value val = slv2_results_get_binding_value(values, 1);
+ App::instance().engine()->set_port_value(
+ node->path().base() + slv2_value_as_string(sym),
+ slv2_value_as_float(val));
+
+ }
+ App::instance().engine()->bundle_end();
+ slv2_results_free(values);
+#endif
+}
+
+
bool
NodeMenu::has_control_inputs()
{
@@ -167,7 +221,6 @@ NodeMenu::disable_controls_menuitem()
}
-
} // namespace GUI
} // namespace Ingen
diff --git a/src/gui/NodeMenu.hpp b/src/gui/NodeMenu.hpp
index cbe39c2f..a15b2b91 100644
--- a/src/gui/NodeMenu.hpp
+++ b/src/gui/NodeMenu.hpp
@@ -58,12 +58,14 @@ protected:
void on_menu_learn();
void on_menu_embed_gui();
void on_menu_randomize();
+ void on_preset_activated(const std::string uri);
Gtk::MenuItem* _learn_menuitem;
Gtk::MenuItem* _controls_menuitem;
Gtk::MenuItem* _popup_gui_menuitem;
Gtk::CheckMenuItem* _embed_gui_menuitem;
Gtk::MenuItem* _randomize_menuitem;
+ Gtk::Menu* _presets_menu;
};