Sign up

Why is main() written as it is in the examples?

void main(string[] args)
{
   Main.init(args);
   new MyMainWindow();
   Main.run();
}

I would have expected:

   MainWindow mw = new MyMainWindow();
   Main.run(mw);

I presume that the constructor for MainWindow initializes a static variable somewhere for the static function Main.run() to utilize.

Is there any special reason it's done this way, or is it just a convenience thing?

Re: Why is main() written as it is in the examples?

On 11/13/2013 12:02 PM, Steve Teale wrote:

void main(string[] args)
{
    Main.init(args);
    new MyMainWindow();
    Main.run();
}

I would have expected:

    MainWindow mw = new MyMainWindow();
    Main.run(mw);

I presume that the constructor for MainWindow initializes a static variable somewhere for the static function Main.run() to utilize.

Is there any special reason it's done this way, or is it just a convenience thing?

Main.init does some initialization and phrases some commandline
arguments common to all gtk apps.

Main.run starts the gtk event loop, when constructing an widget it sets
up its default events in addition to the ones set by you. And from there
on everything is handled with the event loop.