Re: gtk-app-devel-list Digest, Vol 12, Issue 35



a bit easier would be to add a 

while(gtk_events_pending())
gtk_main_iteration();

after each update of the progress bar. that should force a visible update of 
the bar:

system("wget file.a");
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pb1), 0.3);
while(gtk_events_pending())
gtk_main_iteration();

gyözö both

You may use the pthread.h C library and use multiples threads to do
what you want... I don't know exactly how to do it, but it is a way
out for your problem!

--
André Pedralho
Bachelor in Computer Science
Instituto Nokia de Tecnologia

On 4/18/05, Aristidas Vilkaitis <A Vilkaitis gamta lt> wrote:
Hello,

  Since i'm quite new to both C and Gtk, i met a problem which i am not
able to solve. The     base  of the problem is that i have a task, which
should fetch several files from the internet. When a button is pressed,
a new window with a progress bar opens and indicates the progress of the
task. Basicly, since i thought C is a linear language, i just added
several system() calls and added gtk_progress_bar_set_fraction between
them like so:

...
  system("wget file.a");
  gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pb1), 0.3);
  system("wget file.b");
  gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pb1), 0.6);  ...

and so on.

The result was that the program first executed the system calls, and
only afterwards did it paint something or tampered with the progress bar.

Why? How to go around this? What to read?

-- 
I suggest you locate your hot tub outside your house, so it won't do
too much damage if it catches fire or explodes.  First you decide which
direction your hot tub should face for maximum solar energy.  After
much trial and error, I have found that the best direction for a hot
tub to face is up.
                -- Dave Barry, "The Taming of the Screw"



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