GtkTreeView::insert_column_with_data_func
int insert_column_with_data_func(int position, string title, GtkCellRenderer cellrenderer, callback callback);
This method inserts a new column into a GtkTreeView at the given position with a given name. In contrast to insert_column() and append_column() this method creates the column object internally and allows you to specify a data function, which is called everytime a cell in the model for this column changed and needs to be rendered.
The provided callback function receives the following parameters to act on them:
- GtkTreeViewColumn The column object created by the insert_column_with_data_func() call.
- GtkCellRenderer The cell renderer used to display this cell.
- GtkTreeModel The model rendered by the tree view.
- GtkTreeIter The tree row affected by the change.
Example 139. Using insert_column_with_data_func()
<?php
//Using GtkTreeView::insert_column_with_data_func()
/*
* Creating a column with a data function callback
*/
$nameRenderer = new GtkCellRendererText();
$view->insert_column_with_data_func(
0,
"Test suites",
$nameRenderer,
"showTestName"
);
/*
* This data function column makes the cell renderer display the text from model
* column 0 in uppercase letters.
*/
function showTestName($column, $cell, $model, $iter)
{
$cell->set_property(
"text",
strtoupper( $model->get_value($iter, 0))
);
}
?>
|