After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 744102 - Install GtkBuilder XML schema
Install GtkBuilder XML schema
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Class: GtkBuilder
3.15.x
Other All
: Normal enhancement
: ---
Assigned To: GtkBuilder maintainers
GtkBuilder maintainers
Depends on:
Blocks:
 
 
Reported: 2015-02-06 15:31 UTC by Philip Withnall
Modified: 2015-04-30 13:27 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Philip Withnall 2015-02-06 15:31:13 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
Comment 1 Philip Withnall 2015-02-06 15:40:21 UTC
(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.
Comment 2 Matthias Clasen 2015-02-12 01:16:49 UTC
(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 ?
Comment 3 Philip Withnall 2015-02-12 14:18:27 UTC
(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.
Comment 4 Matthias Clasen 2015-02-12 14:22:42 UTC
[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


...
Comment 5 Matthias Clasen 2015-02-12 14:29:09 UTC
oh sorry, you used the .rng, not the .rnc
Comment 6 Philip Withnall 2015-02-12 15:26:17 UTC
(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.
Comment 7 Matthias Clasen 2015-02-12 15:53:40 UTC
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
Comment 8 Philip Withnall 2015-02-13 09:55:55 UTC
(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).
Comment 9 Matthias Clasen 2015-02-13 15:30:56 UTC
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
Comment 10 Philip Withnall 2015-02-16 09:00:30 UTC
(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.
Comment 11 Matthias Clasen 2015-04-29 19:26:42 UTC
we're now installing a tool that lets you validate ui files
Comment 12 Philip Withnall 2015-04-30 06:34:23 UTC
(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.
Comment 13 Matthias Clasen 2015-04-30 13:27:48 UTC
There was no planning... Christian asked for such a tool for gnome-builder, and I took a few evenings to write a prototype.