summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-18 16:33:28 +0000
committerDavid Robillard <d@drobilla.net>2011-02-18 16:33:28 +0000
commit8e07e115429a0869593d4f29dc3e6cf5c8b25049 (patch)
tree68cfdc5ee4a1c932d05ee8988f2738f31c119218 /src/client
parent7ef2c6553339a3c38f8784d764a8f2610bde5d89 (diff)
downloadingen-8e07e115429a0869593d4f29dc3e6cf5c8b25049.tar.gz
ingen-8e07e115429a0869593d4f29dc3e6cf5c8b25049.tar.bz2
ingen-8e07e115429a0869593d4f29dc3e6cf5c8b25049.zip
Use port name from SLV2 for labels where possible (fix ticket #636).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2991 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r--src/client/NodeModel.cpp27
-rw-r--r--src/client/NodeModel.hpp2
2 files changed, 29 insertions, 0 deletions
diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp
index 2ffd751d..1ff3cae6 100644
--- a/src/client/NodeModel.cpp
+++ b/src/client/NodeModel.cpp
@@ -221,6 +221,33 @@ NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max) c
}
+std::string
+NodeModel::port_label(SharedPtr<PortModel> port) const
+{
+ const Raul::Atom& name = port->get_property("http://lv2plug.in/ns/lv2core#name");
+ if (name.is_valid()) {
+ return name.get_string();
+ }
+
+#ifdef HAVE_SLV2
+ if (_plugin && _plugin->type() == PluginModel::LV2) {
+ SLV2World c_world = _plugin->slv2_world();
+ SLV2Plugin c_plugin = _plugin->slv2_plugin();
+ SLV2Value c_sym = slv2_value_new_string(c_world, port->symbol().c_str());
+ SLV2Port c_port = slv2_plugin_get_port_by_symbol(c_plugin, c_sym);
+ if (c_port) {
+ SLV2Value c_name = slv2_port_get_name(c_plugin, c_port);
+ if (c_name && slv2_value_is_string(c_name)) {
+ return slv2_value_as_string(c_name);
+ }
+ }
+ }
+#endif
+
+ return port->symbol().c_str();
+}
+
+
void
NodeModel::set(SharedPtr<ObjectModel> model)
{
diff --git a/src/client/NodeModel.hpp b/src/client/NodeModel.hpp
index fa4af66c..939197b1 100644
--- a/src/client/NodeModel.hpp
+++ b/src/client/NodeModel.hpp
@@ -67,6 +67,8 @@ public:
void default_port_value_range(SharedPtr<PortModel> port, float& min, float& max) const;
void port_value_range(SharedPtr<PortModel> port, float& min, float& max) const;
+ std::string port_label(SharedPtr<PortModel> port) const;
+
// Signals
sigc::signal<void, SharedPtr<PortModel> > signal_new_port;
sigc::signal<void, SharedPtr<PortModel> > signal_removed_port;