Search code examples
cgtksvg

State-of-the-art for embedding scriptable, interactive SVG in Gtk+ applications?


I'm interested in writing a Gtk application that uses an embedded SVG canvas for graphics, and I'm wondering what the current state-of-the-art is for using SVG in Gtk. I know that it's possible to embed Webkit inside of Gtk, and so that seems like one approach, but I would like to add interactivity to DOM elements in the embedded SVG canvas using C instead of JavaScript, and I'm not sure if the embedded Webkit exposes its DOM APIs to the embedding C context. I'm wondering if there might be a better approach. The last article I was able to find on the subject was from 2004: http://www.osnews.com/story/6460


Solution

  • Librsvg (Reference Manual / GitLab) is the preferred way to draw SVG into GTK+ widgets. However, to my knowledge, it doesn't support any kind of interactivity (only drawing).

    Regarding WebKit, it does expose the DOM through webkit_web_view_get_dom_document. Have a look at the WebKitGtk tests for some examples.