How do we get GTYPE from gobject introspection language bindings

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How do we get GTYPE from gobject introspection language bindings

Stefan Salewski-2
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().

https://developer.gnome.org/gobject/stable/gobject-Type-Information.html#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
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

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

Gergely Polonkai

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 <[hidden email]> 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().

https://developer.gnome.org/gobject/stable/gobject-Type-Information.html#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
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

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

Stefan Salewski-2
On Fri, 2017-09-29 at 04:45 +0000, Gergely Polonkai wrote:
> 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.)

Yes, that can be the reason for my observation that I got a non zero
result for g-type-from-name("GSTRING").

I think guessing the other names is easier, it should be gint, gfloat
or widget names like GtkEntry.

I have added the listview example to the mini tutorial, see bottom of

https://github.com/StefanSalewski/gintro


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list