Re: gtk events question



In message <ybelnkrin8s.fsf@fresnel.labs.redhat.com>, Owen Taylor writes:
>
>Marc van Kempen <marc@bowtie.nl> writes:
>
>> Hi,
>> 
>> I'm trying to execute an external program and have a 
>> popup which signals the user to wait for the program to
>> end. In my callback which executes the program I have 
>> something like:
>> 
>> jb_msg_create("wait blabla");		/* this creates the popup window */
>> 
>> /* now try to wait until the window has been created and displayed */
>
>Waiting for a window to show like this is never a good idea,
>since GTK+ usually will go idle before the X server shows
>the window and responds. Instead use:
>
>void       gtk_widget_show_now            (GtkWidget           *widget);
>
>instead of gtk_widget_show() to show your window.

[snip]
>> 
>> But this is blocking in gtk_main_iteration() and will only continue
>> after I move the mouse.
>> 
>> So what is the recommended way of handling such a scenario?
>
>gtk_events_pending() should be considered to return a boolean.
>
>Try:
>
> while (gtk_events_pending())
>   gtk_main_iteration()
>
Hi Owen,

Thanks for you suggestions.

I tried this, but it still didn't work.  After using gdk_flush() before 
the gtk_main_iteration() loop it started to work reliably.

What seems to be the problem is the fact that I have used glade for a large
part of the user interface and the method that I use to save the window
pointers of the windows that get created is to save them in the realize 
event callback for the window. That way I don't have to mess with the code
that gets created by glade, but can keep my own code and the generated
code separated.

When I copied the code into my own sourcefiles and took that callback out it 
started to work too, without the gdk_flush().

It looks a bit like black art to me, but I'll investigate further tomorrow.

Bye,
Marc.



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