Web lists-archives.com

Re: How do we get GTYPE from gobject introspection language bindings

As a side note, STRING probably refers to https://developer.gnome.org/glib/stable/glib-Strings.html which is a more OO string implementation. G_TYPE_STRING being gchararray is of more close relation with C strings (except it consists of gchars instead of chars.)

On Thu, Sep 28, 2017, 22:34 Stefan Salewski <mail@xxxxxxxxxxxx> wrote:
I am just preparing a listview example for the Nim GTK3 mini tutorial.
I followed the Z-Code C example. Was not too difficult. But I got one
problem: For working with listviews, we have to provide GTypes, which
are numerical values. For C we have the macros like G_TYPE_STRING which
for my box gives currently value 64. These values seems to be not
directly supported by gobject-introspection. Seems to be no big
problem, we may query the values by g-type-from-name().


For G_TYPE_STRING I assumed that name is "GSTRING" which gives indeed a
non zero result from g-type-from-name(). But it is wrong.

We can get the correct name by using g_type_name(G_TYPE_STRING). This
gives "gchararray".

And indeed, when I provide this name to g-type-from-name() then the Nim
example works fine.

But where should high level users find the corresponding G_TYPE names
or values?

Or is there another way to get G_TYPE values? I assume a static list of
integers would not make much sense?

Maybe you know how this is done in other languages with GTK bindings.
gtk-list mailing list
gtk-list mailing list