Class TreeStore
- All Implemented Interfaces:
Proxy
,Buildable
,TreeDragDest
,TreeDragSource
,TreeModel
,TreeSortable
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
Modifier and TypeClassDescriptionstatic class
TreeStore.Builder<B extends TreeStore.Builder<B>>
Deprecated.Inner class implementing a builder pattern to construct a GObject with properties.static class
Deprecated.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.TreeDragDest
TreeDragDest.TreeDragDestIface, TreeDragDest.TreeDragDestImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.TreeDragSource
TreeDragSource.TreeDragSourceIface, TreeDragSource.TreeDragSourceImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.TreeModel
TreeModel.RowChangedCallback, TreeModel.RowDeletedCallback, TreeModel.RowHasChildToggledCallback, TreeModel.RowInsertedCallback, TreeModel.RowsReorderedCallback, TreeModel.TreeModelIface, TreeModel.TreeModelImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.TreeSortable
TreeSortable.SortColumnChangedCallback, TreeSortable.TreeSortableIface, TreeSortable.TreeSortableImpl
-
Constructor Summary
ConstructorDescriptionTreeStore
(MemorySegment address) Deprecated.Create a TreeStore proxy instance for the provided memory address.Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.UseTreeListModel
insteadprotected TreeStore
asParent()
Deprecated.Returns this instance as if it were its parent type.static TreeStore.Builder
<? extends TreeStore.Builder> builder()
Deprecated.ATreeStore.Builder
object constructs aTreeStore
with the specified properties.void
clear()
Deprecated.UseTreeListModel
insteadstatic MemoryLayout
Deprecated.The memory layout of the native struct.static Type
getType()
Deprecated.Get the GType of the TreeStore classvoid
Deprecated.UseTreeListModel
insteadvoid
insertAfter
(TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter sibling) Deprecated.UseTreeListModel
insteadvoid
insertBefore
(TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter sibling) Deprecated.UseTreeListModel
insteadvoid
insertWithValues
(@Nullable TreeIter iter, @Nullable TreeIter parent, int position, int[] columns, Value[] values) Deprecated.UseTreeListModel
insteadboolean
isAncestor
(TreeIter iter, TreeIter descendant) Deprecated.UseTreeListModel
insteadint
Deprecated.UseTreeListModel
insteadboolean
iterIsValid
(TreeIter iter) Deprecated.UseTreeListModel
insteadvoid
Deprecated.UseTreeListModel
insteadvoid
moveBefore
(TreeIter iter, @Nullable TreeIter position) Deprecated.UseTreeListModel
insteadvoid
Deprecated.UseTreeListModel
insteadboolean
Deprecated.UseTreeListModel
insteadvoid
Deprecated.UseTreeListModel
insteadvoid
Deprecated.UseTreeListModel
insteadvoid
setColumnTypes
(Type[] types) Deprecated.UseTreeListModel
insteadvoid
Deprecated.UseTreeListModel
insteadvoid
Deprecated.UseTreeListModel
insteadMethods inherited from class org.gnome.gobject.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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
Methods inherited from interface org.gnome.gtk.TreeDragDest
dragDataReceived, rowDropPossible
Methods inherited from interface org.gnome.gtk.TreeDragSource
dragDataDelete, dragDataGet, rowDraggable
Methods inherited from interface org.gnome.gtk.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, unrefNode
Methods inherited from interface org.gnome.gtk.TreeSortable
emitSortColumnChanged, getSortColumnId, hasDefaultSortFunc, onSortColumnChanged, setDefaultSortFunc, setSortColumnId, setSortFunc, sortColumnChanged
-
Constructor Details
-
TreeStore
Deprecated.Create a TreeStore proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
TreeStore
Deprecated.UseTreeListModel
insteadCreates a new tree store.This constructor is meant for language bindings.
- Parameters:
types
- an array ofGType
types for the columns, from first to last
-
-
Method Details
-
getType
-
getMemoryLayout
Deprecated.The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Deprecated.Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
append
Deprecated.UseTreeListModel
insteadAppends a new row to this TreeStore.If
parent
is 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
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 unsetGtkTreeIter
to set to the appended rowparent
- A validGtkTreeIter
-
clear
Deprecated.UseTreeListModel
insteadRemoves all rows from this TreeStore -
insert
Deprecated.UseTreeListModel
insteadCreates a new row atposition
.If parent is non-
null
, then the row will be made a child ofparent
. 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 unsetGtkTreeIter
to set to the new rowparent
- A validGtkTreeIter
position
- position to insert the new row, or -1 for last
-
insertAfter
@Deprecated public void insertAfter(TreeIter iter, @Nullable @Nullable TreeIter parent, @Nullable @Nullable TreeIter sibling) Deprecated.UseTreeListModel
insteadInserts a new row aftersibling
.If
sibling
isnull
, then the row will be prepended toparent
’s children.If
parent
andsibling
arenull
, then the row will be prepended to the toplevel.If both
sibling
andparent
are set, thenparent
must be the parent ofsibling
. Whensibling
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 unsetGtkTreeIter
to set to the new rowparent
- A validGtkTreeIter
sibling
- A validGtkTreeIter
-
insertBefore
@Deprecated public void insertBefore(TreeIter iter, @Nullable @Nullable TreeIter parent, @Nullable @Nullable TreeIter sibling) Deprecated.UseTreeListModel
insteadInserts a new row beforesibling
.If
sibling
isnull
, then the row will be appended toparent
’s children.If
parent
andsibling
arenull
, then the row will be appended to the toplevel.If both
sibling
andparent
are set, thenparent
must be the parent ofsibling
. Whensibling
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 unsetGtkTreeIter
to set to the new rowparent
- A validGtkTreeIter
sibling
- A validGtkTreeIter
-
insertWithValues
@Deprecated public void insertWithValues(@Nullable @Nullable TreeIter iter, @Nullable @Nullable TreeIter parent, int position, int[] columns, Value[] values) Deprecated.UseTreeListModel
insteadA 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 unsetGtkTreeIter
to set the new rowparent
- A validGtkTreeIter
position
- position to insert the new row, or -1 for lastcolumns
- an array of column numbersvalues
- an array of GValues
-
isAncestor
Deprecated.UseTreeListModel
insteadChecks ifiter
is an ancestor ofdescendant
.- Parameters:
iter
- A validGtkTreeIter
descendant
- A validGtkTreeIter
- Returns:
- true if
iter
is an ancestor ofdescendant
, and false otherwise
-
iterDepth
Deprecated.UseTreeListModel
insteadReturns the depth of the position pointed by the iteratorThe 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.UseTreeListModel
insteadChecks if the given iter is a valid iter for thisGtkTreeStore
.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.UseTreeListModel
insteadMovesiter
in this TreeStore to the position afterposition
.iter
andposition
should be in the same level.Note that this function only works with unsorted stores.
If
position
isnull
,iter
will be moved to the start of the level.- Parameters:
iter
- AGtkTreeIter
.position
- AGtkTreeIter
.
-
moveBefore
Deprecated.UseTreeListModel
insteadMovesiter
in this TreeStore to the position beforeposition
.iter
andposition
should be in the same level.Note that this function only works with unsorted stores.
If
position
isnull
,iter
will be moved to the end of the level.- Parameters:
iter
- AGtkTreeIter
position
- AGtkTreeIter
-
prepend
Deprecated.UseTreeListModel
insteadPrepends a new row to this TreeStore.If
parent
is non-null
, then it will prepend the new row before the first child ofparent
, otherwise it will prepend a row to the top level. Theiter
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 unsetGtkTreeIter
to set to the prepended rowparent
- A validGtkTreeIter
-
remove
Deprecated.UseTreeListModel
insteadRemovesiter
from this 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 validGtkTreeIter
- Returns:
- true if
iter
is still valid, and false otherwise
-
reorder
Deprecated.UseTreeListModel
insteadReorders the children ofparent
in 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.UseTreeListModel
insteadSets 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
GtkTreeModel
interface is called on the tree store.- Parameters:
types
- An array ofGType
types, one for each column
-
setValue
Deprecated.UseTreeListModel
insteadSets the data in the cell specified byiter
andcolumn
.The type of
value
must be convertible to the type of the column.- Parameters:
iter
- A validGtkTreeIter
for the row being modifiedcolumn
- column number to modifyvalue
- new value for the cell
-
set
Deprecated.UseTreeListModel
insteadA 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 validGtkTreeIter
for the row being modifiedcolumns
- an array of column numbersvalues
- an array of GValues
-
swap
Deprecated.UseTreeListModel
insteadSwapsa
andb
in the same level of this TreeStore.Note that this function only works with unsorted stores.
- Parameters:
a
- AGtkTreeIter
.b
- AnotherGtkTreeIter
.
-
builder
Deprecated.ATreeStore.Builder
object constructs aTreeStore
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withTreeStore.Builder.build()
.
-
TreeListModel
instead