class Gtk::TreeSelection
- Gtk::TreeSelection
- GObject::Object
- Reference
- Object
Overview
The selection object for Gtk::TreeView
The Gtk::TreeSelection
object is a helper object to manage the selection
for a Gtk::TreeView
widget. The Gtk::TreeSelection
object is
automatically created when a new Gtk::TreeView
widget is created, and
cannot exist independently of this widget. The primary reason the
Gtk::TreeSelection
objects exists is for cleanliness of code and API.
That is, there is no conceptual reason all these functions could not be
methods on the Gtk::TreeView
widget instead of a separate function.
The Gtk::TreeSelection
object is gotten from a Gtk::TreeView
by calling
gtk_tree_view_get_selection(). It can be manipulated to check the
selection status of the tree, as well as select and deselect individual
rows. Selection is done completely view side. As a result, multiple
views of the same model can have completely different selections.
Additionally, you cannot change the selection of a row on the model that
is not currently displayed by the view without expanding its parents
first.
One of the important things to remember when monitoring the selection of
a view is that the Gtk::TreeSelection
::changed signal is mostly a hint.
That is, it may only emit one signal when a range of rows is selected.
Additionally, it may on occasion emit a Gtk::TreeSelection
::changed signal
when nothing has happened (mostly as a result of programmers calling
select_row on an already selected row).
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/tree_selection.crbindings/gtk/tree_selection.cr
Constructors
-
.new
Initialize a new
TreeSelection
. - .new(*, mode : Gtk::SelectionMode | Nil = nil)
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. - #changed_signal
-
#count_selected_rows : Int32
Returns the number of rows that have been selected in tree.
-
#hash(hasher)
See
Object#hash(hasher)
-
#iter_is_selected(iter : Gtk::TreeIter) : Bool
Returns
true
if the row at iter is currently selected. -
#mode : Gtk::SelectionMode
Gets the selection mode for selection.
-
#mode=(type : Gtk::SelectionMode) : Nil
Sets the selection mode of the selection.
-
#path_is_selected(path : Gtk::TreePath) : Bool
Returns
true
if the row pointed to by path is currently selected. -
#select_all : Nil
Selects all the nodes.
-
#select_function=(func : Gtk::TreeSelectionFunc | Nil) : Nil
Sets the selection function.
-
#select_iter(iter : Gtk::TreeIter) : Nil
Selects the specified iterator.
-
#select_path(path : Gtk::TreePath) : Nil
Select the row at path.
-
#select_range(start_path : Gtk::TreePath, end_path : Gtk::TreePath) : Nil
Selects a range of nodes, determined by start_path and end_path inclusive.
- #select_row(row : Int32) : Nil
-
#selected : Gtk::TreeIter
Sets iter to the currently selected node if selection is set to %GTK_SELECTION_SINGLE or %GTK_SELECTION_BROWSE.
-
#selected_foreach(func : Gtk::TreeSelectionForeachFunc, data : Pointer(Void) | Nil) : Nil
Calls a function for each selected node.
-
#selected_rows : GLib::List
Creates a list of path of all selected rows.
-
#tree_view : Gtk::TreeView
Returns the tree view associated with selection.
-
#unselect_all : Nil
Unselects all the nodes.
-
#unselect_iter(iter : Gtk::TreeIter) : Nil
Unselects the specified iterator.
-
#unselect_path(path : Gtk::TreePath) : Nil
Unselects the row at path.
-
#unselect_range(start_path : Gtk::TreePath, end_path : Gtk::TreePath) : Nil
Unselects a range of nodes, determined by start_path and end_path inclusive.
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
Class Method Detail
Returns the type id (GType) registered in GLib type system.
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Returns the number of rows that have been selected in tree.
Returns true
if the row at iter is currently selected.
Gets the selection mode for selection. See gtk_tree_selection_set_mode().
Sets the selection mode of the selection. If the previous type was %GTK_SELECTION_MULTIPLE, then the anchor is kept selected, if it was previously selected.
Returns true
if the row pointed to by path is currently selected. If path
does not point to a valid location, false
is returned
Selects all the nodes. selection must be set to %GTK_SELECTION_MULTIPLE mode.
Sets the selection function.
If set, this function is called before any node is selected or unselected,
giving some control over which nodes are selected. The select function
should return true
if the state of the node may be toggled, and false
if the state of the node should be left unchanged.
Selects a range of nodes, determined by start_path and end_path inclusive. selection must be set to %GTK_SELECTION_MULTIPLE mode.
Sets iter to the currently selected node if selection is set to %GTK_SELECTION_SINGLE or %GTK_SELECTION_BROWSE. iter may be NULL if you just want to test if selection has any selected nodes. model is filled with the current model as a convenience. This function will not work if you use selection is %GTK_SELECTION_MULTIPLE.
Calls a function for each selected node. Note that you cannot modify the tree or selection from within this function. As a result, gtk_tree_selection_get_selected_rows() might be more useful.
Creates a list of path of all selected rows. Additionally, if you are
planning on modifying the model after calling this function, you may
want to convert the returned list into a list of Gtk::TreeRowReference
s.
To do this, you can use gtk_tree_row_reference_new().
To free the return value, use: |[ g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); ]|
Unselects a range of nodes, determined by start_path and end_path inclusive.