Re: gtk events question
- From: Owen Taylor <otaylor redhat com>
- To: Marc van Kempen <marc bowtie nl>
- Cc: gtk-list redhat com
- Subject: Re: gtk events question
- Date: 01 Dec 1998 16:08:35 -0500
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.
> n = gtk_events_pending();
> for (i=0; i<n; i++) {
> gtk_main_iteration();
> }
>
> exec_program();
>
> jb_show_results();
>
> return;
>
>
> But this doesn't give me the desired result as it does not handle
> all pending events, so I must be doing something wrong.
>
> I then tried:
>
> n = gtk_events_pending();
> while (n > 0) {
> for (i=0; i<n;i++) {
> gtk_main_iteration();
> }
> n = gtk_events_pending();
> }
>
>
> 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()
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]