Web lists-archives.com

Re: gtk-main-iteration -- use and understanding




On Sun, 31 Jan 2016 10:45:18 +0100
Stefan Salewski <mail@xxxxxxxxxxxx> wrote:
> https://developer.gnome.org/gtk3/stable/gtk3-General.html#gtk-main-iteration
> 
> I have some problems to understand and correctly use this function.
> 
> Last week I wrote a toy chess game from scratch in Nim language, just
> to get some more experience with Nim and to have one more test and
> example for my Nim GTK3 bindings. For the plain GUI display with chess
> pieces drawn with unicode fonts I followed well known C examples code.
> 
> My chess engine replies synchronously within less than one second --
> well that may be not really good design, but for now that is OK for
> me.
> 
> When human made a move, I wanted to update display at once, before
> reply is called. I found out fast that calling gtk-main-iteration is
> necessary. But it seems to be necessary to call that at least twice! I
> do not really understand why, or when that is really necessary, how I
> can call it in a loop.

You can call gtk_main_iteration() in a while loop with
gtk_events_pending() as the condition.  Doing so is sometimes necessary
if you are trying to plumb two different main loop implementations
together, but otherwise it is often an indication of a defective
design.  Why aren't you just letting the glib main loop do its thing,
following a call to g_main_run(), gtk_main() or g_application_run()?

Chris
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list