summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-10-01 04:40:15 +0000
committerDavid Robillard <d@drobilla.net>2011-10-01 04:40:15 +0000
commit5757ab645cae1d844d6d457ab2dea4a12d21a4e7 (patch)
treea04498c8c006365d5d6f8ad7569dc7cbe4e878b8
parentb60baed5cca3da9aeaba8bf4957cbf469a4b69c7 (diff)
downloadingen-5757ab645cae1d844d6d457ab2dea4a12d21a4e7.tar.gz
ingen-5757ab645cae1d844d6d457ab2dea4a12d21a4e7.tar.bz2
ingen-5757ab645cae1d844d6d457ab2dea4a12d21a4e7.zip
Support inline display of HTML LV2 documentation via WebKit.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3515 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--include/ingen/client/PluginModel.hpp2
-rw-r--r--src/client/PluginModel.cpp28
-rw-r--r--src/gui/NodeModule.cpp8
-rw-r--r--src/gui/PatchCanvas.cpp2
-rw-r--r--src/gui/PatchWindow.cpp53
-rw-r--r--src/gui/PatchWindow.hpp6
-rw-r--r--src/gui/Port.cpp5
-rw-r--r--src/gui/ingen_gui.ui16
-rw-r--r--src/gui/wscript7
-rw-r--r--wscript4
10 files changed, 94 insertions, 37 deletions
diff --git a/include/ingen/client/PluginModel.hpp b/include/ingen/client/PluginModel.hpp
index 99657fbc..28a64578 100644
--- a/include/ingen/client/PluginModel.hpp
+++ b/include/ingen/client/PluginModel.hpp
@@ -76,7 +76,7 @@ public:
const std::string& icon_path() const;
static std::string get_lv2_icon_path(const LilvPlugin* plugin);
- std::string documentation() const;
+ std::string documentation(bool* html) const;
std::string port_documentation(uint32_t index) const;
static void set_rdf_world(Sord::World& world) {
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index 80b78887..1d13ee5b 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -28,6 +28,8 @@
#include "ingen/client/PluginModel.hpp"
#include "ingen/client/PluginUI.hpp"
+#include "ingen-config.h"
+
using namespace std;
using namespace Raul;
@@ -225,19 +227,27 @@ PluginModel::get_lv2_icon_path(const LilvPlugin* plugin)
}
std::string
-PluginModel::documentation() const
+PluginModel::documentation(bool* html) const
{
std::string doc;
- if (!_lilv_plugin)
+ if (!_lilv_plugin) {
return doc;
+ }
- //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");
+ LilvNode* lv2_documentation = lilv_new_uri(_lilv_world,
+ LILV_NS_LV2 "documentation");
+ LilvNode* rdfs_comment = lilv_new_uri(_lilv_world,
+ LILV_NS_RDFS "comment");
+
+ LilvNodes* vals = lilv_plugin_get_value(_lilv_plugin, lv2_documentation);
+ if (vals) {
+ *html = true;
+ doc += std::string("<h2>") + human_name() + "</h2>\n";
+ } else {
+ *html = false;
+ vals = lilv_plugin_get_value(_lilv_plugin, rdfs_comment);
+ }
- LilvNodes* vals = lilv_plugin_get_value(_lilv_plugin,
- rdfs_comment);
if (vals) {
const LilvNode* val = lilv_nodes_get_first(vals);
if (lilv_node_is_string(val)) {
@@ -245,6 +255,8 @@ PluginModel::documentation() const
}
}
lilv_node_free(rdfs_comment);
+ lilv_node_free(lv2_documentation);
+
lilv_nodes_free(vals);
return doc;
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index 8f66b3bd..20eebdd1 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -415,14 +415,14 @@ NodeModule::set_selected(bool b)
PatchWindow* win = app.window_factory()->parent_patch_window(node());
if (win) {
std::string doc;
+ bool html = false;
if (node()->plugin_model()) {
- doc = node()->plugin_model()->documentation();
+ doc = node()->plugin_model()->documentation(&html);
}
if (!doc.empty()) {
- win->doc_textview()->get_buffer()->set_text(doc);
- win->doc_textview()->show();
+ win->show_documentation(doc, html);
} else {
- win->doc_textview()->hide();
+ win->hide_documentation();
}
}
}
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp
index ded2cbe9..d8d89651 100644
--- a/src/gui/PatchCanvas.cpp
+++ b/src/gui/PatchCanvas.cpp
@@ -591,7 +591,7 @@ PatchCanvas::clear_selection()
const App& app = App::instance();
PatchWindow* win = app.window_factory()->patch_window(_patch);
if (win) {
- win->doc_textview()->hide();
+ win->hide_documentation();
}
FlowCanvas::Canvas::clear_selection();
diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp
index 1d20c732..d03d665e 100644
--- a/src/gui/PatchWindow.cpp
+++ b/src/gui/PatchWindow.cpp
@@ -15,31 +15,40 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "PatchWindow.hpp"
#include <cassert>
#include <sstream>
+
#include <boost/format.hpp>
#include <glib/gstdio.h>
#include <glibmm/fileutils.h>
+
#include "raul/AtomRDF.hpp"
+
#include "ingen/ServerInterface.hpp"
-#include "shared/LV2URIMap.hpp"
-#include "ingen/client/PatchModel.hpp"
#include "ingen/client/ClientStore.hpp"
+#include "ingen/client/PatchModel.hpp"
+#include "shared/LV2URIMap.hpp"
+
#include "App.hpp"
-#include "PatchCanvas.hpp"
+#include "BreadCrumbs.hpp"
+#include "Configuration.hpp"
+#include "ConnectWindow.hpp"
+#include "LoadPatchWindow.hpp"
#include "LoadPluginWindow.hpp"
+#include "MessagesWindow.hpp"
#include "NewSubpatchWindow.hpp"
-#include "LoadPatchWindow.hpp"
#include "NodeControlWindow.hpp"
-#include "Configuration.hpp"
-#include "MessagesWindow.hpp"
+#include "PatchCanvas.hpp"
#include "PatchTreeWindow.hpp"
-#include "BreadCrumbs.hpp"
-#include "ConnectWindow.hpp"
+#include "PatchView.hpp"
+#include "PatchWindow.hpp"
#include "ThreadedLoader.hpp"
#include "WindowFactory.hpp"
-#include "PatchView.hpp"
+#include "ingen-config.h"
+
+#ifdef HAVE_WEBKIT
+#include <webkit/webkit.h>
+#endif
using namespace Raul;
@@ -95,6 +104,7 @@ PatchWindow::PatchWindow(BaseObjectType* cobject,
xml->get_widget("patch_view_messages_window_menuitem", _menu_view_messages_window);
xml->get_widget("patch_view_patch_tree_window_menuitem", _menu_view_patch_tree_window);
xml->get_widget("patch_help_about_menuitem", _menu_help_about);
+ xml->get_widget("patch_documentation_viewport", _doc_viewport);
xml->get_widget("patch_documentation_textview", _doc_textview);
_menu_view_control_window->property_sensitive() = false;
@@ -298,6 +308,29 @@ PatchWindow::patch_port_removed(SharedPtr<const PortModel> port)
}
void
+PatchWindow::show_documentation(const std::string& doc, bool html)
+{
+#ifdef HAVE_WEBKIT
+ WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ webkit_web_view_load_html_string(view, doc.c_str(), "");
+ _doc_viewport->add(*Gtk::manage(Glib::wrap(GTK_WIDGET(view))));
+ _doc_viewport->show_all();
+#else
+ Gtk::TextView* view = Gtk::manage(new Gtk::TextView());
+ view->get_buffer()->set_text(doc);
+ _doc_viewport->add(*view);
+ _doc_viewport->show_all();
+#endif
+}
+
+void
+PatchWindow::hide_documentation()
+{
+ _doc_viewport->remove();
+ _doc_viewport->hide();
+}
+
+void
PatchWindow::show_status(const ObjectModel* model)
{
std::stringstream msg;
diff --git a/src/gui/PatchWindow.hpp b/src/gui/PatchWindow.hpp
index 4ba9d123..4766cb99 100644
--- a/src/gui/PatchWindow.hpp
+++ b/src/gui/PatchWindow.hpp
@@ -57,11 +57,12 @@ public:
const Glib::RefPtr<Gtk::Builder>& xml);
~PatchWindow();
- Gtk::TextView* doc_textview() { return _doc_textview; }
-
void set_patch_from_path(const Raul::Path& path, SharedPtr<PatchView> view);
void set_patch(SharedPtr<const PatchModel> pc, SharedPtr<PatchView> view);
+ void show_documentation(const std::string& doc, bool html);
+ void hide_documentation();
+
SharedPtr<const PatchModel> patch() const { return _patch; }
Gtk::MenuItem* menu_view_control_window() { return _menu_view_control_window; }
@@ -153,6 +154,7 @@ private:
BreadCrumbs* _breadcrumbs;
Gtk::Statusbar* _status_bar;
+ Gtk::Viewport* _doc_viewport;
Gtk::TextView* _doc_textview;
sigc::connection _entered_connection;
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 809f43f1..b0c4ffcb 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -311,10 +311,9 @@ Port::set_selected(bool b)
const std::string& doc = node->plugin_model()->port_documentation(
pm->index());
if (!doc.empty()) {
- win->doc_textview()->get_buffer()->set_text(doc);
- win->doc_textview()->show();
+ win->show_documentation(doc, false);
} else {
- win->doc_textview()->hide();
+ win->hide_documentation();
}
}
}
diff --git a/src/gui/ingen_gui.ui b/src/gui/ingen_gui.ui
index 63aea196..66d7cc19 100644
--- a/src/gui/ingen_gui.ui
+++ b/src/gui/ingen_gui.ui
@@ -2187,12 +2187,18 @@ Contributors:
</packing>
</child>
<child>
- <object class="GtkTextView" id="patch_documentation_textview">
+ <object class="GtkViewport" id="patch_documentation_viewport">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="wrap_mode">word</property>
- <property name="cursor_visible">False</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkTextView" id="patch_documentation_textview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="wrap_mode">word</property>
+ <property name="cursor_visible">False</property>
+ </object>
+ </child>
</object>
<packing>
<property name="resize">False</property>
diff --git a/src/gui/wscript b/src/gui/wscript
index dd9c4770..ca254d45 100644
--- a/src/gui/wscript
+++ b/src/gui/wscript
@@ -55,13 +55,14 @@ def build(bld):
GLIBMM
GNOMECANVASMM
GTKMM
+ LILV
+ LV2CORE
RAUL
- SORD
SIGCPP
- LV2CORE
- LILV
+ SORD
SOUP
SUIL
+ WEBKIT
''')
# XML UI definition
diff --git a/wscript b/wscript
index 375b0597..489eb65e 100644
--- a/wscript
+++ b/wscript
@@ -63,6 +63,8 @@ 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, 'flowcanvas-1', uselib_store='FLOWCANVAS',
atleast_version='1.0.0', mandatory=False)
if not Options.options.no_http:
@@ -117,6 +119,8 @@ def configure(conf):
autowaf.display_msg(conf, "HTTP", conf.is_defined('HAVE_SOUP'))
autowaf.display_msg(conf, "LV2", conf.is_defined('HAVE_LILV'))
autowaf.display_msg(conf, "GUI", str(conf.env['INGEN_BUILD_GUI'] == 1))
+ autowaf.display_msg(conf, "HTML plugin documentation support",
+ conf.is_defined('HAVE_WEBKIT'))
print('')
def build(bld):