[Glade-users] How to link in a gtk+ 3.0 resource file?

On 07/01/15 14:41, Tristan Van Berkom wrote:
On Wed, 2015-01-07 at 14:13 +0100, Izak van Langevelde wrote:
I spent some time trying to include a gtk+ 3.0 resource file into my
binary, without success. I created an xml file with glade, used
glib-compile-resources to create a c file, included it into my eclipse
project, get it compiled, and from there I am lost.
I don't know about eclipse, but certainly you want to integrate it
as a build rule for your project, rather than to manually include
the result of glib-compile-resources directly in your build (and
worse, commit generated files into your own source repository).
I agree, but I decided to leave build rules out of the equation, in 
order to focus on the crux of the problem.
If I use glib-compile-resources with the --manual-register option, and I
explicitly call menus_register_resource(), subsequent call of
gtk_builder_new_from_resource seems to find the resource, but generates
lots of errors like 'Gtk-CRITICAL **: gtk_settings_get_for_screen:
assertion 'GDK_IS_SCREEN (screen)' failed'.

This error does not look like it has anything to do with the actual
resources, it looks like perhaps you tried to instantiate widgets
before ever calling gtk_init() (wild guess).
That was the problem, indeed. I didn't call gtk_init because I call 
gtk_application_new, but gtk_builder_new_from_resource obviously needs 
the gtk_init. Thanks!
If I leave out the call to
menus_register_resource(), I get the error 'Gtk-ERROR **: failed to add
UI: The resource at '/com/wullie/draughts/gtk/menus.ui' does not exist'
FWIW, gresources, if not manually registered, are registered
automatically in constructor, such as gcc supports with the constructor
function attribute:

static void __attribute__((constructor)) some_function (void) {

   /* This is called automatically when the binary is loaded,
      somewhere before main()

That doesn't seem to happen...
You may try printing the value of what G_HAS_CONSTRUCTOR was at
compile time to check that your compiler supports constructors.
It is defined, otherwise the compiler gives a warning "Constructor not 
supported on this compiler, linking in resources will not work"; I 
double-checked this. Looks like things are not working for eclipse on 
Ubuntu, I will focus on this.

Anyways, thanks for your help, I am one step further.


Grinnikend door het leven...

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]