Re: [Vala] Genie, subclassing and some help!



Hey!

2) Perhaps related, in the main.gs file, I have:

init
   Gtk.init(ref args)
   create_indicator()
   Gtk.main()

However, if I don;t put the Gtk.main() in the function above (rather
than the init), it doesn't work. Why is this/is this on purpose?


Maybe you understand this already, just in case though:
Gtk needs to be "initialized" before you can use it (display any widgets or
even create them).
The function that does this is *Gtk.init()

*Then you create some widgets, ie *Gtk.Button.with_label("Hello"); *, add
this to a window etc...

And then to hand control over to Gtk, we call *Gtk.main()*. This function
lets Gtk actually *DRAW* the
window on the screen, and its is only now that the window is actually SHOWN
to the user. (Despite that
it was created long beforehand).

Hence that these 3 steps are nessisary in your main() function.

The reason that its a very good idea to put *Gtk.init()  *and  *Gtk.main()
*in your *main()*, is this:
If you want to show 2 toplevel windows, and you've got *Gtk.main()* in your
class' init function, Gtk
is going to create your class, and then show the window. (ie: pass control
of the thread to Gtk.)
This is going to halt the program exectution until this window is destroyed,
and then your program
gets control of the thread back, and the next class' init will be called,
and that window shown.

Don't think I explained that 100%, but hope you understand me anyway.
Cheers, -Harry


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]