17 feb. 2010 : PHP-GTK Application descriptions can now be submitted in Brazilian Portuguese too. Thanks Bruno Bandeira !.
German and Italian still missing: who will contribute the translated categories for these languages ? Contact the team to offer your translations !
This code
shows how to use a GtkProgressBar in
"fraction" mode, in which the progress bar advances from
one side to the other.
It also demonstrates how Pango integration allows the text to be automatically ellipsized to fit within a given rectangle : try resizing the window to see what happens with the text.
<?php
if (!class_exists('gtk'))
{
die("Please load the php-gtk2 module in your php.ini\r\n");
}
/**
* This function is the signal handler used to
* increase the fraction in the progress bar by one step
*
* @return bool must signal by fired again next time ?
*/
function stepper ()
{
global $progress;
static $pause = 0;
$pos = $progress->get_fraction()
+ $progress->get_pulse_step();
if ($pos < 1)
{
$progress->set_fraction($pos);
return true;
}
else
{
$progress->set_fraction(1.0);
if ($pause++ > 3)
Gtk::main_quit();
}
return true;
}
/**
* ---- Main code ----
*/
/**
* INIT A NEW PROGRESS BAR OBJECT AND SET PROPERTIES
*/
$progress = new gtkProgressBar();
$progress->set_ellipsize(Pango::ELLIPSIZE_MIDDLE);
$progress->set_pulse_step(0.1);
$progress->set_text("This is a test with a long text,"
. "to demonstrate Pango ellipsing");
/**
* according to Gtk+ docs, this should not be used
* http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#id2541129
*
* but g_timeout_add_seconds is not yet in PHP-GTK
* Delay is expressed in milliseconds
*/
Gtk::timeout_add(500, 'stepper');
/******************************************************/
//INIT A NEW WINDOW AND ADD THE PROGRESS WIDGIT
$win = new gtkWindow();
$win->add($progress);
/******************************************************/
/******************************************************/
//SHOW THE WINDOW
$win->show_all();
/******************************************************/
// Main event loop
gtk::main();
?>Additional keywords: progressbar
Recent comments
2 weeks 5 days ago
2 weeks 6 days ago
3 weeks 5 hours ago
4 weeks 1 day ago
5 weeks 3 days ago
5 weeks 6 days ago
13 weeks 1 hour ago
25 weeks 7 hours ago
30 weeks 6 days ago
32 weeks 4 days ago