Using GtkSourceview in glade template

I am using some Gtk bindings for the Nim programming language. Trying to use a glade file that has a GtkSourceview in it. I get the following error when I do:

Error: unhandled exception: builder.ui:46:1 Invalid object type 'GtkSourceView' [GException].

I have confirmed that I can use the widget from nim code without issue.

What I am trying to do is validate if this is an issue with those bindings or if there is some initial setup required to use a Widget that ships separately from gtk in a glade template.

I made an issue on the binding libraries github about this issue as well gintro issue

Without much knowledge of how Nim works, I would focus on making sure the GtkSourceView GType is known to the type system before loading your glade file. In C, this usually isn’t needed because you link against the library and the GtkBuilder knows how to translate type names (GtkSourceView) to the C symbol gtk_source_view_get_type(). But if Nim doesn’t have such linking rules, it wont know about the type.

Generally, in a C program, that means doing something like this in your class_init function.

  g_type_ensure (GTK_SOURCE_TYPE_VIEW);

You are absolutely right, register is needed. I found that hint already with google on stackoverflow and hacked together a ugly but working example for him. (He wants to use builder with GtkSourceView widget)

https://githuuub.com/StefanSalewski/gintro/issues/40#issuecomment-477744353

Yes, it is very ugly, sorry.

PS: When clicking on reply I get this strange message:

Sorry you cannot post a link to that host.

Is there something wrong with the github issue link, or temporary malfunction of this forum?

And for reference:

https://mail.gnome.org/archives/gtk-list/2015-March/msg00016.html

So the issue is due to how Nim loads it libraries.

I’m glad you linked to this email it was very enlightening. I think I understand what is going on a lot better now.

The link is to “githuuub.com”, which does not exist. Did you mean to use “github.com” instead?

Emmanuele, yes I added the two additional u after sending my post was two times rejected. With the two additional u I could finally send it. So my first idea was that github is a hated company and blacklisted by the discourse forum software. Sounds strange, but indeed I heard that there exists forums which do not allow to post links. The strange thing is, that the initial post contains a working link to github issue already.

I will not test it again yet, lets just hope that it was a temporary failure.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.