Next: , Previous: GtkListStore, Up: Top


53 GtkTreeStore

A tree-like data structure that can be used with the

53.1 Overview

The <gtk-tree-store> object is a list model for use with a <gtk-tree-view> widget. It implements the <gtk-tree-model> interface, and consequentialy, can use all of the methods available there. It also implements the <gtk-tree-sortable> interface so it can be sorted by the view. Finally, it also implements the tree drag and drop interfaces.

53.2 Usage

— Class: <gtk-tree-store>

Derives from <gtk-tree-model>, <gtk-tree-sortable>, <gtk-buildable>, <gtk-tree-drag-dest>, <gtk-tree-drag-source>, <gobject>.

This class defines no direct slots.

— Function: gtk-tree-store-new (types scm) ⇒  (ret <gtk-tree-store>)

Creates a new tree store as with n-columns columns each of the types passed in. Note that only types derived from standard GObject fundamental types are supported.

As an example, ‘gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF);’ will create a new <gtk-tree-store> with three columns, of type <int>, <string> and <gdk-pixbuf> respectively.

n-columns
number of columns in the tree store
...
all <g-type> types for the columns, from first to last
ret
a new <gtk-tree-store>
— Function: gtk-tree-store-set-value (self <gtk-tree-store>) (iter <gtk-tree-iter>) (column int) (value scm)
— Method: set-value

Sets the data in the cell specified by iter and column. The type of value must be convertible to the type of the column.

tree-store
a <gtk-tree-store>
iter
A valid <gtk-tree-iter> for the row being modified
column
column number to modify
value
new value for the cell
— Function: gtk-tree-store-remove (self <gtk-tree-store>) (iter <gtk-tree-iter>) ⇒  (ret <gtk-tree-iter>)
— Method: remove

Removes iter from tree-store. After being removed, iter is set to the next valid row at that level, or invalidated if it previously pointed to the last one.

tree-store
A <gtk-tree-store>
iter
A valid <gtk-tree-iter>
ret
#t’ if iter is still valid, ‘#f’ if not.
— Function: gtk-tree-store-insert (self <gtk-tree-store>) (parent <gtk-tree-iter>) (position int) ⇒  (ret <gtk-tree-iter>)
— Method: insert

Creates a new row at position. If parent is non-‘#f’, 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.

tree-store
A <gtk-tree-store>
iter
An unset <gtk-tree-iter> to set to the new row
parent
A valid <gtk-tree-iter>, or ‘#f
position
position to insert the new row
— Function: gtk-tree-store-insert-before (self <gtk-tree-store>) (parent <gtk-tree-iter>) (sibling <gtk-tree-iter>) ⇒  (ret <gtk-tree-iter>)
— Method: insert-before

Inserts a new row before sibling. If sibling is ‘#f’, then the row will be appended to parent 's children. If parent and sibling are ‘#f’, 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.

tree-store
A <gtk-tree-store>
iter
An unset <gtk-tree-iter> to set to the new row
parent
A valid <gtk-tree-iter>, or ‘#f
sibling
A valid <gtk-tree-iter>, or ‘#f
— Function: gtk-tree-store-insert-after (self <gtk-tree-store>) (parent <gtk-tree-iter>) (sibling <gtk-tree-iter>) ⇒  (ret <gtk-tree-iter>)
— Method: insert-after

Inserts a new row after sibling. If sibling is ‘#f’, then the row will be prepended to parent 's children. If parent and sibling are ‘#f’, 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.

tree-store
A <gtk-tree-store>
iter
An unset <gtk-tree-iter> to set to the new row
parent
A valid <gtk-tree-iter>, or ‘#f
sibling
A valid <gtk-tree-iter>, or ‘#f
— Function: gtk-tree-store-prepend (self <gtk-tree-store>) (parent <gtk-tree-iter>) ⇒  (ret <gtk-tree-iter>)
— Method: prepend

Prepends a new row to tree-store. If parent is non-‘#f’, 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.

