Re: Progress bars and syscals



You need to call

while( g_main_iteration (FALSE));

to update the progress bar. The gtk_progress_bar_set_fraction queues draw requests that are then executed inside gtk main event loop. Be careful that calling g_main_iteration also processes user messages, so if the user clicks on something, the corresponding code will be executed inside the while. This may cause unwanted effects.

Fireel 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?

Thank you,
Fireel


_______________________________________________
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]