[Glade-users] A GTK window doesn't quit with gtk_main_quit()

Tristan Van Berkom tvb at gnome.org
Sun Jun 5 15:18:36 EDT 2005


SBBG wrote:
> Hello everyone,
>     I'm trying to use a GTK window containing 2 textview to display  
> some information on each time of iteration in a loop like this:
[...]
> while(1)
> {
> .....
> 
>     mainFrame=  create_mainFrame();  // these 3 lines are at the end  of 
> the looop
>     gtk_widget_show( mainFrame );
>     gtk_main();
> }

Hi,
     gtk_main (); is responsable for being the main loop of your
application, it uses a GMainLoop for this; if you pay close attention
to the docs, you'll find that it is possible to run nested main loops;
but it makes your program quite complex and I'm sure that you dont
need that in your application.

The proper/normal way of writing a GTK+ application is (more or less):
     - Init code in main segment (gtk_init () etc..)
     - Obtain all the pointers to UI objects you need using
       glade_xml_get_widget ();
     - Connect to any significant signals on UI objects.
     - Connect to any event sources such as timeouts or IO watches
     - run gtk_main ();
     - return 0;

Cheers,
                           -Tristan


GMainLoop docs:
http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html




More information about the Glade-users mailing list