tree-store
A <gtk-tree-store>
iter
An unset <gtk-tree-iter> to set to the prepended row
parent
A valid <gtk-tree-iter>, or ‘#f
— Function: gtk-tree-store-append (self <gtk-tree-store>) (parent <gtk-tree-iter>) ⇒  (ret <gtk-tree-iter>)
— Method: append

Appends a new row to tree-store. If parent is non-‘#f’, 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.

tree-store
A <gtk-tree-store>
iter
An unset <gtk-tree-iter> to set to the appended row
parent
A valid <gtk-tree-iter>, or ‘#f
— Function: gtk-tree-store-is-ancestor (self <gtk-tree-store>) (iter <gtk-tree-iter>) (descendant <gtk-tree-iter>) ⇒  (ret bool)
— Method: is-ancestor

Returns ‘#t’ if iter is an ancestor of descendant. That is, iter is the parent (or grandparent or great-grandparent) of descendant.

tree-store
A <gtk-tree-store>
iter
A valid <gtk-tree-iter>
descendant
A valid <gtk-tree-iter>
ret
#t’, if iter is an ancestor of descendant
— Function: gtk-tree-store-iter-depth (self <gtk-tree-store>) (iter <gtk-tree-iter>) ⇒  (ret int)
— Method: iter-depth

Returns the depth of iter. This will be 0 for anything on the root level, 1 for anything down a level, etc.

tree-store
A <gtk-tree-store>
iter
A valid <gtk-tree-iter>
ret
The depth of iter
— Function: gtk-tree-store-clear (self <gtk-tree-store>)
— Method: clear

Removes all rows from tree-store

tree-store
a <gtk-tree-store>
— Function: gtk-tree-store-iter-is-valid (self <gtk-tree-store>) (iter <gtk-tree-iter>) ⇒  (ret bool)
— Method: iter-is-valid

WARNING: This function is slow. Only use it for debugging and/or testing purposes.

Checks if the given iter is a valid iter for this <gtk-tree-store>.

tree-store
A <gtk-tree-store>.
iter
A <gtk-tree-iter>.
ret
#t’ if the iter is valid, ‘#f’ if the iter is invalid.

Since 2.2

— Function: gtk-tree-store-reorder (self <gtk-tree-store>) (parent <gtk-tree-iter>) ⇒  (new_order int)
— Method: reorder

Reorders the children of parent in tree-store to follow the order indicated by new-order. Note that this function only works with unsorted stores.

tree-store
A <gtk-tree-store>.
parent
A <gtk-tree-iter>.
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’.

Since 2.2

— Function: gtk-tree-store-swap (self <gtk-tree-store>) (<gtk-tree-iter>) (<gtk-tree-iter>)
— Method: swap

Swaps a and b in the same level of tree-store. Note that this function only works with unsorted stores.

tree-store
A <gtk-tree-store>.
a
A <gtk-tree-iter>.
b
Another <gtk-tree-iter>.

Since 2.2

— Function: gtk-tree-store-move-before (self <gtk-tree-store>) (iter <gtk-tree-iter>) (position <gtk-tree-iter>)
— Method: move-before

Moves iter in tree-store to the position before position. iter and position should be in the same level. Note that this function only works with unsorted stores. If position is ‘#f’, iter will be moved to the end of the level.

tree-store
A <gtk-tree-store>.
iter
A <gtk-tree-iter>.
position
A <gtk-tree-iter> or ‘#f’.

Since 2.2

— Function: gtk-tree-store-move-after (self <gtk-tree-store>) (iter <gtk-tree-iter>) (position <gtk-tree-iter>)
— Method: move-after

Moves iter in tree-store to the position after position. iter and position should be in the same level. Note that this function only works with unsorted stores. If position is ‘#f’, iter will be moved to the start of the level.

tree-store
A <gtk-tree-store>.
iter
A <gtk-tree-iter>.
position
A <gtk-tree-iter>.

Since 2.2