I'm trying to update a graphical project in vala, moving lot of code lines into an ui file. I want to use template (available with glib-2.38 and GTK+3.8, something like that).
My project is managed with Anjuta and autoconf.
In the src
directory there are
application.ui
:
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.8 -->
<template class="SpiWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
<child>
<placeholder />
</child>
</template>
</interface>
resources.xml
:
<?xml version="1.0" charset="UTF-8" ?>
<gresources>
<gresource prefix="/org/app/spi">
<file compressed="true" preprocess="xml-stripblanks">application.ui</file>
</gresource>
</gresources>
in src/Makefile.am
I have append --gresources resources.xml
to the spi_VALAFLAGS
. And finally I declared The Gtk.ApplicationWindow
like this
[GtkTemplate(ui = "/org/app/spi/application.ui")]
internal class SpiWindow : Gtk.ApplicationWindow {
// Constructor
public Window (Gtk.Application application) {
Object(application: application);
}
}
But when I compile and then run the application, there is the error message :
(spi:9749): Gtk-CRITICAL : Unable to load resource for composite template for type 'SpiWindow': The resource at '/org/app/spi/application.ui' does not exist
(spi:9749): Gtk-CRITICAL : gtk_widget_init_template: assertion 'template != NULL' failed