Package ch.bailu.gtk.gtk
Class TreeStore
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gtk.TreeStore
- All Implemented Interfaces:
PointerInterface
A tree-like data structure that can be used with the GtkTreeView
The `GtkTreeStore` object is a list model for use with a `GtkTreeView`
widget. It implements the `GtkTreeModel` interface, and consequently,
can use all of the methods available there. It also implements the
`GtkTreeSortable` interface so it can be sorted by the view. Finally,
it also implements the tree
[drag and drop][gtk3-GtkTreeView-drag-and-drop]
interfaces.
# 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:
The `GtkTreeStore` object is a list model for use with a `GtkTreeView`
widget. It implements the `GtkTreeModel` interface, and consequently,
can use all of the methods available there. It also implements the
`GtkTreeSortable` interface so it can be sorted by the view. Finally,
it also implements the tree
[drag and drop][gtk3-GtkTreeView-drag-and-drop]
interfaces.
# 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 classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionCreates a new tree store as with @n_columns columns each of the types passed
in.TreeStore
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends a new row to @tree_store.Implements interfaceBuildable
.Implements interfaceTreeDragDest
.Implements interfaceTreeDragSource
.Implements interfaceTreeModel
.Implements interfaceTreeSortable
.void
clear()
Removes all rows from @tree_storestatic ClassHandler
static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
void
Creates a new row at @position.void
insertAfter
(TreeIter iter, TreeIter parent, TreeIter sibling) Inserts a new row after @sibling.void
insertBefore
(TreeIter iter, TreeIter parent, TreeIter sibling) Inserts a new row before @sibling.void
insertWithValues
(TreeIter iter, TreeIter parent, int position, Object... _elipse) Creates a new row at @position.boolean
isAncestor
(TreeIter iter, TreeIter descendant) Returns %TRUE if @iter is an ancestor of @descendant.int
Returns the depth of @iter.boolean
iterIsValid
(TreeIter iter) Checks if the given iter is a valid iter for this `GtkTreeStore`.void
Moves @iter in @tree_store to the position after @position.void
moveBefore
(TreeIter iter, TreeIter position) Moves @iter in @tree_store to the position before @position.static TreeStore
newvTreeStore
(int n_columns, Int64 types) Non vararg creation function.void
Prepends a new row to @tree_store.boolean
Removes @iter from @tree_store.void
Reorders the children of @parent in @tree_store to follow the order
indicated by @new_order.void
Sets the value of one or more cells in the row referenced by @iter.void
setColumnTypes
(int n_columns, Int64 types) This function is meant primarily for `GObjects` that inherit from
`GtkTreeStore`, and should only be used when constructing a new
`GtkTreeStore`.void
Sets the data in the cell specified by @iter and @column.void
Swaps @a and @b in the same level of @tree_store.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
TreeStore
-
TreeStore
Creates a new tree store as with @n_columns columns each of the types passed
in. Note that only types derived from standard GObject fundamental types
are supported.
As an example,
```
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.- Parameters:
n_columns
- number of columns in the tree store_elipse
- all `GType` types for the columns, from first to last
-
-
Method Details
-
getClassHandler
-
newvTreeStore
Non vararg creation function. Used primarily by language bindings.- Parameters:
n_columns
- number of columns in the tree storetypes
- an array of `GType` types for the columns, from first to last- Returns:
- a new `GtkTreeStore`
-
append
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. @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_tree_store_set() or gtk_tree_store_set_value().- Parameters:
iter
- An unset `GtkTreeIter` to set to the appended rowparent
- A valid `GtkTreeIter`
-
clear
public void clear()Removes all rows from @tree_store -
insert
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. @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_tree_store_set() or
gtk_tree_store_set_value().- Parameters:
iter
- An unset `GtkTreeIter` to set to the new rowparent
- A valid `GtkTreeIter`position
- position to insert the new row, or -1 for last
-
insertAfter
public void insertAfter(@Nonnull TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter 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.
@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_tree_store_set() or gtk_tree_store_set_value().- Parameters:
iter
- An unset `GtkTreeIter` to set to the new rowparent
- A valid `GtkTreeIter`sibling
- A valid `GtkTreeIter`
-
insertBefore
public void insertBefore(@Nonnull TreeIter iter, @Nullable TreeIter parent, @Nullable TreeIter 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.
@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_tree_store_set() or gtk_tree_store_set_value().- Parameters:
iter
- An unset `GtkTreeIter` to set to the new rowparent
- A valid `GtkTreeIter`sibling
- A valid `GtkTreeIter`
-
insertWithValues
public void insertWithValues(@Nullable TreeIter iter, @Nullable TreeIter parent, int position, Object... _elipse) 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 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<!-- language="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.- Parameters:
iter
- An unset `GtkTreeIter` to set the new rowparent
- A valid `GtkTreeIter`position
- position to insert the new row, or -1 to append after existing rows_elipse
- pairs of column number and value, terminated with -1
-
isAncestor
Returns %TRUE if @iter is an ancestor of @descendant. That is, @iter is the
parent (or grandparent or great-grandparent) of @descendant.- Parameters:
iter
- A valid `GtkTreeIter`descendant
- A valid `GtkTreeIter`- Returns:
- %TRUE, if @iter is an ancestor of @descendant
-
iterDepth
Returns the depth of @iter. This 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 @iter
-
iterIsValid
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, %FALSE if the iter is invalid.
-
moveAfter
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.- Parameters:
iter
- A `GtkTreeIter`.position
- A `GtkTreeIter`.
-
moveBefore
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.- Parameters:
iter
- A `GtkTreeIter`position
- A `GtkTreeIter`
-
prepend
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. @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_tree_store_set() or gtk_tree_store_set_value().- Parameters:
iter
- An unset `GtkTreeIter` to set to the prepended rowparent
- A valid `GtkTreeIter`
-
remove
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.- Parameters:
iter
- A valid `GtkTreeIter`- Returns:
- %TRUE if @iter is still valid, %FALSE if not.
-
reorder
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.- Parameters:
parent
- A `GtkTreeIter`new_order
- 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`.
-
set
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_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.- Parameters:
iter
- A valid `GtkTreeIter` for the row being modified_elipse
- pairs of column number and value, terminated with -1
-
setColumnTypes
This function is meant primarily for `GObjects` that inherit from
`GtkTreeStore`, and should only be used when constructing a new
`GtkTreeStore`. It will not function after a row has been added,
or a method on the `GtkTreeModel` interface is called.- Parameters:
n_columns
- Number of columns for the tree storetypes
- An array of `GType` types, one for each column
-
setValue
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 modifiedcolumn
- column number to modifyvalue
- new value for the cell
-
swap
Swaps @a and @b in the same level of @tree_store. Note that this function
only works with unsorted stores.- Parameters:
a
- A `GtkTreeIter`.b
- Another `GtkTreeIter`.
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Returns:
Buildable
-
asTreeDragDest
Implements interfaceTreeDragDest
. Call this to get access to interface functions.- Returns:
TreeDragDest
-
asTreeDragSource
Implements interfaceTreeDragSource
. Call this to get access to interface functions.- Returns:
TreeDragSource
-
asTreeModel
Implements interfaceTreeModel
. Call this to get access to interface functions.- Returns:
TreeModel
-
asTreeSortable
Implements interfaceTreeSortable
. Call this to get access to interface functions.- Returns:
TreeSortable
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-