Class TreeSelection

All Implemented Interfaces:
PointerInterface

public class TreeSelection extends Object
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).

https://docs.gtk.org/gtk4/class.TreeSelection.html

  • Field Details

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • countSelectedRows

      public int countSelectedRows()
      Returns the number of rows that have been selected in @tree.
      Returns:
      The number of rows selected.
    • getMode

      public int getMode()
      Gets the selection mode for @selection. See
      gtk_tree_selection_set_mode().
      Returns:
      the current selection mode
    • getTreeView

      public TreeView getTreeView()
      Returns the tree view associated with @selection.
      Returns:
      A `GtkTreeView`
    • getUserData

      public Pointer getUserData()
      Returns the user data for the selection function.
      Returns:
      The user data.
    • iterIsSelected

      public boolean iterIsSelected(@Nonnull TreeIter iter)
      Returns %TRUE if the row at @iter is currently selected.
      Parameters:
      iter - A valid `GtkTreeIter`
      Returns:
      %TRUE, if @iter is selected
    • pathIsSelected

      public boolean pathIsSelected(@Nonnull TreePath path)
      Returns %TRUE if the row pointed to by @path is currently selected. If @path
      does not point to a valid location, %FALSE is returned
      Parameters:
      path - A `GtkTreePath` to check selection on.
      Returns:
      %TRUE if @path is selected.
    • selectAll

      public void selectAll()
      Selects all the nodes. @selection must be set to %GTK_SELECTION_MULTIPLE
      mode.
    • selectIter

      public void selectIter(@Nonnull TreeIter iter)
      Selects the specified iterator.
      Parameters:
      iter - The `GtkTreeIter` to be selected.
    • selectPath

      public void selectPath(@Nonnull TreePath path)
      Select the row at @path.
      Parameters:
      path - The `GtkTreePath` to be selected.
    • selectRange

      public void selectRange(@Nonnull TreePath start_path, @Nonnull TreePath end_path)
      Selects a range of nodes, determined by @start_path and @end_path inclusive.
      @selection must be set to %GTK_SELECTION_MULTIPLE mode.
      Parameters:
      start_path - The initial node of the range.
      end_path - The final node of the range.
    • selectedForeach

      public void selectedForeach(TreeSelection.OnTreeSelectionForeachFunc func, @Nullable Pointer data)
      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.
      Parameters:
      func - The function to call for each selected node.
      data - user data to pass to the function.
    • setMode

      public void setMode(int type)
      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.
      Parameters:
      type - The selection mode
    • setSelectFunction

      public void setSelectFunction(TreeSelection.OnTreeSelectionFunc func, @Nullable Pointer data, TreeSelection.OnDestroyNotify destroy)
      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.
      Parameters:
      func - The selection function. May be %NULL
      data - The selection function’s data. May be %NULL
      destroy - The destroy function for user data. May be %NULL
    • unselectAll

      public void unselectAll()
      Unselects all the nodes.
    • unselectIter

      public void unselectIter(@Nonnull TreeIter iter)
      Unselects the specified iterator.
      Parameters:
      iter - The `GtkTreeIter` to be unselected.
    • unselectPath

      public void unselectPath(@Nonnull TreePath path)
      Unselects the row at @path.
      Parameters:
      path - The `GtkTreePath` to be unselected.
    • unselectRange

      public void unselectRange(@Nonnull TreePath start_path, @Nonnull TreePath end_path)
      Unselects a range of nodes, determined by @start_path and @end_path
      inclusive.
      Parameters:
      start_path - The initial node of the range.
      end_path - The initial node of the range.
    • onChanged

      public SignalHandler onChanged(TreeSelection.OnChanged signal)
      Connect to signal "changed".
      See TreeSelection.OnChanged.onChanged() for signal description.
      Field SIGNAL_ON_CHANGED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()