I'm making an app for elementary OS using Vala. I use a .glade file to define the interface and I load it in the app with:
this.builder = new Gtk.Builder ();
builder.add_from_file ("src/filename.glade");
It obviously only works when I run the program from the project folder (where there is src folder).
My question is, how do I correctly define the route to the .glade file in order to make the application work after installing it in the system using cmake? (the cmake file has been built following the elementary os guide).
To sum up:
- Which is the correct way to define routes to files, imatges (like logos), etc. in an app which is installed in the system (elementary and other linux ditros)?
- Are these files placed in an specific folder? Do i have to define it in the cmake file or some other file?
You probably want to use GResources. In an extra build step, you compile your resource files, such as Glade, into C files that get included in the compilation process. Then, use
new GtkBuilder.from_resource
to include the configuration. There are similar resource-based methods for images and files.