<?php
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));
function update_bar() {
global $progressbar, $value;
$progressbar->set_percentage($value);
start_update();
}
function start_update() {
global $value;
if($value <= 1.0) {
$value += 0.01;
gtk::timeout_add(200, 'update_bar');
}
else gtk::timeout_add(50, array('gtk', 'main_quit'));
}
$window = &new GtkWindow();
$window->set_uposition(200, 250);
$window->set_policy(false, false, true);
$window->connect_object('destroy', array('gtk', 'main_quit'));
/* These adjustment settings are on the wild side for demo purposes */
$adjustment = &new GtkAdjustment(0.5, 100.0, 200.0, 0.0, 0.0, 0.0);
$value = $adjustment->value;
$progressbar = &new GtkProgressBar($adjustment);
$progressbar->set_show_text(true);
$progressbar->set_text_alignment(0.02, 1.0);
$progressbar->set_format_string("%v%% complete");
$progressbar->set_usize(gdk::screen_width()/2, 30);
$window->add($progressbar);
$window->show_all();
start_update();
gtk::main();
?>
|