GNOME Bugzilla – Bug 744102
Install GtkBuilder XML schema
Last modified: 2015-04-30 13:27:48 UTC
It would be useful if gtkbuilder.rnc and gtkbuilder.rng were installed on the system (and I guess packaged as part of gtk3-devel), so that GTK+ applications could validate their UI files against the schema at build time. Perhaps installed to $(datadir)/xml/gtk-3.0/, as seems to be the convention for other schemas? That would allow rules like the following in applications’ Makefile.ams: check-builder: $(UI_FILES) $(XMLLINT) --relaxng $(datadir)/xml/gtk-3.0/gtkbuilder.rnc $(UI_FILES) check: check-builder .PHONY: check-builder
(In reply to comment #0) > Perhaps installed to $(datadir)/xml/gtk-3.0/, as seems to be the convention for > other schemas? Although I’ve just noticed GLib installs gsettings.dtd to $(datadir)/glib-2.0/schemas/, so something like $(datadir)/gtk-3.0/schemas/ is also an option.
(In reply to Philip Withnall from comment #0) > That would allow rules like the following in applications’ Makefile.ams: > > check-builder: $(UI_FILES) > $(XMLLINT) --relaxng $(datadir)/xml/gtk-3.0/gtkbuilder.rnc $(UI_FILES) Have you tried this ?
(In reply to Matthias Clasen from comment #2) > (In reply to Philip Withnall from comment #0) > > > That would allow rules like the following in applications’ Makefile.ams: > > > > check-builder: $(UI_FILES) > > $(XMLLINT) --relaxng $(datadir)/xml/gtk-3.0/gtkbuilder.rnc $(UI_FILES) > > > Have you tried this ? Just tried it locally on a project, and the rule ended up being: check-builder: $(ui_DATA) xmllint --nonet --noblanks --noout --relaxng /path/to/gtkbuilder.rng $^ check-local: check-builder .PHONY: check-builder (In reply to Philip Withnall from comment #1) > (In reply to comment #0) > > Perhaps installed to $(datadir)/xml/gtk-3.0/, as seems to be the convention for > > other schemas? > > Although I’ve just noticed GLib installs gsettings.dtd to > $(datadir)/glib-2.0/schemas/, so something like $(datadir)/gtk-3.0/schemas/ > is also an option. Which path would you prefer? I’ll whip up a patch.
[mclasen@localhost gtk+]$ xmllint --nonet --noblanks --noout --relaxng ./gtk/gtkbuilder.rnc gtk/ui/gtkfilechooserwidget.ui ./gtk/gtkbuilder.rnc:1: parser error : Start tag expected, '<' not found start = element interface { ^ Relax-NG parser error : xmlRelaxNGParse: could not load ./gtk/gtkbuilder.rnc Relax-NG schema ./gtk/gtkbuilder.rnc failed to compile ...
oh sorry, you used the .rng, not the .rnc
(In reply to Matthias Clasen from comment #5) > oh sorry, you used the .rng, not the .rnc yeah, I didn’t realise before but the .rnc is the compact version of the schema, which xmllint apparently doesn’t support. I suspect we should still install both, though, just in case the compact version is useful to someone? Or we could be conservative and just install the .rng.
seems to me that we already install the rng file, btw: [mclasen@localhost ~]$ rpm -ql gtk3-devel | grep rng /usr/share/gtk-3.0/gtkbuilder.rng
(In reply to Matthias Clasen from comment #7) > seems to me that we already install the rng file, btw: > > [mclasen@localhost ~]$ rpm -ql gtk3-devel | grep rng > /usr/share/gtk-3.0/gtkbuilder.rng I don’t understand how I missed that before. It’s right above where I was checking in the Makefile the first time round. I guess I must have been grepping for ‘.rnc’. :-( So apart from completely wasting your time with this bug, I guess there are a couple of open questions: 1. Should we also install the .rnc? Probably not, since xmllint can’t use it, and that’s what we care about. 2. Is the current installation path OK? Probably, since there’s no real standard for this. 3. Should GTK+ provide an automake macro for installing and checking GtkBuilder files? At the moment it would just be the check-builder rule, but I suspect it could also support magically packaging gtk/menus[-appmenu|-traditional].ui into a GResource (in a way that complements the GResource support in Makefile.glib, bug #654395).
1. no, the rnc is there for the purpose of showing it in the doc (showing the xml version would be just cruel) 2. yes 3. I'd rather not
(In reply to Matthias Clasen from comment #9) > 1. no, the rnc is there for the purpose of showing it in the doc (showing > the xml version would be just cruel) > > 2. yes Great, no changes to be made for those then. > 3. I'd rather not Why not? The only alternative I see is for people to cargo-cult the makefile snippet above, plus potentially the snippets needed for gtk/menus[-appmenu|-traditional].ui.
we're now installing a tool that lets you validate ui files
(In reply to Matthias Clasen from comment #11) > we're now installing a tool that lets you validate ui files For future reference, that tool is gtk-builder-validate, and you use it as: gtk-builder-validate validate my-ui-file.ui It validates using the actual GtkBuilder parser, so is always going to be correct with respect to GTK+ behaviour, whereas the XML schema might get out of date. Would have been nice to see some planning or discussion of gtk-builder-tool somewhere.
There was no planning... Christian asked for such a tool for gnome-builder, and I took a few evenings to write a prototype.