« Return to Thread: Remove the nodes of a tree

Re: Remove the nodes of a tree

by kksou :: Rate this Message:

Reply to Author | View in Thread

Fernando Correa da Conceição-3 wrote:
Thanks, but this is not exacty what I need...
My case is that I do not want remove the
parent node, only the childs.

Fernando Correa da Conceição.
Try this then...

$parent_node = $model[$iter];
$nodes_to_remove = array();

foreach ($parent_node->children() as $child_node) {
    $iter = $child_node->iter;
    $nodes_to_remove[] = $model->get_string_from_iter($iter);
}

for ($i=count($nodes_to_remove)-1; $i>=0; --$i) {
    unset($model[$nodes_to_remove[$i]]);
}

Complete sample code here:
http://www.kksou.com/php-gtk2/articles/remove-nodes-from-GtkTreeView---Part-3---remove-child-nodes-only.php

Regards,
/kksou

 « Return to Thread: Remove the nodes of a tree