RE: gtk progress bar and gdk_flush() --the solution!



Thanks jrainha's idea.
I have to grab the progress bar before enter this loop. After finish the
loop, I have to remove the grab.
Post the whole code if someone has the same problem as me.

int done;
GtkWidget pg;
char msg[100];

gdk_window_set_modal_hint (pg->window, TRUE);
gtk_grab_add (GTK_WIDGET (pg));
for (done=0;done<100;done+=20){
   sprintf (msg,"%d was done" , done);
   gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pg),msg);
 
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pg),(double)(done)/100);
   while (gtk_events_pending()) gtk_main_iteration ();
   sleep(1); // do something take a long time.
}
gtk_grab_remove ( pg);
gdk_window_set_modal_hint (pg->window, FALSE);



I think the Gtk progress bar should do this for us. Because most
progress bar should put in a long loop.

Thanks.



-----Original Message-----
From: gtk-app-devel-list-admin gnome org
[mailto:gtk-app-devel-list-admin gnome org] On Behalf Of Tristan Van
Berkom
Sent: Friday, October 24, 2003 1:19 PM
To: Tom Liu
Cc: jrainha olivia inesc-id pt; gtk-app-devel-list gnome org
Subject: Re: gtk progress bar and gdk_flush()

Tom Liu wrote:

Use the fooling code to refresh progressbar will work, But the new
problem is that user may click other button during this loop.

  while (gtk_events_pending ()) gtk_main_iteration ();
 

<snip>

You could:
    A.) make the widgets that you dont want to be clicked "insensitive"
    B.) make your progressbar "modal" for your application. modal iirc
is a
        property of an X window, anyway; it means that that is the only
        window that will recieve mouse events, usualy used for
"OK|CANCEL"
        popups.

Cheers,
                            -Tristan


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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