Class TreeStore
- All Implemented Interfaces:
Buildable, TreeDragDest, TreeDragSource, TreeModel, TreeSortable, Proxy
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>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTreeStore.Builder<B extends TreeStore.Builder<B>>Deprecated.Inner class implementing a builder pattern to construct a GObject with properties.static classDeprecated.Nested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface Buildable
Buildable.Buildable$Impl, Buildable.BuildableIfaceNested classes/interfaces inherited from interface TreeDragDest
TreeDragDest.TreeDragDest$Impl, TreeDragDest.TreeDragDestIfaceNested classes/interfaces inherited from interface TreeDragSource
TreeDragSource.TreeDragSource$Impl, TreeDragSource.TreeDragSourceIfaceNested classes/interfaces inherited from interface TreeModel
TreeModel.RowChangedCallback, TreeModel.RowDeletedCallback, TreeModel.RowHasChildToggledCallback, TreeModel.RowInsertedCallback, TreeModel.RowsReorderedCallback, TreeModel.TreeModel$Impl, TreeModel.TreeModelIfaceNested classes/interfaces inherited from interface TreeSortable
TreeSortable.SortColumnChangedCallback, TreeSortable.TreeSortable$Impl, TreeSortable.TreeSortableIface -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Create a new TreeStore.TreeStore(MemorySegment address) Deprecated.Create a TreeStore instance for the provided memory address.Deprecated.UseTreeListModelinstead -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.UseTreeListModelinsteadprotected TreeStoreasParent()Deprecated.Return this instance as if it were its parent type.static TreeStore.Builder<? extends TreeStore.Builder> builder()Deprecated.ATreeStore.Builderobject constructs aTreeStorewith the specified properties.voidclear()Deprecated.UseTreeListModelinsteadstatic MemoryLayoutDeprecated.The memory layout of the native struct.static @Nullable TypegetType()Deprecated.Get the GType of the TreeStore class.voidDeprecated.UseTreeListModelinsteadvoidinsertAfter(TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter sibling) Deprecated.UseTreeListModelinsteadvoidinsertBefore(TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter sibling) Deprecated.UseTreeListModelinsteadvoidinsertWithValues(@Nullable TreeIter iter, @Nullable TreeIter parent, int position, @Nullable int @Nullable [] columns, @Nullable Value @Nullable [] values) Deprecated.UseTreeListModelinsteadbooleanisAncestor(TreeIter iter, TreeIter descendant) Deprecated.UseTreeListModelinsteadintDeprecated.UseTreeListModelinsteadbooleaniterIsValid(TreeIter iter) Deprecated.UseTreeListModelinsteadvoidDeprecated.UseTreeListModelinsteadvoidmoveBefore(TreeIter iter, @Nullable TreeIter position) Deprecated.UseTreeListModelinsteadvoidDeprecated.UseTreeListModelinsteadbooleanDeprecated.UseTreeListModelinsteadvoidDeprecated.UseTreeListModelinsteadvoidDeprecated.UseTreeListModelinsteadvoidsetColumnTypes(@Nullable Type @Nullable [] types) Deprecated.UseTreeListModelinsteadvoidDeprecated.UseTreeListModelinsteadvoidDeprecated.UseTreeListModelinsteadMethods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCodeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Buildable
getBuildableIdMethods inherited from interface TreeDragDest
dragDataReceived, rowDropPossibleMethods inherited from interface TreeDragSource
dragDataDelete, dragDataGet, rowDraggableMethods inherited from interface TreeModel
emitRowChanged, emitRowDeleted, emitRowHasChildToggled, emitRowInserted, emitRowsReordered, filterNew, foreach, get, getColumnType, getFlags, getIter, getIterFirst, getIterFromString, getNColumns, getPath, getStringFromIter, getValue, iterChildren, iterHasChild, iterNChildren, iterNext, iterNthChild, iterParent, iterPrevious, onRowChanged, onRowDeleted, onRowHasChildToggled, onRowInserted, onRowsReordered, refNode, rowChanged, rowDeleted, rowHasChildToggled, rowInserted, rowsReordered, unrefNodeMethods inherited from interface TreeSortable
emitSortColumnChanged, getSortColumnId, hasDefaultSortFunc, onSortColumnChanged, setDefaultSortFunc, setSortColumnId, setSortFunc, sortColumnChanged
-
Constructor Details
-
TreeStore
Deprecated.Create a TreeStore instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
TreeStore
Deprecated.UseTreeListModelinsteadCreates a new tree store.
This constructor is meant for language bindings.
- Parameters:
types- an array ofGTypetypes for the columns, from first to last
-
TreeStore
public TreeStore()Deprecated.Create a new TreeStore.
-
-
Method Details
-
getType
Deprecated.Get the GType of the TreeStore class.- Returns:
- the GType
-
getMemoryLayout
Deprecated.The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
-
append
Deprecated.UseTreeListModelinsteadAppends a new row to
treeStore.If
parentis non-null, then it will append the new row after the last child ofparent,otherwise it will append a row to the top level.The
iterparameter 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 unsetGtkTreeIterto set to the appended rowparent- A validGtkTreeIter
-
clear
Deprecated.UseTreeListModelinsteadRemoves all rows from this TreeStore -
insert
Deprecated.UseTreeListModelinsteadCreates a new row at
position.If parent is non-
null, then the row will be made a child ofparent.Otherwise, the row will be created at the toplevel.If
positionis-1or is larger than the number of rows at that level, then the new row will be inserted to the end of the list.The
iterparameter 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 unsetGtkTreeIterto set to the new rowparent- A validGtkTreeIterposition- position to insert the new row, or -1 for last
-
insertAfter
@Deprecated public void insertAfter(TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter sibling) Deprecated.UseTreeListModelinsteadInserts a new row after
sibling.If
siblingisnull, then the row will be prepended toparent’schildren.If
parentandsiblingarenull, then the row will be prepended to the toplevel.If both
siblingandparentare set, thenparentmust be the parent ofsibling.Whensiblingis set,parentis optional.The
iterparameter 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 unsetGtkTreeIterto set to the new rowparent- A validGtkTreeItersibling- A validGtkTreeIter
-
insertBefore
@Deprecated public void insertBefore(TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter sibling) Deprecated.UseTreeListModelinsteadInserts a new row before
sibling.If
siblingisnull, then the row will be appended toparent’schildren.If
parentandsiblingarenull, then the row will be appended to the toplevel.If both
siblingandparentare set, thenparentmust be the parent ofsibling.Whensiblingis set,parentis optional.The
iterparameter 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 unsetGtkTreeIterto set to the new rowparent- A validGtkTreeItersibling- A validGtkTreeIter
-
insertWithValues
@Deprecated public void insertWithValues(@Nullable TreeIter iter, @Nullable TreeIter parent, int position, @Nullable int @Nullable [] columns, @Nullable Value @Nullable [] values) Deprecated.UseTreeListModelinsteadA 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 unsetGtkTreeIterto set the new rowparent- A validGtkTreeIterposition- position to insert the new row, or -1 for lastcolumns- an array of column numbersvalues- an array of GValues
-
isAncestor
Deprecated.UseTreeListModelinsteadChecks ifiteris an ancestor ofdescendant.- Parameters:
iter- A validGtkTreeIterdescendant- A validGtkTreeIter- Returns:
- true if
iteris an ancestor ofdescendant,and false otherwise
-
iterDepth
Deprecated.UseTreeListModelinsteadReturns 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 validGtkTreeIter- Returns:
- The depth of the position pointed by the iterator
-
iterIsValid
Deprecated.UseTreeListModelinsteadChecks 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.UseTreeListModelinsteadMoves
iterin this TreeStore to the position afterposition.iterandpositionshould be in the same level.Note that this function only works with unsorted stores.
If
positionisnull,iterwill be moved to the start of the level.- Parameters:
iter- AGtkTreeIter.position- AGtkTreeIter.
-
moveBefore
Deprecated.UseTreeListModelinsteadMoves
iterin this TreeStore to the position beforeposition.iterandpositionshould be in the same level.Note that this function only works with unsorted stores.
If
positionisnull,iterwill be moved to the end of the level.- Parameters:
iter- AGtkTreeIterposition- AGtkTreeIter
-
prepend
Deprecated.UseTreeListModelinsteadPrepends a new row to
treeStore.If
parentis non-null, then it will prepend the new row before the first child ofparent,otherwise it will prepend a row to the top level. Theiterparameter 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 unsetGtkTreeIterto set to the prepended rowparent- A validGtkTreeIter
-
remove
Deprecated.UseTreeListModelinsteadRemoves
iterfromtreeStore.After being removed,
iteris set to the next valid row at that level, or invalidated if it previously pointed to the last one.- Parameters:
iter- A validGtkTreeIter- Returns:
- true if
iteris still valid, and false otherwise
-
reorder
Deprecated.UseTreeListModelinsteadReorders the children of
parentin this TreeStore to follow the order indicated bynewOrder.Note that this function only works with unsorted stores.
- Parameters:
parent- the parent of the children to re-ordernewOrder- 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.UseTreeListModelinsteadSets 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 newGtkTreeStore.This functions cannot be called after a row has been added, or a method on the
GtkTreeModelinterface is called on the tree store.- Parameters:
types- An array ofGTypetypes, one for each column
-
setValue
Deprecated.UseTreeListModelinsteadSets the data in the cell specified by
iterandcolumn.The type of
valuemust be convertible to the type of the column.- Parameters:
iter- A validGtkTreeIterfor the row being modifiedcolumn- column number to modifyvalue- new value for the cell
-
set
@Deprecated public void set(TreeIter iter, @Nullable int @Nullable [] columns, @Nullable Value @Nullable [] values) Deprecated.UseTreeListModelinsteadA 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 validGtkTreeIterfor the row being modifiedcolumns- an array of column numbersvalues- an array of GValues
-
swap
Deprecated.UseTreeListModelinsteadSwaps
aandbin the same level oftreeStore.Note that this function only works with unsorted stores.
- Parameters:
a- AGtkTreeIter.b- AnotherGtkTreeIter.
-
builder
Deprecated.ATreeStore.Builderobject constructs aTreeStorewith the specified properties. Use the variousset...()methods to set properties, and finish construction withTreeStore.Builder.build().- Returns:
- the builder object
-
TreeListModelinstead