Re: Forcing update of widgets



>o I am attempting to force GTK to update all widgets in a realtime
>  display application using the following code fragment (which I
>  first read about on this mailing list):
>
>        while (g_main_iteration(FALSE))
>            ;

this is the wrong design for "realtime display applications". if you
want the GUI to update while other activity is happening, you should
be using either idle handlers or threads. idle handlers work if the
"other activity" is short lived. threads are necessary for other
situations. with threads come some extra complications, as well as
better performance.

>o Second problem is that I have a TCP socket connected to the GTK
>  main loop (again GTK--, using Gtk::Main.input.connect()) and doing
>  the above g_main_iteration() loop exposes me to an unwanted
>  re-entrancy.  In the middle of processing a user or TCP input and
>  updating the widgets, I can "signal" back to the same or another
>  handler before finishing the current input.

this will go away when you correct your design.

>o Is there any other/better way to force an update of widgets?  I've
>  tried gdk_flush(), by itself and in addition to g_main_iteration(),
>  without success.

widget->queue_draw() will mark a widget as needing an expose_event to
be synthesized for it. the expose_event will be delivered during the
next iteration of the GTK main loop.

--p



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