我试图更新vala中的一个图形项目,将许多代码行移动到ui文件中。我想使用模板(与glib-2.38和GTK+3.8类似)。
我的项目由Anjuta和autoconf管理。
在src目录中,有
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>在src/Makefile.am中,我将--gresources resources.xml附加到spi_VALAFLAGS中。最后,我像这样声明了Gtk.ApplicationWindow
[GtkTemplate(ui = "/org/app/spi/application.ui")]
internal class SpiWindow : Gtk.ApplicationWindow {
// Constructor
public Window (Gtk.Application application) {
Object(application: application);
}
}但是,当我编译并运行应用程序时,会出现以下错误消息:
(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发布于 2014-10-08 21:12:19
您仍然需要编译这些资源并将它们包括在内:
GLIB_COMPILE_RESOURCES=glib-compile-resources
resources.c: resources.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies resources.xml)
$(GLIB_COMPILE_RESOURCES) --target=$@ --generate-source $<并将resources.c作为源文件包含在spi_SOURCES中。
https://stackoverflow.com/questions/26265836
复制相似问题