diff options
-rw-r--r-- | ingen/client/PluginModel.hpp | 4 | ||||
-rw-r--r-- | src/client/PluginModel.cpp | 81 | ||||
-rw-r--r-- | src/gui/Port.cpp | 20 | ||||
-rw-r--r-- | src/gui/Port.hpp | 2 | ||||
-rw-r--r-- | wscript | 9 |
5 files changed, 72 insertions, 44 deletions
diff --git a/ingen/client/PluginModel.hpp b/ingen/client/PluginModel.hpp index 7f409f02..9c4e6b41 100644 --- a/ingen/client/PluginModel.hpp +++ b/ingen/client/PluginModel.hpp @@ -81,7 +81,7 @@ public: static std::string get_lv2_icon_path(const LilvPlugin* plugin); std::string documentation(bool html) const; - std::string port_documentation(uint32_t index) const; + std::string port_documentation(uint32_t index, bool html) const; static void set_rdf_world(Sord::World& world) { _rdf_world = &world; @@ -98,6 +98,8 @@ protected: void set(SPtr<PluginModel> p); private: + std::string get_documentation(const LilvNode* subject, bool html) const; + Type _type; static LilvWorld* _lilv_world; diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 1025a7dc..a85a9968 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -272,37 +272,43 @@ PluginModel::get_lv2_icon_path(const LilvPlugin* plugin) } static std::string -heading(const std::string& text, bool html) +heading(const std::string& text, bool html, unsigned level) { if (html) { - return std::string("<h2>") + text + "</h2>\n"; + const std::string tag = std::string("h") + std::to_string(level); + return std::string("<") + tag + ">" + text + "</" + tag + ">\n"; } else { return text + ":\n\n"; } } +static std::string +link(const std::string& addr, bool html) +{ + if (html) { + return std::string("<a href=\"") + addr + "\">" + addr + "</a>"; + } else { + return addr; + } +} + std::string -PluginModel::documentation(bool html) const +PluginModel::get_documentation(const LilvNode* subject, bool html) const { std::string doc; - LilvNode* subject = (_lilv_plugin) - ? lilv_node_duplicate(lilv_plugin_get_uri(_lilv_plugin)) - : lilv_new_uri(_lilv_world, uri().c_str()); - LilvNode* lv2_documentation = lilv_new_uri(_lilv_world, - LILV_NS_LV2 "documentation"); + LV2_CORE__documentation); LilvNode* rdfs_comment = lilv_new_uri(_lilv_world, LILV_NS_RDFS "comment"); LilvNodes* vals = lilv_world_find_nodes( _lilv_world, subject, lv2_documentation, NULL); + const bool doc_is_html = vals; if (!vals) { vals = lilv_world_find_nodes( _lilv_world, subject, rdfs_comment, NULL); - // TODO: If not html, must convert to plain text } - doc += heading(human_name(), html); if (vals) { const LilvNode* val = lilv_nodes_get_first(vals); @@ -310,41 +316,52 @@ PluginModel::documentation(bool html) const doc += lilv_node_as_string(val); } } + + if (html && !doc_is_html) { + for (std::size_t i = 0; i < doc.size(); ++i) { + if (doc.substr(i, 2) == "\n\n") { + doc.replace(i, 2, "<br/><br/>"); + i += strlen("<br/><br/>"); + } + } + } + lilv_node_free(rdfs_comment); lilv_node_free(lv2_documentation); - lilv_node_free(subject); - lilv_nodes_free(vals); return doc; } std::string -PluginModel::port_documentation(uint32_t index) const +PluginModel::documentation(const bool html) const { - std::string doc; + LilvNode* subject = (_lilv_plugin) + ? lilv_node_duplicate(lilv_plugin_get_uri(_lilv_plugin)) + : lilv_new_uri(_lilv_world, uri().c_str()); - if (!_lilv_plugin) - return doc; + const std::string doc(get_documentation(subject, html)); - const LilvPort* port = lilv_plugin_get_port_by_index(_lilv_plugin, index); + lilv_node_free(subject); - //LilvNode lv2_documentation = lilv_new_uri( - // _lilv_world, LILV_NAMESPACE_LV2 "documentation"); - LilvNode* rdfs_comment = lilv_new_uri( - _lilv_world, "http://www.w3.org/2000/01/rdf-schema#comment"); + return (heading(human_name(), html, 2) + + link(uri(), html) + (html ? "<br/><br/>" : "\n\n") + + doc); +} - LilvNodes* vals = lilv_port_get_value(_lilv_plugin, - port, - rdfs_comment); - if (vals) { - const LilvNode* val = lilv_nodes_get_first(vals); - if (lilv_node_is_string(val)) { - doc += lilv_node_as_string(val); - } +std::string +PluginModel::port_documentation(uint32_t index, bool html) const +{ + if (!_lilv_plugin) { + return ""; } - lilv_node_free(rdfs_comment); - lilv_nodes_free(vals); - return doc; + + const LilvPort* port = lilv_plugin_get_port_by_index(_lilv_plugin, index); + if (!port) { + return ""; + } + + return (heading(port_human_name(index), html, 2) + + get_documentation(lilv_port_get_node(_lilv_plugin, port), html)); } const LilvPort* diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 92775483..2bdf2e43 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -32,6 +32,7 @@ #include "Style.hpp" #include "WidgetFactory.hpp" #include "WindowFactory.hpp" +#include "ingen_config.h" using namespace Ingen::Client; using namespace std; @@ -434,22 +435,27 @@ Port::property_changed(const Raul::URI& key, const Atom& value) } } -void -Port::set_selected(gboolean b) +bool +Port::on_selected(gboolean b) { - if (b != get_selected()) { - Ganv::Port::set_selected(b); + if (b) { SPtr<const PortModel> pm = _port_model.lock(); - if (pm && b) { + if (pm) { SPtr<const BlockModel> block = dynamic_ptr_cast<BlockModel>(pm->parent()); GraphWindow* win = _app.window_factory()->parent_graph_window(block); if (win && win->documentation_is_visible() && block->plugin_model()) { + bool html = false; +#ifdef HAVE_WEBKIT + html = true; +#endif const std::string& doc = block->plugin_model()->port_documentation( - pm->index()); - win->set_documentation(doc, false); + pm->index(), html); + win->set_documentation(doc, html); } } } + + return true; } } // namespace GUI diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 16fc5cde..24cddd4e 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -64,7 +64,7 @@ public: void activity(const Atom& value); void disconnected_from(SPtr<Client::PortModel> port); - void set_selected(gboolean b); + bool on_selected(gboolean b); private: Port(App& app, @@ -23,6 +23,8 @@ def options(opt): help='Ingen module install directory [Default: PREFIX/lib/ingen]') opt.add_option('--no-gui', action='store_true', dest='no_gui', help='Do not build GUI') + opt.add_option('--no-webkit', action='store_true', dest='no_webkit', + help='Do not use webkit to display plugin documentation') opt.add_option('--no-jack-session', action='store_true', default=False, dest='no_jack_session', help='Do not build JACK session support') @@ -56,7 +58,7 @@ def configure(conf): autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.120.0', mandatory=False) autowaf.check_pkg(conf, 'lilv-0', uselib_store='LILV', - atleast_version='0.16.1', mandatory=True) + atleast_version='0.17.0', mandatory=True) autowaf.check_pkg(conf, 'suil-0', uselib_store='SUIL', atleast_version='0.2.0', mandatory=True) autowaf.check_pkg(conf, 'sratom-0', uselib_store='SRATOM', @@ -72,10 +74,11 @@ def configure(conf): atleast_version='2.12.0', mandatory=False) autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='NEW_GTKMM', atleast_version='2.14.0', mandatory=False) - autowaf.check_pkg(conf, 'webkit-1.0', uselib_store='WEBKIT', - atleast_version='1.4.0', mandatory=False) autowaf.check_pkg(conf, 'ganv-1', uselib_store='GANV', atleast_version='1.2.1', mandatory=False) + if not Options.options.no_webkit: + autowaf.check_pkg(conf, 'webkit-1.0', uselib_store='WEBKIT', + atleast_version='1.4.0', mandatory=False) if not Options.options.no_socket: conf.check_cc(function_name='socket', header_name='sys/socket.h', |