class Gtk::TreeStore
- Gtk::TreeStore
- GObject::Object
- Reference
- Object
Overview
A tree-like data structure that can be used with the Gtk::TreeView
.
The Gtk::TreeStore
object is a list model for use with a Gtk::TreeView
widget. It implements the Gtk::TreeModel
interface, and consequently,
can use all of the methods available there. It also implements the
Gtk::TreeSortable
interface so it can be sorted by the view.
Finally, it also implements the tree [drag]Gtk::TreeDragSource
and [drop]Gtk::TreeDragDest
interfaces.
Gtk::TreeStore
is deprecated since GTK 4.10, and should not be used in newly
written code. You should use Gtk::TreeListModel
for a tree-like model
object.
Gtk::TreeStore as Gtk::Buildable
The Gtk::TreeStore implementation of the Gtk::Buildable
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:
WARNING ⚠️ The following code is in xml ⚠️
<object class="Gtk::TreeStore">
<columns>
<column type="gchararray"/>
<column type="gchararray"/>
<column type="gint"/>
</columns>
</object>
Included Modules
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/tree_store.crlib/gtk4/src/bindings/gtk/tree_store.cr
Constructors
-
.new(types : Enumerable(UInt64)) : self
Creates a new tree store.
DEPRECATED
-
.new
Initialize a new
TreeStore
. - .new(*types : UInt64)
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#append(parent : Gtk::TreeIter | Nil) : Gtk::TreeIter
Appends a new row to tree_store.
DEPRECATED
-
#clear : Nil
Removes all rows from tree_store
DEPRECATED
-
#column_types=(types : Enumerable(UInt64)) : Nil
Sets the type of the columns in a tree store.
DEPRECATED
-
#hash(hasher)
See
Object#hash(hasher)
-
#insert(parent : Gtk::TreeIter | Nil, position : Int32) : Gtk::TreeIter
Creates a new row at position.
DEPRECATED
-
#insert_after(parent : Gtk::TreeIter | Nil, sibling : Gtk::TreeIter | Nil) : Gtk::TreeIter
Inserts a new row after sibling.
DEPRECATED
-
#insert_before(parent : Gtk::TreeIter | Nil, sibling : Gtk::TreeIter | Nil) : Gtk::TreeIter
Inserts a new row before sibling.
DEPRECATED
-
#insert_with_values(parent : Gtk::TreeIter | Nil, position : Int32, columns : Enumerable(Int32), values : Enumerable(_)) : Gtk::TreeIter
Creates a new row at the given position.
DEPRECATED
-
#is_ancestor(iter : Gtk::TreeIter, descendant : Gtk::TreeIter) : Bool
Checks if iter is an ancestor of descendant.
DEPRECATED
-
#iter_depth(iter : Gtk::TreeIter) : Int32
Returns the depth of the position pointed by the iterator
DEPRECATED
-
#iter_is_valid(iter : Gtk::TreeIter) : Bool
Checks if the given iter is a valid iter for this
Gtk::TreeStore
.DEPRECATED
-
#move_after(iter : Gtk::TreeIter, position : Gtk::TreeIter | Nil) : Nil
Moves iter in tree_store to the position after position.
DEPRECATED
-
#move_before(iter : Gtk::TreeIter, position : Gtk::TreeIter | Nil) : Nil
Moves iter in tree_store to the position before position.
DEPRECATED
-
#prepend(parent : Gtk::TreeIter | Nil) : Gtk::TreeIter
Prepends a new row to tree_store.
DEPRECATED
-
#remove(iter : Gtk::TreeIter) : Bool
Removes iter from tree_store.
DEPRECATED
-
#set(iter : Gtk::TreeIter, columns : Enumerable(Int32), values : Enumerable(_)) : Nil
Sets the value of one or more cells in the row referenced by iter.
DEPRECATED
-
#set_value(iter : Gtk::TreeIter, column : Int32, value : _) : Nil
Sets the data in the cell specified by iter and column.
DEPRECATED
-
#swap(a : Gtk::TreeIter, b : Gtk::TreeIter) : Nil
Swaps a and b in the same level of tree_store.
DEPRECATED
Instance methods inherited from module Gtk::TreeSortable
default_sort_func=(sort_func : Gtk::TreeIterCompareFunc) : Nil
default_sort_func=,
has_default_sort_func : Bool
has_default_sort_func,
set_sort_column_id(sort_column_id : Int32, order : Gtk::SortType) : Nil
set_sort_column_id,
set_sort_func(sort_column_id : Int32, sort_func : Gtk::TreeIterCompareFunc) : Nil
set_sort_func,
sort_column_changed : Nil
sort_column_changed,
sort_column_changed_signal
sort_column_changed_signal,
sort_column_id(sort_column_id : Int32, order : Gtk::SortType) : Bool
sort_column_id,
to_unsafe
to_unsafe
Constructor methods inherited from module Gtk::TreeSortable
cast(obj : GObject::Object) : self
cast
Class methods inherited from module Gtk::TreeSortable
cast?(obj : GObject::Object) : self | Nil
cast?,
g_type : UInt64
g_type
Instance methods inherited from module Gtk::TreeModel
column_type(index_ : Int32) : UInt64
column_type,
filter_new(root : Gtk::TreePath | Nil) : Gtk::TreeModel
filter_new,
flags : Gtk::TreeModelFlags
flags,
foreach(func : Gtk::TreeModelForeachFunc, user_data : Pointer(Void) | Nil) : Nil
foreach,
iter(path : Gtk::TreePath) : Gtk::TreeIter
iter,
iter_children(parent : Gtk::TreeIter | Nil) : Gtk::TreeIter
iter_children,
iter_first : Gtk::TreeIter
iter_first,
iter_from_string(path_string : String) : Gtk::TreeIter
iter_from_string,
iter_has_child(iter : Gtk::TreeIter) : Bool
iter_has_child,
iter_n_children(iter : Gtk::TreeIter | Nil) : Int32
iter_n_children,
iter_next(iter : Gtk::TreeIter) : Bool
iter_next,
iter_nth_child(parent : Gtk::TreeIter | Nil, n : Int32) : Gtk::TreeIter
iter_nth_child,
iter_parent(child : Gtk::TreeIter) : Gtk::TreeIter
iter_parent,
iter_previous(iter : Gtk::TreeIter) : Bool
iter_previous,
n_columns : Int32
n_columns,
path(iter : Gtk::TreeIter) : Gtk::TreePath
path,
ref_node(iter : Gtk::TreeIter) : Nil
ref_node,
row_changed(path : Gtk::TreePath, iter : Gtk::TreeIter) : Nil
row_changed,
row_changed_signal
row_changed_signal,
row_deleted(path : Gtk::TreePath) : Nil
row_deleted,
row_deleted_signal
row_deleted_signal,
row_has_child_toggled(path : Gtk::TreePath, iter : Gtk::TreeIter) : Nil
row_has_child_toggled,
row_has_child_toggled_signal
row_has_child_toggled_signal,
row_inserted(path : Gtk::TreePath, iter : Gtk::TreeIter) : Nil
row_inserted,
row_inserted_signal
row_inserted_signal,
rows_reordered(path : Gtk::TreePath, iter : Gtk::TreeIter | Nil, new_order : Enumerable(Int32)) : Nil
rows_reordered,
string_from_iter(iter : Gtk::TreeIter) : String | Nil
string_from_iter,
to_unsafe
to_unsafe,
unref_node(iter : Gtk::TreeIter) : Nil
unref_node,
value(iter : Gtk::TreeIter, column : Int32) : GObject::Value
value
Constructor methods inherited from module Gtk::TreeModel
cast(obj : GObject::Object) : self
cast
Class methods inherited from module Gtk::TreeModel
cast?(obj : GObject::Object) : self | Nil
cast?,
g_type : UInt64
g_type
Instance methods inherited from module Gtk::TreeDragSource
drag_data_delete(path : Gtk::TreePath) : Bool
drag_data_delete,
drag_data_get(path : Gtk::TreePath) : Gdk::ContentProvider | Nil
drag_data_get,
row_draggable(path : Gtk::TreePath) : Bool
row_draggable,
to_unsafe
to_unsafe
Constructor methods inherited from module Gtk::TreeDragSource
cast(obj : GObject::Object) : self
cast
Class methods inherited from module Gtk::TreeDragSource
cast?(obj : GObject::Object) : self | Nil
cast?,
g_type : UInt64
g_type
Instance methods inherited from module Gtk::TreeDragDest
drag_data_received(dest : Gtk::TreePath, value : _) : Bool
drag_data_received,
row_drop_possible(dest_path : Gtk::TreePath, value : _) : Bool
row_drop_possible,
to_unsafe
to_unsafe
Constructor methods inherited from module Gtk::TreeDragDest
cast(obj : GObject::Object) : self
cast
Class methods inherited from module Gtk::TreeDragDest
cast?(obj : GObject::Object) : self | Nil
cast?,
g_type : UInt64
g_type
Instance methods inherited from module Gtk::Buildable
buildable_id : String | Nil
buildable_id,
to_unsafe
to_unsafe
Constructor methods inherited from module Gtk::Buildable
cast(obj : GObject::Object) : self
cast
Class methods inherited from module Gtk::Buildable
cast?(obj : GObject::Object) : self | Nil
cast?,
g_type : UInt64
g_type
Instance methods inherited from class GObject::Object
==(other : self)
==,
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void) | Nil
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
hash(hasher)
hash,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void) | Nil
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void) | Nil) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void) | Nil
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void) | Nil
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
cast?(obj : GObject::Object) : self | Nil
cast?,
compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Macros inherited from class GObject::Object
previous_vfunc(*args)
previous_vfunc,
previous_vfunc!(*args)
previous_vfunc!,
signal(signature)
signal
Constructor Detail
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:
WARNING ⚠️ The following code is in c ⚠️
gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_TEXTURE);
will create a new Gtk::TreeStore
with three columns of type
int
, gchararray
, and Gdk::Texture
respectively.
DEPRECATED
Class Method Detail
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Appends a new row to tree_store.
If parent is non-nil
, 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().
DEPRECATED
Sets the type of the columns in a tree store.
This function is meant primarily for types that inherit from
Gtk::TreeStore
, and should only be used when constructing a new
Gtk::TreeStore
.
This functions cannot be called after a row has been added,
or a method on the Gtk::TreeModel
interface is called on the
tree store.
DEPRECATED
Creates a new row at position.
If parent is non-nil
, 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().
DEPRECATED
Inserts a new row after sibling.
If sibling is nil
, then the row will be prepended to parent’s children.
If parent and sibling are nil
, 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().
DEPRECATED
Inserts a new row before sibling.
If sibling is nil
, then the row will be appended to parent’s children.
If parent and sibling are nil
, 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().
DEPRECATED
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
WARNING ⚠️ The following code is in 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.
DEPRECATED
Checks if iter is an ancestor of descendant.
DEPRECATED
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.
DEPRECATED
Checks if the given iter is a valid iter for this Gtk::TreeStore
.
This function is slow. Only use it for debugging and/or testing purposes.
DEPRECATED
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 nil
, iter will be moved to the start of the level.
DEPRECATED
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 nil
, iter will be moved to the end of the level.
DEPRECATED
Prepends a new row to tree_store.
If parent is non-nil
, 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().
DEPRECATED
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.
DEPRECATED
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
WARNING ⚠️ The following code is in 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
.
DEPRECATED
Sets the data in the cell specified by iter and column.
The type of value must be convertible to the type of the column.
DEPRECATED
Swaps a and b in the same level of tree_store.
Note that this function only works with unsorted stores.
DEPRECATED