GNOME Bugzilla – Bug 107012
SVG theme support
Last modified: 2017-03-03 14:09:46 UTC
Will probably need an optional librsvg dependency to do this sanely, so
it's fast enough etc.
Could you elaborate ? Why is it optional, is there another way of
loading SVG ?
compile-time option to disable SVG support, like startup notification,
xinerama, randr, etc.
I think the main point about the librsvg dependency is to do it that
way rather than via gdk-pixbuf. The problem with gdk-pixbuf is that
we'd need to reload the SVG from disk each time we scale it, unless
gdk-pixbuf has been enhanced to avoid that. With librsvg we'd instead
keep the svg in memory and just re-render it as you resize the window.
Another library out there is Cairo + xsvg, I think, though librsvg is
probably a better idea at the moment due to maturity.
You can use GdkPixbufLoader to load the svg images to size based on
in-memory data (so metacity would cache the file contents and pass
those to the pixbuf loader).
I'm not sure how librsvg handles caching, or if that would be any
faster, but the above method would eliminate at least the disk access.
It occurs to me that if we had good, fast support for SVG in themes using one of the SVG libraries, we might not need our own XML drawing format like <rectangle> and <line> and so on (except for backwards compatibility). That would give us lots of goodies, too (like fancy gradients, say, solving bug 321278 straight off).
I'd just like to say that GTK is the cat's pyjamas. I sat down this evening to start figuring out how SVG theme support would work, and found the API looks just the same as support for raster images. In other words, we already do support SVG. I'll attach a silly little theme I just made that demonstrates this.
This also means that we get to close bug 321278 and possibly others for free. Woohoo.
Created attachment 61813 [details]
Demonstration that SVG support is already working
This theme sets the titlebar to an SVG file containing a diagonal gradient fill on the left and a radial fill on the right. It looks pretty ridiculous, but it shows the point.
If anyone else can reproduce my results, I think we can mark this FIXED now.
We could make some really wacky themes with this. It should be fun. I think it means that there's no longer any need to create any new drawing primitives. You could even get away with deprecating everything other than <image/>, I suppose.
If you mean loading svg with gdk-pixbuf, see the earlier comment on this bug for the problem there (I think?). If you load svg "natively"/as-vector then you're right, additional primitives would not necessarily be needed... although, note that if the theme were just a big svg image you wouldn't be able to properly line up elements with the buttons, adjust for various font sizes, etc. - so it will remain important to have the "layout" handled in the metacity format, or something.
When messing with any theme feature, be sure to use metacity-theme-viewer to look at all the window types and the button combinatorics and be sure the theme feature can support the diversity of cases.
Another note on this bug is that Cairo has become the clear choice in the modern world, right...