Question about event loops



Hello all...

I'm currently evaluating GTK+ for use in a project that I'm involved with.
Unfortunately, I can't divulge the details, so forgive me if this post
is too vague...

I have a question about event processing. In my potential use of GTK,
calling gtk_main() is not acceptable. I need to be able to process
events that are unrelated to GTK in the same thread, so what would be
ideal for me is a loop that I can use which will accomplish the same
thing yet provide me with time to do my alternative event processing.

The basic idea of the loop would be
while (events pending) {
	process some gtk events
	do some of my own event processing
	sleep maybe?
}

In Havoc Pennington's book, I see
while (gtk_events_pending())
    gtk_main_iteration();

which would seem to suit my needs, but I thought I'd ask to make sure.
Does the code quoted above assume that I'm already in at least one
level of gtk_main() calls? Or is it intended to be used on its own? 
(The context of the example in the book where the above code came from
involved processing events while in a lengthy callback, and gtk_main()
was already running, which is why I wasn't sure).

Before you ask the obvious "why are you doing this? Just call gtk_main()",
I'll say that this is not a simple GTK application, and having done the
same thing on other platforms, we have a pretty good idea of the type of
solution we need for this particular project. The documentation for the
event functions is just sketchy at best and I need more information on
what the above calls are intended to do, specifically.

If you need more details, I will try to provide them as best as I can.

Thank you in advance,

james



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