How to include resource file in anjuta project

I am trying to update a graphical project in vala by moving many lines of code to the ui file. I want to use a template (available as of glib-2.38 and GTK + 3.8, something like that).

My project is managed with Anjuta and autoconf.

The catalog src

contains

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 add --gresources resources.xml

to spi_VALAFLAGS

. Finally, I declared The Gtk.ApplicationWindow

as follows

[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 run the application, the error message appears:

(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

      

+3


source to share


1 answer


You still need to compile the resources and include them:

GLIB_COMPILE_RESOURCES=glib-compile-resources

resources.c: resources.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies resources.xml)
  $(GLIB_COMPILE_RESOURCES) --target=$@  --generate-source $<

      



and include resources.c

as source file in spi_SOURCES

.

+3


source







All Articles