For your last question:
grep WindowObj src/gtk3.nim
Window* = ptr WindowObj
WindowPtr* = ptr WindowObj
WindowObj* = object of BinObj
In Nim as in many other OOP languages we can use hyrachical object structures,
by using the "object of" notation. In C GTK related structs have generally a
parent field as first component. We can do it in the same way in Nim, but we
can also drop that field by using the object of notation. This way we can avoid
many casts. So for example Window is a "subclass" of Bin object, which already
is a subclass of Widget. This means that procs which expects a widget parameter
will accept a Bin or a Window as well without cast. This is convenient, but it
may be not as typesafe as pure Nim code of course. If you need a type
conversion in rare cases, you can use Nim's type conversion like
Window(widget), or better use the lower case GTK casting templates like
template window*(obj: expr): expr =
(gTypeCheckInstanceCast(obj, typeWindow, WindowObj))
They do runtime type checking.
For your first question:
GTK3 programs can be written in the traditional GTK2 way, or with App design.
For traditional code, we have to init gtk lib before using it. In my examples
that is done this way:
$ cat test.nim
"..."
gtk3.initWithArgv()
# your code
gtk3.main()
For the app design, we do not need an explicit init -- that is the reason why
gtk3.initWithArgv() is not called automatically. For the app design NEd editor
is an example, and I also provided a Nim version of the so called application10
of GTK docs:
[https://github.com/ngtk3/nim-app](https://github.com/ngtk3/nim-app)
The App style is more advanced, but for that style generally only C and Nim
examples exists, I am not aware of fully functional Python or Ruby or
Java-Script examples.
As I already told you -- it may be really hard for you to learn GTK3 and Nim at
the same time. There may exist other GUI toolkits which are much better suited
for your tasks, maybe in conjunction with another programming language.
PS: Recently I updated my box from GTK 3.18 to 3.20 and just discovered that
some color settings do not works any more. The CSS notation has changed. So for
NEd editor with dark color scheme tooltip background is dark also, which is
really not nice. It is not very easy to fix, I already contacted two of the few
remaining GTK developers, but we still have no really nice solution. I will try
to fix that as soon as possible. That CSS problem also concerns the colors.nim
example, currently setting of background color does not work. That should be
very easy to fix, but has low priority.