GtkTreeIter insert_before([GtkTreeIter sibling [, GtkTreeIter parent [, array items]]]);

Inserts a new row before sibling. If sibling is null, then the row will be appended to parent's children. If parent and sibling are null, then the row will be appended to the toplevel. If both sibling and parent are set, then parent must be the parent of sibling. When sibling is set, parent is optional.

items can be an array of values for the column.

Example 134. Filling a GtkTreeStore with insert_before

//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_after();
$store->set($root, 0, 'root');

//insert root2 before $root
$root2 = $store->insert_before($root);
$store->set($root2, 0, 'root2');

//insert this child as child of root row
$child1 = $store->insert_before(null, $root, array('child1'));

//insert this child before $child1
$child2 = $store->insert_before($child1, $root, array('child2'));

//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() , insert_after() , append() , prepend()