A tree-like data structure that can be used with the GtkTreeView
Class GtkTreeStore( types )
types | an array of all GType types for the columns, from first to last |
The GtkTreeStore object is a list model for use with a GtkTreeView widget. It implements the GtkTreeModel interface, and consequentialy, can use all of the methods available there. It also implements the GtkTreeSortable interface so it can be sorted by the view. Finally, it also implements the tree drag and drop interfaces.
Methods | |
append | Appends a new row to tree_store. |
clear | Removes all rows from tree_store |
insert | Creates a new row at position. |
insert_after | Inserts a new row after sibling. |
insert_before | Inserts a new row before sibling. |
insert_with_values | Creates a new row at position. |
is_ancestor | Returns TRUE if iter is an ancestor of descendant. |
iter_depth | Returns the depth of iter. |
iter_is_valid | Checks if the given iter is a valid iter for this GtkTreeStore. |
move_after | Moves iter in tree_store to the position after position. |
move_before | Moves iter in tree_store to the position before position. |
prepend | Prepends a new row to tree_store. |
remove | Removes iter from tree_store. |
reorder | Reorders the children of parent in tree_store to follow the order indicated by new_order. |
set | Sets the value of one or more cells in the row referenced by iter. |
set_column_types | Sets the column types. |
set_value | Sets the data in the cell specified by iter and column. |
swap | Swaps a and b in the same level of tree_store. |
Appends a new row to tree_store.
GtkTreeStore.append( iter, parent )
iter | An unset GtkTreeIter to set to the appended row |
parent | A valid GtkTreeIter, or NULL. |
If parent is non-NULL, then it will append the new row after the last child of parent, otherwise it will append a row to the top level. iter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call gtk_tree_store_set() or gtk_tree_store_set_value().
Removes all rows from tree_store
GtkTreeStore.clear()
Creates a new row at position.
GtkTreeStore.insert( iter, parent, position )
iter | An unset GtkTreeIter to set to the new row |
parent | A valid GtkTreeIter, or NULL. |
position | position to insert the new row |
If parent is non-NULL, then the row will be made a child of parent. Otherwise, the row will be created at the toplevel. 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. iter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call gtk_tree_store_set() or gtk_tree_store_set_value().
Inserts a new row after sibling.
GtkTreeStore.insert_after( iter, parent, sibling )
iter | An unset GtkTreeIter to set to the new row |
parent | A valid GtkTreeIter, or NULL. |
sibling | A valid GtkTreeIter, or NULL. |
If sibling is NULL, then the row will be prepended to parent 's children. If parent and sibling are NULL, then the row will be prepended 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.
iter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call gtk_tree_store_set() or gtk_tree_store_set_value().
Inserts a new row before sibling.
GtkTreeStore.insert_before( iter, parent, sibling )
iter | An unset GtkTreeIter to set to the new row |
parent | A valid GtkTreeIter, or NULL. |
sibling | A valid GtkTreeIter, or NULL. |
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.
iter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call gtk_tree_store_set() or gtk_tree_store_set_value().
Creates a new row at position.
GtkTreeStore.insert_with_values( iter, parent, pos, values )
iter | An unset GtkTreeIter to set to the new row, or NULL. |
parent | A valid GtkTreeIter, or NULL. |
pos | position to insert the new row |
values | an array of pairs [ column index, column value, ... ] |
iter will be changed to point to this new row. If position is larger than the number of rows on the list, then the new row will be appended to the list. The row will be filled with the values given to this function.
Returns TRUE if iter is an ancestor of descendant.
GtkTreeStore.is_ancestor( iter, descendant )
iter | A valid GtkTreeIter |
descendant | A valid GtkTreeIter |
Return | TRUE, if iter is an ancestor of descendant |
That is, iter is the parent (or grandparent or great-grandparent) of descendant.
Returns the depth of iter.
GtkTreeStore.iter_depth( iter )
iter | A valid GtkTreeIter |
Return | The depth of iter |
This will be 0 for anything on the root level, 1 for anything down a level, etc.
Checks if the given iter is a valid iter for this GtkTreeStore.
GtkTreeStore.iter_is_valid( iter )
iter | A GtkTreeIter. |
Return | TRUE if the iter is valid, FALSE if the iter is invalid. |
Warning: This function is slow. Only use it for debugging and/or testing purposes.
Moves iter in tree_store to the position after position.
GtkTreeStore.move_after( iter, position )
iter | A GtkTreeIter. |
position | A GtkTreeIter or NULL. |
iter and position should be in the same level. Note that this function only works with unsorted stores. If position is NULL, iter will be moved to the start of the level.
Moves iter in tree_store to the position before position.
GtkTreeStore.move_before( iter, position )
iter | A GtkTreeIter. |
position | A GtkTreeIter or NULL. |
iter and position should be in the same level. Note that this function only works with unsorted stores. If position is NULL, iter will be moved to the end of the level.
Prepends a new row to tree_store.
GtkTreeStore.prepend( iter, parent )
iter | An unset GtkTreeIter to set to the prepended row. |
parent | A valid GtkTreeIter, or NULL. |
If parent is non-NULL, then it will prepend the new row before the first child of parent, otherwise it will prepend a row to the top level. iter will be changed to point to this new row. The row will be empty after this function is called. To fill in values, you need to call gtk_tree_store_set() or gtk_tree_store_set_value().
Removes iter from tree_store.
GtkTreeStore.remove( iter )
iter | A valid GtkTreeIter |
Return | TRUE if iter is still valid, FALSE if not. |
After being removed, iter is set to the next valid row at that level, or invalidated if it previously pointed to the last one.
Reorders the children of parent in tree_store to follow the order indicated by new_order.
GtkTreeStore.reorder( parent, new_order )
parent | A GtkTreeIter. |
new_order | an array of integers mapping the new position of each child to its old position before the re-ordering, i.e. new_order[newpos] = oldpos. |
Note that this function only works with unsorted stores.
Sets the value of one or more cells in the row referenced by iter.
GtkTreeStore.set( iter, values )
iter | row iterator (GtkTreeIter) |
values | an array of pairs [ column index, column value, ... ] |
The variable argument list should contain integer column numbers, each column number followed by the value to be set. For example, to set column 0 with type G_TYPE_STRING to "Foo", you would write gtk_tree_store_set ( iter, [ 0, "Foo" ] ).
Sets the column types.
GtkTreeStore.set_column_types( types )
types | an array of GType |
This function is meant primarily for GObjects that inherit from GtkTreeStore, and should only be used when constructing a new GtkTreeStore.
It will not function after a row has been added, or a method on the GtkTreeModel interface is called.
Sets the data in the cell specified by iter and column.
GtkTreeStore.set_value( iter, column, value )
iter | A valid GtkTreeIter for the row being modified |
column | column number to modify |
value | new value for the cell |
The type of value must be convertible to the type of the column.
Swaps a and b in the same level of tree_store.
GtkTreeStore.swap( a, b )
a | A GtkTreeIter. |
b | Another GtkTreeIter. |
Note that this function only works with unsorted stores.