Re: Application redrawing



I have removed my pthread and decided to just call:


        /* computation going on */
        while (gtk_events_pending ())
          gtk_main_iteration ();
        /* computation continued */

at the appropriate times. However, when I use gtk_progress_bar_pulse() the Progress Bar does redraw to a new pulse location. However, if I use gtk_progress_bar_set_fraction() with a new fraction for each call, it does not redraw. However, once the application is finished processing (the method returns) then the Progress Bar redraw to 100%.

So basically, my question is, why do _pulse() and _set_fraction() behaving differently?

Thanks,

-------
Alvin Beach
Email: alvinbeach hotmail com
Website: http://www.vianet.ca/~abeach




From: Roland Smith <rsmith xs4all nl>
Reply-To: rsmith xs4all nl
To: gtk-app-devel-list gnome org
Subject: Re: Application redrawing
Date: Tue, 8 Apr 2003 19:44:31 +0200

On Sun, 06 Apr 2003 16:53:41 -0400
"A B" <alvinbeach hotmail com> wrote:

> Hello,
>
> I am experimenting with GTK+. I am creating an app that does a lot of
> processing. What I am having problems with is having the application redraw > itself. I thought that if I put all the processing in a pthread that would
> help. But, this isn't the case.
>
> What do GTK+ programmers do to work around this?

There are a couple of alternatives. Using threads is one of them (but not the best IMHO). GTK+ depends on a regular flow of events. That means you should:

1 - split you calculation in little pieces that can be invoked via timeouts or
    idle functions.
2 - allow GTK+ to process events from within your calculation
3 - use a separate calculation program, that communicates with the GUI via pipes
4 - use threads. But do not issue gTK+ calls from the thread that does the
    processing.

For 1 see gtk_timeout_add() and gtk_idle_add().

for 2 use something like:

        /* computation going on */
        while (gtk_events_pending ())
          gtk_main_iteration ();
        /* computation continued */

For 3 see g_spawn_async_with_pipes()

Roland
--
R.F. Smith                           /"\    ASCII Ribbon Campaign
r s m i t h @ x s 4 a l l . n l      \ /    No HTML/RTF in email
http://www.xs4all.nl/~rsmith/         X     No Word docs in email
                                     / \    Respect for open standards
<< attach3 >>


_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail




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