Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GtkTreeStore

[27:7] extends: object

A tree-like data structure that can be used with the [class@Gtk.TreeView]. The GtkTreeStore object is a list model for use with a GtkTreeView widget. It implements the [iface@Gtk.TreeModel] interface, and consequently, can use all of the methods available there. It also implements the [iface@Gtk.TreeSortable] interface so it can be sorted by the view. Finally, it also implements the tree [drag][iface@Gtk.TreeDragSource] and [drop][iface@Gtk.TreeDragDest] interfaces. GtkTreeStore is deprecated since GTK 4.10, and should not be used in newly written code. You should use [class@Gtk.TreeListModel] for a tree-like model object. ## GtkTreeStore as GtkBuildable The GtkTreeStore implementation of the GtkBuildable interface allows to specify the model columns with a <columns> element that may contain multiple <column> elements, each specifying one model column. The “type” attribute specifies the data type for the column. An example of a UI Definition fragment for a tree store: xml <object class="GtkTreeStore"> <columns> <column type="gchararray"/> <column type="gchararray"/> <column type="gint"/> </columns> </object>

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • GtkTreeStore (n_columns = null, ___ = null)

    Creates a new tree store. The tree store will have @n_columns, with each column using the corresponding type passed to this function. Note that only types derived from standard GObject fundamental types are supported. As an example: c gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_TEXTURE); will create a new GtkTreeStore with three columns of type int, gchararray, and GdkTexture respectively.

    • @p n_columns is number of columns in the tree store.
    • @p ___ is all GType types for the columns, from first to last.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asObject ()

    Wraps this handle as GObject.

    • @r A GObject object.
  • asBuildable ()

    Wraps this handle as GtkBuildable.

    • @r A GtkBuildable object.
  • asTreeDragDest ()

    Wraps this handle as GtkTreeDragDest.

    • @r A GtkTreeDragDest object.
  • asTreeDragSource ()

    Wraps this handle as GtkTreeDragSource.

    • @r A GtkTreeDragSource object.
  • asTreeModel ()

    Wraps this handle as GtkTreeModel.

    • @r A GtkTreeModel object.
  • asTreeSortable ()

    Wraps this handle as GtkTreeSortable.

    • @r A GtkTreeSortable object.
  • append (object parent)

    Appends a new row to @tree_store. 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. 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().

    • @p iter is An unset GtkTreeIter to set to the appended row.
    • @p parent is A valid GtkTreeIter.
    • @r None.
  • clear ()

    Removes all rows from @tree_store

    • @r None.
  • insert (object parent, int position)

    Creates a new row at @position. 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 -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().
    • @p iter is An unset GtkTreeIter to set to the new row.
    • @p parent is A valid GtkTreeIter.
    • @p position is position to insert the new row, or -1 for last.
    • @r None.
  • insert_after (object parent, object sibling)

    Inserts a new row after @sibling. 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. 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().
    • @p iter is An unset GtkTreeIter to set to the new row.
    • @p parent is A valid GtkTreeIter.
    • @p sibling is A valid GtkTreeIter.
    • @r None.
  • insert_before (object parent, object sibling)

    Inserts a new row before @sibling. 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. 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().
    • @p iter is An unset GtkTreeIter to set to the new row.
    • @p parent is A valid GtkTreeIter.
    • @p sibling is A valid GtkTreeIter.
    • @r None.
  • insert_with_values (object parent, int position, list varargs)

    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 c 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.

    • @p iter is An unset GtkTreeIter to set the new row.
    • @p parent is A valid GtkTreeIter.
    • @p position is position to insert the new row, or -1 to append after existing rows.
    • @p ... is pairs of column number and value, terminated with -1.
    • @r None.
  • insert_with_valuesv (object parent, int position, list columns, list values)

    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.

    • @p iter is An unset GtkTreeIter to set the new row.
    • @p parent is A valid GtkTreeIter.
    • @p position is position to insert the new row, or -1 for last.
    • @p columns is an array of column numbers.
    • @p values is an array of GValues.
    • @p n_values is the length of the @columns and @values arrays.
    • @r None.
  • is_ancestor (object iter, object descendant)

    Checks if @iter is an ancestor of @descendant.

    • @p iter is A valid GtkTreeIter.
    • @p descendant is A valid GtkTreeIter.
    • @r true if @iter is an ancestor of @descendant, and false otherwise.
  • iter_depth (object iter)

    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.

    • @p iter is A valid GtkTreeIter.
    • @r The depth of the position pointed by the iterator.
  • iter_is_valid (object iter)

    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.

    • @p iter is the iterator to check.
    • @r true if the iter is valid, and false otherwise.
  • move_after (object iter, object position)

    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 %NULL, @iter will be moved to the start of the level.
    • @p iter is A GtkTreeIter..
    • @p position is A GtkTreeIter..
    • @r None.
  • move_before (object iter, object position)

    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 %NULL, @iter will be moved to the end of the level.
    • @p iter is A GtkTreeIter.
    • @p position is A GtkTreeIter.
    • @r None.
  • prepend (object parent)

    Prepends a new row to @tree_store. 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. 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().

    • @p iter is An unset GtkTreeIter to set to the prepended row.
    • @p parent is A valid GtkTreeIter.
    • @r None.
  • remove (object iter)

    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.

    • @p iter is A valid GtkTreeIter.
    • @r true if @iter is still valid, and false otherwise.
  • reorder (object parent, list new_order)

    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.

    • @p parent is the parent of the children to re-order.
    • @p new_order is 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.
    • @r None.
  • set (object iter, list varargs)

    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 c 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.

    • @p iter is A valid GtkTreeIter for the row being modified.
    • @p ... is pairs of column number and value, terminated with -1.
    • @r None.
  • set_column_types (list types)

    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.

    • @p n_columns is Number of columns for the tree store.
    • @p types is An array of GType types, one for each column.
    • @r None.
  • set_value (object iter, int column, object 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.
    • @p iter is A valid GtkTreeIter for the row being modified.
    • @p column is column number to modify.
    • @p value is new value for the cell.
    • @r None.
  • set_valuesv (object iter, list columns, list values)

    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.

    • @p iter is A valid GtkTreeIter for the row being modified.
    • @p columns is an array of column numbers.
    • @p values is an array of GValues.
    • @p n_values is the length of the @columns and @values arrays.
    • @r None.
  • swap (object a, object b)

    Swaps @a and @b in the same level of @tree_store. Note that this function only works with unsorted stores.

    • @p a is A GtkTreeIter..
    • @p b is Another GtkTreeIter..
    • @r None.

class: GtkTreeStoreCtors

[516:14] static extends: object

Alternate constructors for GtkTreeStore. Usage: GtkTreeStoreCtors.<name>(...). The primary constructor lives directly on GtkTreeStore.

Methods

  • newNewv (list types)

    Creates a new tree store. This constructor is meant for language bindings.

    • @p n_columns is number of columns in the tree store.
    • @p types is an array of GType types for the columns, from first to last.
    • @r A new GtkTreeStore.