I understand the what are the arguments for the functions gtk_builder_new_from_file
or gtk_builder_new_from_string
but I struggle a little to see what is a resource path like:
GtkBuilder *
gtk_builder_new_from_resource (const gchar *resource_path);
I can not found any example (C, python, vala or other I don't mind).
Edit: Solution
Thanks to the help of gnianmt here is a basic example in ruby (https://github.com/ruby-gnome2/ruby-gnome2):
first a simple ui file simple_window.ui :
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkWindow" id="window">
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
<property name="ellipsize">end</property>
</object>
</child>
</object>
</interface>
Create then a simple_window.gresource.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/simple_window">
<file>simple_window.ui</file>
</gresource>
</gresources>
Package this with :
glib-compile-resources simple_window.gresource.xml
Which create a simple_window.gresource binary file.
Now the ruby script:
#!/usr/bin/env ruby
require "gtk3"
path = File.expand_path(File.dirname(__FILE__))
resource = Gio::Resource.load("#{path}/simple_window.gresource")
Gio::Resources.register(resource)
builder = Gtk::Builder.new(:resource => "/simple_window/simple_window.ui")
window = builder.get_object("window")
window.show_all
Gtk.main