Class TreeStore

All Implemented Interfaces:
Buildable, TreeDragDest, TreeDragSource, TreeModel, TreeSortable, Proxy

@Generated("org.javagi.JavaGI") @Deprecated public class TreeStore extends GObject implements Buildable, TreeDragDest, TreeDragSource, TreeModel, TreeSortable
Deprecated.
Use TreeListModel instead

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

The GtkTreeStore object is a list model for use with a GtkTreeView widget. It implements the TreeModel interface, and consequently, can use all of the methods available there. It also implements the TreeSortable interface so it can be sorted by the view. Finally, it also implements the tree Gtk.TreeDragSource and Gtk.TreeDragDest interfaces.

GtkTreeStore is deprecated since GTK 4.10, and should not be used in newly written code. You should use 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:

<object class="GtkTreeStore">
  <columns>
    <column type="gchararray"/>
    <column type="gchararray"/>
    <column type="gint"/>
  </columns>
</object>
  • Constructor Details

    • TreeStore

      public TreeStore(MemorySegment address)
      Deprecated.
      Create a TreeStore instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • TreeStore

      @Deprecated public TreeStore(@Nullable Type @Nullable [] types)
      Deprecated.
      Use TreeListModel instead

      Creates a new tree store.

      This constructor is meant for language bindings.

      Parameters:
      types - an array of GType types for the columns, from first to last
    • TreeStore

      public TreeStore()
      Deprecated.
      Create a new TreeStore.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Deprecated.
      Get the GType of the TreeStore class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      Deprecated.
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected TreeStore asParent()
      Deprecated.
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • append

      @Deprecated public void append(TreeIter iter, @Nullable TreeIter parent)
      Deprecated.
      Use TreeListModel instead

      Appends a new row to treeStore.

      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().

      Parameters:
      iter - An unset GtkTreeIter to set to the appended row
      parent - A valid GtkTreeIter
    • clear

      @Deprecated public void clear()
      Deprecated.
      Use TreeListModel instead
      Removes all rows from this TreeStore
    • insert

      @Deprecated public void insert(TreeIter iter, @Nullable TreeIter parent, int position)
      Deprecated.
      Use TreeListModel instead

      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().

      Parameters:
      iter - An unset GtkTreeIter to set to the new row
      parent - A valid GtkTreeIter
      position - position to insert the new row, or -1 for last
    • insertAfter

      @Deprecated public void insertAfter(TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter sibling)
      Deprecated.
      Use TreeListModel instead

      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().

      Parameters:
      iter - An unset GtkTreeIter to set to the new row
      parent - A valid GtkTreeIter
      sibling - A valid GtkTreeIter
    • insertBefore

      @Deprecated public void insertBefore(TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter sibling)
      Deprecated.
      Use TreeListModel instead

      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().

      Parameters:
      iter - An unset GtkTreeIter to set to the new row
      parent - A valid GtkTreeIter
      sibling - A valid GtkTreeIter
    • insertWithValues

      @Deprecated public void insertWithValues(@Nullable TreeIter iter, @Nullable TreeIter parent, int position, @Nullable int @Nullable [] columns, @Nullable Value @Nullable [] values)
      Deprecated.
      Use TreeListModel instead

      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 - An unset GtkTreeIter to set the new row
      parent - A valid GtkTreeIter
      position - position to insert the new row, or -1 for last
      columns - an array of column numbers
      values - an array of GValues
    • isAncestor

      @Deprecated public boolean isAncestor(TreeIter iter, TreeIter descendant)
      Deprecated.
      Use TreeListModel instead
      Checks if iter is an ancestor of descendant.
      Parameters:
      iter - A valid GtkTreeIter
      descendant - A valid GtkTreeIter
      Returns:
      true if iter is an ancestor of descendant, and false otherwise
    • iterDepth

      @Deprecated public int iterDepth(TreeIter iter)
      Deprecated.
      Use TreeListModel instead

      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 - A valid GtkTreeIter
      Returns:
      The depth of the position pointed by the iterator
    • iterIsValid

      @Deprecated public boolean iterIsValid(TreeIter iter)
      Deprecated.
      Use TreeListModel instead

      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 - the iterator to check
      Returns:
      true if the iter is valid, and false otherwise
    • moveAfter

      @Deprecated public void moveAfter(TreeIter iter, @Nullable TreeIter position)
      Deprecated.
      Use TreeListModel instead

      Moves iter in this TreeStore 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.

      Parameters:
      iter - A GtkTreeIter.
      position - A GtkTreeIter.
    • moveBefore

      @Deprecated public void moveBefore(TreeIter iter, @Nullable TreeIter position)
      Deprecated.
      Use TreeListModel instead

      Moves iter in this TreeStore 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.

      Parameters:
      iter - A GtkTreeIter
      position - A GtkTreeIter
    • prepend

      @Deprecated public void prepend(TreeIter iter, @Nullable TreeIter parent)
      Deprecated.
      Use TreeListModel instead

      Prepends a new row to treeStore.

      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().

      Parameters:
      iter - An unset GtkTreeIter to set to the prepended row
      parent - A valid GtkTreeIter
    • remove

      @Deprecated public boolean remove(TreeIter iter)
      Deprecated.
      Use TreeListModel instead

      Removes iter from treeStore.

      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 - A valid GtkTreeIter
      Returns:
      true if iter is still valid, and false otherwise
    • reorder

      @Deprecated public void reorder(@Nullable TreeIter parent, @Nullable int @Nullable [] newOrder)
      Deprecated.
      Use TreeListModel instead

      Reorders the children of parent in this TreeStore to follow the order indicated by newOrder.

      Note that this function only works with unsorted stores.

      Parameters:
      parent - the parent of the children to re-order
      newOrder - 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
    • setColumnTypes

      @Deprecated public void setColumnTypes(@Nullable Type @Nullable [] types)
      Deprecated.
      Use TreeListModel instead

      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:
      types - An array of GType types, one for each column
    • setValue

      @Deprecated public void setValue(TreeIter iter, int column, Value value)
      Deprecated.
      Use TreeListModel instead

      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 - A valid GtkTreeIter for the row being modified
      column - column number to modify
      value - new value for the cell
    • set

      @Deprecated public void set(TreeIter iter, @Nullable int @Nullable [] columns, @Nullable Value @Nullable [] values)
      Deprecated.
      Use TreeListModel instead

      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 - A valid GtkTreeIter for the row being modified
      columns - an array of column numbers
      values - an array of GValues
    • swap

      @Deprecated public void swap(TreeIter a, TreeIter b)
      Deprecated.
      Use TreeListModel instead

      Swaps a and b in the same level of treeStore.

      Note that this function only works with unsorted stores.

      Parameters:
      a - A GtkTreeIter.
      b - Another GtkTreeIter.
    • builder

      public static TreeStore.Builder<? extends TreeStore.Builder> builder()
      Deprecated.
      A TreeStore.Builder object constructs a TreeStore with the specified properties. Use the various set...() methods to set properties, and finish construction with TreeStore.Builder.build().
      Returns:
      the builder object