Class: Gtk::ListStore

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

Instance Method Summary collapse

Constructor Details

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

Creates a new GtkListStore.

This function is meant to be used by language bindings.

Parameters:

  • n_columns (Integer)

    number of columns in the list store

  • types (Array<GLib::Type>)

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

Instance Method Details

#append(iter) ⇒ nil

Appends a new row to list_store. 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_list_store_set() or gtk_list_store_set_value().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the appended row

Returns:

  • (nil)

#clearnil

Removes all rows from the list store.

Returns:

  • (nil)

#insert(iter, position) ⇒ nil

Creates a new row at position. iter will be changed to point to this new row. If position is -1 or is larger than the number of rows on the list, then the new row will be appended to the list. The row will be empty after this function is called. To fill in values, you need to call gtk_list_store_set() or gtk_list_store_set_value().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the new row

  • position (Integer)

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

Returns:

  • (nil)

#insert_after(iter, sibling) ⇒ nil

Inserts a new row after sibling. If sibling is nil, then the row will be prepended to the beginning 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_list_store_set() or gtk_list_store_set_value().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the new row

  • sibling (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (nil)

#insert_before(iter, sibling) ⇒ nil

Inserts a new row before sibling. If sibling is nil, then the row will be appended 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_list_store_set() or gtk_list_store_set_value().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the new row

  • sibling (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (nil)

#insert_with_values(iter, position, array) ⇒ nil

Creates a new row at position. iter will be changed to point to this new row. If position is -1, or larger than the number of rows in 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_list_store_insert_with_values (list_store, iter, position...) has the same effect as calling:

static void
insert_value (GtkListStore *list_store,
              GtkTreeIter  *iter,
              int           position)
{
  gtk_list_store_insert (list_store, iter, position);
  gtk_list_store_set (list_store,
                      iter
                      // ...
                      );
}

with the difference that the former will only emit GtkTreeModel::row-inserted once, while the latter will emit GtkTreeModel::row-inserted, GtkTreeModel::row-changed and, if the list store is sorted, GtkTreeModel::rows-reordered for every inserted value.

Since emitting the GtkTreeModel::rows-reordered signal repeatedly can affect the performance of the program, gtk_list_store_insert_with_values() should generally be preferred when inserting rows in a sorted list store.

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the new row

  • 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, position, columns, values, n_values) ⇒ nil

A variant of gtk_list_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 to the new row

  • 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)

#iter_is_valid(iter) ⇒ Boolean

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

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, false if the iter is invalid.

#move_after(iter, position) ⇒ nil

Moves iter in store to the position after position. Note that this function only works with unsorted stores. If position is nil, iter will be moved to the start of the list.

Parameters:

  • iter (Gtk::TreeIter)

    A GtkTreeIter

  • position (Gtk::TreeIter)

    A GtkTreeIter

Returns:

  • (nil)

#move_before(iter, position) ⇒ nil

Moves iter in store to the position before position. Note that this function only works with unsorted stores. If position is nil, iter will be moved to the end of the list.

Parameters:

  • iter (Gtk::TreeIter)

    A GtkTreeIter

  • position (Gtk::TreeIter)

    A GtkTreeIter

Returns:

  • (nil)

#prepend(iter) ⇒ nil

Prepends a new row to list_store. 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_list_store_set() or gtk_list_store_set_value().

Parameters:

  • iter (Gtk::TreeIter)

    An unset GtkTreeIter to set to the prepend row

Returns:

  • (nil)

#remove(iter) ⇒ Boolean

Removes the given row from the list store. After being removed, iter is set to be the next valid row, or invalidated if it pointed to the last row in list_store.

Parameters:

  • iter (Gtk::TreeIter)

    A valid GtkTreeIter

Returns:

  • (Boolean)

    true if iter is valid, false if not.

#reorder(new_order) ⇒ nil

Reorders store to follow the order indicated by new_order. Note that this function only works with unsorted stores.

Parameters:

  • 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. It must have exactly as many items as the list store’s length.

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 -1. For example, to set column 0 with type %G_TYPE_STRING to “Foo”, you would write gtk_list_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)

    row iterator

  • array (Array)

    pairs of column number and value, terminated with -1

Returns:

  • (nil)

#set_column_types(n_columns, types) ⇒ nil

Sets the types of the columns of a list store.

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

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

Parameters:

  • n_columns (Integer)

    Number of columns for the list store

  • types (Array<GLib::Type>)

    An array length n of GTypes

Returns:

  • (nil)

#set_valist(iter, var_args) ⇒ nil

See gtk_list_store_set(); this version takes a va_list for use by language bindings.

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_list_store_set_valist() which takes the columns and values as two arrays, instead of varargs. This function is mainly intended for language-bindings and 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 store. Note that this function only works with unsorted stores.

Parameters:

  • a (Gtk::TreeIter)

    A GtkTreeIter

  • b (Gtk::TreeIter)

    Another GtkTreeIter

Returns:

  • (nil)