3
我試圖更新vala中的圖形項目,將很多代碼行移動到一個ui文件中。 我想使用模板(可用於glib-2.38和GTK + 3.8,類似的)。如何在anjuta項目中包含資源文件
我的項目由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
謝謝,我試圖使用作爲模式的猴麪包樹makefile,但我錯過了構建的C文件應該添加到spi_SOURCES的部分。 – 2014-10-08 21:39:47