如何在Anjuta项目中包含资源文件

编程入门 行业动态 更新时间:2024-10-24 03:23:09
本文介绍了如何在Anjuta项目中包含资源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试更新vala中的图形项目,将许多代码行移到ui文件中. 我想使用模板(可用于glib-2.38和GTK + 3.8,类似这样).

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).

我的项目由Anjuta和autoconf管理.

My project is managed with Anjuta and 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

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

推荐答案

您仍然需要编译资源并将其包括在内:

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 $<

,并将resources.c作为源文件包含在spi_SOURCES中.

and include resources.c as a source file in spi_SOURCES.

更多推荐

如何在Anjuta项目中包含资源文件

本文发布于:2023-07-16 20:18:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125500.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   项目   如何在   资源   Anjuta

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!