GtkTreeModel::foreach
Calls the given callback function for each single row in the store.
The callback function can have the following parameters: (GtkTreeModel model, GtkTreePath path, GtkTreeIter iter).
例 120. Looping through all rows with foreach
<?php
$store = new GtkListStore(Gtk::TYPE_STRING, Gtk::TYPE_LONG);
$store->append(array('Tokio', 34100000));
$store->append(array('Mexico city', 22650000));
$store->append(array('New York', 21850000));
$store->append(array('São Paulo', 20200000));
/*
* And now show what we've got in the store
*/
function echoRow($store, $path, $iter)
{
$city = $store->get_value($iter, 0);
$number = $store->get_value($iter, 1);
echo $city . ' has ' . $number . " inhabitants.\r\n";
}
$store->foreach('echoRow');
?> |