Class: Gtk::TreeStore

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Constructor Details

#initialize(n_columns, types) ⇒ Gtk::TreeStore

Creates a new tree store.

This constructor is meant for language bindings.

Parameters:

  • n_columns (Integer)

    number of columns in the tree store

  • types (Array<GLib::Type>)

    an array of GType types for the columns, from first to last

Instance Method Details

#append(iter, parent) ⇒ nil

Appends a new row to tree_store.

If parent is non-nil, then it will append the new row after the last child of parent, otherwise it will append a row to the top level.

The iter parameter 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().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the appended row

  • parent (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (nil)

#clearnil

Removes all rows from tree_store

Returns:

  • (nil)

#insert(iter, parent, position) ⇒ nil

Creates a new row at position.

If parent is non-nil, then the row will be made a child of parent. Otherwise, the row will be created at the toplevel.

If position is -1 or is larger than the number of rows at that level, then the new row will be inserted to the end of the list.

The iter parameter 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().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the new row

  • parent (Gtk::TreeIter)

    A valid GtkTreeIter

  • position (Integer)

    position to insert the new row, or -1 for last

Returns:

  • (nil)

#insert_after(iter, parent, sibling) ⇒ nil

Inserts a new row after sibling.

If sibling is nil, then the row will be prepended to parent’s children.

If parent and sibling are nil, 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.

The iter parameter 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().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the new row

  • parent (Gtk::TreeIter)

    A valid GtkTreeIter

  • sibling (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (nil)

#insert_before(iter, parent, sibling) ⇒ nil

Inserts a new row before sibling.

If sibling is nil, then the row will be appended to parent’s children.

If parent and sibling are nil, 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.

The iter parameter 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().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the new row

  • parent (Gtk::TreeIter)

    A valid GtkTreeIter

  • sibling (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (nil)

#insert_with_values(iter, parent, position, array) ⇒ nil

Creates a new row at the given position.

The iter parameter will be changed to point to this new row.

If position is -1, or 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.

Calling

gtk_tree_store_insert_with_values (tree_store, iter, position, ...)

has the same effect as calling

gtk_tree_store_insert (tree_store, iter, position);
gtk_tree_store_set (tree_store, iter, ...);

with the different that the former will only emit a row_inserted signal, while the latter will emit row_inserted, row_changed and if the tree store is sorted, rows_reordered.

Since emitting the rows_reordered signal repeatedly can affect the performance of the program, gtk_tree_store_insert_with_values() should generally be preferred when inserting rows in a sorted tree store.

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set the new row

  • parent (Gtk::TreeIter)

    A valid GtkTreeIter

  • position (Integer)

    position to insert the new row, or -1 to append after existing rows

  • array (Array)

    pairs of column number and value, terminated with -1

Returns:

  • (nil)

#insert_with_valuesv(iter, parent, position, columns, values, n_values) ⇒ nil

A variant of gtk_tree_store_insert_with_values() which takes the columns and values as two arrays, instead of varargs.

This function is mainly intended for language bindings.

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set the new row

  • parent (Gtk::TreeIter)

    A valid GtkTreeIter

  • position (Integer)

    position to insert the new row, or -1 for last

  • columns (Array<Integer>)

    an array of column numbers

  • values (Array<GObject::Value>)

    an array of GValues

  • n_values (Integer)

    the length of the columns and values arrays

Returns:

  • (nil)

#is_ancestor(iter, descendant) ⇒ Boolean

Checks if iter is an ancestor of descendant.

Parameters:

  • iter (Gtk::TreeIter)

    A valid GtkTreeIter

  • descendant (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (Boolean)

    true if iter is an ancestor of descendant, and false otherwise

#iter_depth(iter) ⇒ Integer

Returns the depth of the position pointed by the iterator

The depth will be 0 for anything on the root level, 1 for anything down a level, etc.

Parameters:

  • iter (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (Integer)

    The depth of the position pointed by the iterator

#iter_is_valid(iter) ⇒ Boolean

Checks if the given iter is a valid iter for this GtkTreeStore.

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

Parameters:

  • iter (Gtk::TreeIter)

    the iterator to check

Returns:

  • (Boolean)

    true if the iter is valid, and false otherwise

#move_after(iter, position) ⇒ nil

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 nil, iter will be moved to the start of the level.

Parameters:

  • iter (Gtk::TreeIter)

    A GtkTreeIter.

  • position (Gtk::TreeIter)

    A GtkTreeIter.

Returns:

  • (nil)

#move_before(iter, position) ⇒ nil

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 nil, iter will be moved to the end of the level.

Parameters:

  • iter (Gtk::TreeIter)

    A GtkTreeIter

  • position (Gtk::TreeIter)

    A GtkTreeIter

Returns:

  • (nil)

#prepend(iter, parent) ⇒ nil

Prepends a new row to tree_store.

If parent is non-nil, then it will prepend the new row before the first child of parent, otherwise it will prepend a row to the top level. The iter parameter 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().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the prepended row

  • parent (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (nil)

#remove(iter) ⇒ Boolean

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.

Parameters:

  • iter (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (Boolean)

    true if iter is still valid, and false otherwise

#reorder(parent, new_order) ⇒ nil

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.

Parameters:

  • parent (Gtk::TreeIter)

    the parent of the children to re-order

  • new_order (Array<Integer>)

    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

Returns:

  • (nil)

#set(iter, array) ⇒ nil

Sets the value of one or more cells in the row referenced by iter.

The variable argument list should contain integer column numbers, each column number followed by the value to be set.

The list is terminated by a value of -1.

For example, to set column 0 with type G_TYPE_STRING to “Foo”, you would write

gtk_tree_store_set (store, iter, 0, "Foo", -1);

The value will be referenced by the store if it is a G_TYPE_OBJECT, and it will be copied if it is a G_TYPE_STRING or G_TYPE_BOXED.

Parameters:

  • iter (Gtk::TreeIter)

    A valid GtkTreeIter for the row being modified

  • array (Array)

    pairs of column number and value, terminated with -1

Returns:

  • (nil)

#set_column_types(n_columns, types) ⇒ nil

Sets the type of the columns in a tree store.

This function is meant primarily for types that inherit from GtkTreeStore, and should only be used when constructing a new GtkTreeStore.

This functions cannot be called after a row has been added, or a method on the GtkTreeModel interface is called on the tree store.

Parameters:

  • n_columns (Integer)

    Number of columns for the tree store

  • types (Array<GLib::Type>)

    An array of GType types, one for each column

Returns:

  • (nil)

#set_valist(iter, var_args) ⇒ nil

A version of gtk_tree_store_set() using va_list.

Parameters:

  • iter (Gtk::TreeIter)

    A valid GtkTreeIter for the row being modified

  • var_args (Gtk::va_list)

    va_list of column/value pairs

Returns:

  • (nil)

#set_value(iter, column, value) ⇒ nil

Sets the data in the cell specified by iter and column.

The type of value must be convertible to the type of the column.

Parameters:

  • iter (Gtk::TreeIter)

    A valid GtkTreeIter for the row being modified

  • column (Integer)

    column number to modify

  • value (GObject::Value)

    new value for the cell

Returns:

  • (nil)

#set_valuesv(iter, columns, values, n_values) ⇒ nil

A variant of gtk_tree_store_set_valist() which takes the columns and values as two arrays, instead of using variadic arguments.

This function is mainly intended for language bindings or in case the number of columns to change is not known until run-time.

Parameters:

  • iter (Gtk::TreeIter)

    A valid GtkTreeIter for the row being modified

  • columns (Array<Integer>)

    an array of column numbers

  • values (Array<GObject::Value>)

    an array of GValues

  • n_values (Integer)

    the length of the columns and values arrays

Returns:

  • (nil)

#swap(a, b) ⇒ nil

Swaps a and b in the same level of tree_store.

Note that this function only works with unsorted stores.

Parameters:

  • a (Gtk::TreeIter)

    A GtkTreeIter.

  • b (Gtk::TreeIter)

    Another GtkTreeIter.

Returns:

  • (nil)