GtkTreeIter insert(int position [, GtkTreeIter parent [, array items]]);

Inserts a new row as child of parent at position.

If parent is null, the new row will be created at top-level. If position is larger than the number of rows at that level, then the new row will be inserted to the end of the list.

items can be an array of values for the column.

Example 132. Filling a GtkTreeStore with insert

//new model with just one column of type string
$store = new GtkTreeStore(Gtk::TYPE_STRING);

//insert a new row without a parent (root row)
$root = $store->insert(0);
$store->set($root, 0, 'root');

//insert a new row as child of the previously created root row
$child1 = $store->insert(0, $root);
$store->set($child1, 0, 'child');

//insert another row, but at position 0 - that means
//before $child1
$child2 = $store->insert(0, $root, array('child2'));

//insert at position 1: before $child1,
//but after $child2
$child3 = $store->insert(1, $root, array('child3'));

//Display the store
$wnd  = new GtkWindow();
$view = new GtkTreeView($store);
    new GtkTreeViewColumn('String column', new GtkCellRendererText(), 'text', 0)
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));

See also: insert_after() , insert_before() , append() , prepend()