Class: Gtk::TreeSelection
- Inherits:
-
Object
- Object
- Gtk::TreeSelection
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gtk4/deprecated.rb,
lib/gtk4/tree-selection.rb
Overview
The selection object for GtkTreeView
The GtkTreeSelection object is a helper object to manage the selection
for a GtkTreeView widget. The GtkTreeSelection object is
automatically created when a new GtkTreeView widget is created, and
cannot exist independently of this widget. The primary reason the
GtkTreeSelection 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 GtkTreeView widget instead of a separate function.
The GtkTreeSelection object is gotten from a GtkTreeView 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 GtkTreeSelection::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 GtkTreeSelection::changed signal
when nothing has happened (mostly as a result of programmers calling
select_row on an already selected row).
Instance Method Summary collapse
-
#count_selected_rows ⇒ Integer
Returns the number of rows that have been selected in tree.
-
#get_selected(model, iter) ⇒ Boolean
Sets iter to the currently selected node if selection is set to %GTK_SELECTION_SINGLE or %GTK_SELECTION_BROWSE.
-
#get_selected_rows(model) ⇒ GLib::List<Gtk::TreePath>
Creates a list of path of all selected rows.
-
#iter_is_selected(iter) ⇒ Boolean
Returns true if the row at iter is currently selected.
-
#mode ⇒ Gtk::SelectionMode
Selection mode.
-
#mode=(mode) ⇒ Gtk::SelectionMode
Selection mode.
-
#path_is_selected(path) ⇒ Boolean
Returns true if the row pointed to by path is currently selected.
-
#select_all ⇒ nil
Selects all the nodes.
-
#select_function ⇒ Gtk::TreeSelectionFunc
Returns the current selection function.
-
#select_iter(iter) ⇒ nil
Selects the specified iterator.
-
#select_path(path) ⇒ nil
Select the row at path.
-
#select_range(start_path, end_path) ⇒ nil
Selects a range of nodes, determined by start_path and end_path inclusive.
- #selected ⇒ Object
-
#selected_foreach(func, data) ⇒ nil
Calls a function for each selected node.
- #selected_raw ⇒ Object
-
#set_select_function(func, data, destroy) ⇒ nil
Sets the selection function.
-
#tree_view ⇒ Gtk::TreeView
Returns the tree view associated with selection.
-
#unselect_all ⇒ nil
Unselects all the nodes.
-
#unselect_iter(iter) ⇒ nil
Unselects the specified iterator.
-
#unselect_path(path) ⇒ nil
Unselects the row at path.
-
#unselect_range(start_path, end_path) ⇒ nil
Unselects a range of nodes, determined by start_path and end_path inclusive.
-
#user_data ⇒ GObject
Returns the user data for the selection function.
Instance Method Details
#count_selected_rows ⇒ Integer
Returns the number of rows that have been selected in tree.
#get_selected(model, iter) ⇒ Boolean
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.
#get_selected_rows(model) ⇒ GLib::List<Gtk::TreePath>
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 GtkTreeRowReferences.
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);
#iter_is_selected(iter) ⇒ Boolean
Returns true if the row at iter is currently selected.
#mode ⇒ Gtk::SelectionMode
Selection mode. See gtk_tree_selection_set_mode() for more information on this property.
#mode=(mode) ⇒ Gtk::SelectionMode
Selection mode. See gtk_tree_selection_set_mode() for more information on this property.
#path_is_selected(path) ⇒ Boolean
Returns true if the row pointed to by path is currently selected. If path does not point to a valid location, false is returned
#select_all ⇒ nil
Selects all the nodes. selection must be set to %GTK_SELECTION_MULTIPLE mode.
#select_function ⇒ Gtk::TreeSelectionFunc
Returns the current selection function.
#select_iter(iter) ⇒ nil
Selects the specified iterator.
#select_path(path) ⇒ nil
Select the row at path.
#select_range(start_path, end_path) ⇒ nil
Selects a range of nodes, determined by start_path and end_path inclusive. selection must be set to %GTK_SELECTION_MULTIPLE mode.
#selected ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/gtk4/tree-selection.rb', line 20 def selected selected_p, model, iter = selected_raw return nil unless selected_p iter.model = model iter end |
#selected_foreach(func, data) ⇒ nil
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.
#selected_raw ⇒ Object
19 |
# File 'lib/gtk4/tree-selection.rb', line 19 alias_method :selected_raw, :selected |
#set_select_function(func, data, destroy) ⇒ nil
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.
#tree_view ⇒ Gtk::TreeView
Returns the tree view associated with selection.
#unselect_all ⇒ nil
Unselects all the nodes.
#unselect_iter(iter) ⇒ nil
Unselects the specified iterator.
#unselect_path(path) ⇒ nil
Unselects the row at path.
#unselect_range(start_path, end_path) ⇒ nil
Unselects a range of nodes, determined by start_path and end_path inclusive.
#user_data ⇒ GObject
Returns the user data for the selection function.