GtkTreeStore::append
Creates a new line and appends it to the end of the store. The first parameter parent can be null. If that's the case, the new entry will have no parent and thus be a "root" entry.
The second parameter items is an array with a value for each column. If your treestore has three columns, the array should have three values.
The method returns a GtkTreeIter which you can use to refer to the entry row; e.g. to use it as a parent for another row.
If you pass no parameters at all, an empty row with no values will be created, and you have to use other methods like set() to change the column values.
Example 131. Creating and filling a GtkTreeStore
<?php //new model with just one column of type string $store = new GtkTreeStore(Gtk::TYPE_STRING); //create root entry: parent parameter is NULL $root = $store->append(null, array('This is the root')); //Create a child entry below the root one $child = $store->append($root, array('Child of root')); //Create a second child of root $store->append($root, array('Second child')); //create another root entry $root2 = $store->append(null, array('Another root')); //create empty root entry $empty = $store->append(); //create empty entry below child $subchild = $store->append($child); //Display the store $wnd = new GtkWindow(); $view = new GtkTreeView($store); $view->append_column( new GtkTreeViewColumn('String column', new GtkCellRendererText(), 'text', 0) ); $wnd->add($view); $wnd->connect_simple('destroy', array('gtk', 'main_quit')); $wnd->show_all(); Gtk::main(); ?> |
See also: insert() , insert_after() , insert_before() , prepend()