[10575] in The GTK GIMP ToolKit mailing list archive
[gtk-list] Re: gtk events question
daemon@ATHENA.MIT.EDU (Owen Taylor)
Tue Dec 1 16:07:57 1998
To: Marc van Kempen <marc@bowtie.nl>
Cc: gtk-list@redhat.com
From: Owen Taylor <otaylor@redhat.com>
Date: 01 Dec 1998 16:08:35 -0500
In-Reply-To: Marc van Kempen's message of "Tue, 01 Dec 1998 20:14:51 +0100"
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com
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
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null