float accumulator;
float fraction;
gboolean changeProgress(gpointer data) {
*bar=accumulator;
accumulator+=fraction;
if (accumulator>1.0) {
accumulator=1.0;
fraction=-fraction;
}
if (accumulator<.0) {
accumulator=.0;
fraction=-fraction;
}
return 1;
}
gboolean pulseProgress(gpointer data) {
*bar=-accumulator;
}
static void quit(
void *widget, gpointer data) {
gtk_main_quit();
}
int main(
int argc,
char *argv[]) {
accumulator =0.0;
fraction=0.1;
gtk_init( &argc, &argv );
bar=0.5;
pulsingBar=-0.5;
labels<<"progress bar"<<"pulse bar";
topWindow<<vbox;
g_timeout_add_seconds(1, changeProgress, (gpointer)&bar);
g_timeout_add_seconds(1, pulseProgress, (gpointer)&pulsingBar);
gtk_main();
}