On Thu, 19 Mar 2015, Stefan Salewski wrote:

in the last months I was working on GTK3 bindings for the Nim
programming language (http://nim-lang.org/). Now that they are nearly
complete (https://github.com/StefanSalewski?tab=repositories) I tried to
make some example code. One is the gtksourceview test-completion.c
example, currently from gtk 3.12. Works fine, with one difference
between C original and my Nim one: Without any modifications I get an
error message about "Invalid object type GtkSourceView" from Nim
equivalent of gtk_builder_add_from_file(builder, "test-completion.ui",
&error). I can easily fix that by putting a dummy allocation like "var
h1 = view_new()" in front of gtk_builder_add_from_file() call. I think
something like "gtk_source_view_get_type()" may work also. I think that
will register the gtk_source_view gobject, and then builder can use it.
People using GTKmm or Python reports from similar problems, see
http://comments.gmane.org/gmane.comp.gnome.devtools/1390 or
http://stackoverflow.com/questions/10524196/load-gui-from-a-glade-with-gtksourceview-in-pygobject.
 But it seems that the examples written in C can call 
gtk_builder_add_from_file() without any preparation. Why? Is there a invisible 
init operation involved? I think such an init which registers new GObject types 
like GtkSourceView and related types is necessary when builder is used. But 
GtkSourceView library has no init function (gtk3 has one, and of course I call 
it, but I think it can and will not init gtksourceview lib.) I know there is 
another mailing list closer related to gtksourceview available, but there seems 
to be no activity for months. And this is not really a gtksourceview question, 
but more about general builder and unknown gobject types.

This sounds similar to the problems I've recently run into with wxPython (Python wrappers for wxWidgets, which has a GTK implementation).

Basically, GTK assumes that its libraries are loaded into the global symbol namespace. I'm guessing that Nim is probably loading them into a local namespace (RTLD_LOCAL) and thus when GtkBuilder tries to load GtkSourceView, it can't find it. Does Nim let you load the libraries into the global namespace instead? That may be one possible way to work around this, assuming that's what you're seeing.

Scott
_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to