I'm trying to use GtkTemplate, but it is really annoyingly not working. I have defined .ui file resources, properly calling it & etc.
Here is my files:
meson.build:
# project name and programming language
project('myproject', 'vala', 'c', version: '1.0.0')
# add resources to the executeable
gnome = import('gnome')
gresources = gnome.compile_resources(
meson.project_name() + '.resources',
'data/gresources.xml',
c_name: 'resources'
)
executable(
meson.project_name(),
'src/OpenFileWindow.vala',
'src/Main.vala',
gresources,
dependencies: [
dependency('gtk+-3.0'),
dependency('gio-2.0'),
],
install: true
)
src/OpenFileWindow.vala:
using Gtk;
namespace MyProject {
[GtkTemplate (ui="/ui/OpenFileWindow.ui")]
public class OpenFileWindow : Window {
[GtkChild]
Button btn_browse;
public OpenFileWindow() {
}
[GtkCallback]
private void btn_browse_clicked(Button btn) {
stdout.printf("CLICKED");
}
}
}
ui/OpenFileWindow.ui:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="OpenFileWindow" parent="GtkWindow">
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="btn_browse">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="image_position">top</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="myproject_openfilewindow_btn_browse_clicked" swapped="no"/>
</object>
</child>
</template>
</interface>
data/gresources.xml:
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/">
<file preprocess="xml-stripblanks">ui/OpenFileWindow.ui</file>
</gresource>
</gresources>
And when I builded with meson & ninja, it gives this error:
valac -C --debug --debug --pkg gio-2.0 --pkg gtk+-3.0 --color=always --directory myproject@exe --basedir ../ --gresources=../data/gresources.xml ../src/OpenFileWindow.vala ../src/Main.vala
../src/OpenFileWindow.vala:6.5-6.40: error: UI resource not found: `/ui/OpenFileWindow.ui'. Please make sure to specify the proper GResources xml files with --gresources and alternative search locations with --gresourcesdir.
public class OpenFileWindow : Window {
What is the problem, I really can't see it... Thanks!