Gnome::Gtk4::TreeSelection
Description
The selection object for GtkTreeView
The Gnome::Gtk4::TreeSelection object is a helper object to manage the selection for a Gnome::Gtk4::TreeView widget. The Gnome::Gtk4::TreeSelection object is automatically created when a new Gnome::Gtk4::TreeView widget is created, and cannot exist independently of this widget. The primary reason the Gnome::Gtk4::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 Gnome::Gtk4::TreeView widget instead of a separate function.
The Gnome::Gtk4::TreeSelection object is gotten from a Gnome::Gtk4::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 Gnome::Gtk4::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 Gnome::Gtk4::TreeSelection::changed signal when nothing has happened (mostly as a result of programmers calling select_row on an already selected row).
Class initialization
Note: The native version of this class is deprecated in gtk4-lib() since version 4.10
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
Methods
count-selected-rows
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Returns the number of rows that have been selected in $tree
.
method count-selected-rows (--> Int )
Return value; The number of rows selected..
get-mode
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Gets the selection mode for $selection
. See .set-mode()
.
method get-mode (--> GtkSelectionMode )
Return value; the current selection mode.
get-select-function
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Returns the current selection function.
method get-select-function (--> )
Return value; The function..
get-selected
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
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
.
method get-selected ( N-Object() $model, N-Object $iter --> Bool )
$model; A pointer to set to the Gnome::Gtk4::R-TreeModel.
$iter; The Gnome::Gtk4::N-TreeIter
Return value; TRUE, if there is a selected node..
get-selected-rows
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
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 Gnome::Gtk4::N-TreeRowReferences. To do this, you can use gtk_tree_row_reference_new().
To free the return value, use:
method get-selected-rows ( N-Object() $model --> N-List )
$model; A pointer to set to the Gnome::Gtk4::R-TreeModel.
Return value; A Gnome::Glib::N-List containing a Gnome::Gtk4::N-TreePath for each selected row..
get-tree-view
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Returns the tree view associated with $selection
.
method get-tree-view (--> N-Object )
Return value; A Gnome::Gtk4::TreeView.
get-user-data
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Returns the user data for the selection function.
method get-user-data (--> gpointer )
Return value; The user data..
iter-is-selected
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Returns True
if the row at $iter
is currently selected.
method iter-is-selected ( N-Object $iter --> Bool )
$iter; A valid Gnome::Gtk4::N-TreeIter
Return value; True
, if $iter
is selected.
path-is-selected
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Returns True
if the row pointed to by $path
is currently selected. If $path
does not point to a valid location, False
is returned
method path-is-selected ( N-Object $path --> Bool )
$path; A Gnome::Gtk4::N-TreePath to check selection on.
Return value; True
if $path
is selected..
select-all
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Selects all the nodes. $selection
must be set to GTK_SELECTION_MULTIPLE
mode.
method select-all ( )
select-iter
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Selects the specified iterator.
method select-iter ( N-Object $iter )
$iter; The Gnome::Gtk4::N-TreeIter to be selected.
select-path
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Select the row at $path
.
method select-path ( N-Object $path )
$path; The Gnome::Gtk4::N-TreePath to be selected.
select-range
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Selects a range of nodes, determined by $start-path
and $end-path
inclusive. $selection
must be set to GTK_SELECTION_MULTIPLE
mode.
method select-range ( N-Object $start-path, N-Object $end-path )
$start-path; The initial node of the range.
$end-path; The final node of the range.
selected-foreach
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Calls a function for each selected node. Note that you cannot modify the tree or selection from within this function. As a result, .get-selected-rows()
might be more useful.
method selected-foreach ( &func, gpointer $data )
&func; The function to call for each selected node.. Tthe function must be specified with following signature;
:( N-Object $model, N-Object $path, N-Object $iter, gpointer $data )
.$data; user data to pass to the function..
set-mode
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
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.
method set-mode ( GtkSelectionMode $type )
$type; The selection mode.
set-select-function This function is not yet available
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
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.
method set-select-function ( &func, gpointer $data, … )
&func; The selection function. May be undefined. Tthe function must be specified with following signature;
:( N-Object $selection, N-Object $model, N-Object $path, gboolean $path-currently-selected, gpointer $data --
gboolean )>.$data; The selection function’s data. May be undefined.
destroy; The destroy function for user data. May be undefined. Note that each argument must be specified as a type followed by its value!
unselect-all
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Unselects all the nodes.
method unselect-all ( )
unselect-iter
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Unselects the specified iterator.
method unselect-iter ( N-Object $iter )
$iter; The Gnome::Gtk4::N-TreeIter to be unselected.
unselect-path
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Unselects the row at $path
.
method unselect-path ( N-Object $path )
$path; The Gnome::Gtk4::N-TreePath to be unselected.
unselect-range
Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10
Unselects a range of nodes, determined by $start-path
and $end-path
inclusive.
method unselect-range ( N-Object $start-path, N-Object $end-path )
$start-path; The initial node of the range.
$end-path; The initial node of the range.
Signals
changed
Emitted whenever the selection has (possibly) changed. Please note that this signal is mostly a hint. It may only be emitted once when a range of rows are selected, and it may occasionally be emitted when nothing has happened.
method handler ( Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::TreeSelection :$_widget, *C<user>-options )
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::TreeSelection object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.