2014-10-08 98 views
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.xmlspi_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 

回答

3

你仍然需要編譯的資源,並將它們包括:

GLIB_COMPILE_RESOURCES=glib-compile-resources 

resources.c: resources.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies resources.xml) 
    $(GLIB_COMPILE_RESOURCES) [email protected] --generate-source $< 

並且包括resources.c作爲spi_SOURCES中的源文件。

+1

謝謝,我試圖使用作爲模式的猴麪包樹makefile,但我錯過了構建的C文件應該添加到spi_SOURCES的部分。 – 2014-10-08 21:39:47

相關問題