Class TreeSelection

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") @Deprecated public class TreeSelection extends GObject
Deprecated.
Use SelectionModel instead

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).

  • Constructor Details

    • TreeSelection

      public TreeSelection(MemorySegment address)
      Deprecated.
      Create a TreeSelection instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • TreeSelection

      public TreeSelection()
      Deprecated.
      Create a new TreeSelection.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Deprecated.
      Get the GType of the TreeSelection class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      Deprecated.
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected TreeSelection asParent()
      Deprecated.
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • countSelectedRows

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

      @Deprecated public SelectionMode getMode()
      Deprecated.
      Use GtkListView or GtkColumnView
      Gets the selection mode for selection. See gtk_tree_selection_set_mode().
      Returns:
      the current selection mode
    • getSelectFunction

      @Deprecated public @Nullable TreeSelectionFunc getSelectFunction()
      Deprecated.
      Use GtkListView or GtkColumnView
      Returns the current selection function.
      Returns:
      The function.
    • getSelected

      @Deprecated public boolean getSelected(@Nullable Out<TreeModel> model, @Nullable TreeIter iter)
      Deprecated.
      Use GtkListView or GtkColumnView
      Sets iter to the currently selected node if this TreeSelection is set to SelectionMode.SINGLE or SelectionMode.BROWSE. iter may be NULL if you just want to test if this TreeSelection has any selected nodes. model is filled with the current model as a convenience. This function will not work if you use this TreeSelection is SelectionMode.MULTIPLE.
      Parameters:
      model - A pointer to set to the GtkTreeModel
      iter - The GtkTreeIter
      Returns:
      TRUE, if there is a selected node.
    • getSelectedRows

      @Deprecated public List<TreePath> getSelectedRows(@Nullable Out<TreeModel> model)
      Deprecated.
      Use GtkListView or GtkColumnView

      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);
      
      Parameters:
      model - A pointer to set to the GtkTreeModel
      Returns:
      A GList containing a GtkTreePath for each selected row.
    • getTreeView

      @Deprecated public TreeView getTreeView()
      Deprecated.
      Use GtkListView or GtkColumnView
      Returns the tree view associated with selection.
      Returns:
      A GtkTreeView
    • getUserData

      @Deprecated public @Nullable MemorySegment getUserData()
      Deprecated.
      Use GtkListView or GtkColumnView
      Returns the user data for the selection function.
      Returns:
      The user data.
    • iterIsSelected

      @Deprecated public boolean iterIsSelected(TreeIter iter)
      Deprecated.
      Use GtkListView or GtkColumnView
      Returns true if the row at iter is currently selected.
      Parameters:
      iter - A valid GtkTreeIter
      Returns:
      true, if iter is selected
    • pathIsSelected

      @Deprecated public boolean pathIsSelected(TreePath path)
      Deprecated.
      Use GtkListView or GtkColumnView
      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

      @Deprecated public void selectAll()
      Deprecated.
      Use GtkListView or GtkColumnView
      Selects all the nodes. this TreeSelection must be set to SelectionMode.MULTIPLE mode.
    • selectIter

      @Deprecated public void selectIter(TreeIter iter)
      Deprecated.
      Use GtkListView or GtkColumnView
      Selects the specified iterator.
      Parameters:
      iter - The GtkTreeIter to be selected.
    • selectPath

      @Deprecated public void selectPath(TreePath path)
      Deprecated.
      Use GtkListView or GtkColumnView
      Select the row at path.
      Parameters:
      path - The GtkTreePath to be selected.
    • selectRange

      @Deprecated public void selectRange(TreePath startPath, TreePath endPath)
      Deprecated.
      Use GtkListView or GtkColumnView
      Selects a range of nodes, determined by startPath and endPath inclusive. this TreeSelection must be set to SelectionMode.MULTIPLE mode.
      Parameters:
      startPath - The initial node of the range.
      endPath - The final node of the range.
    • selectedForeach

      @Deprecated public void selectedForeach(@Nullable TreeSelectionForeachFunc func)
      Deprecated.
      Use GtkListView or GtkColumnView
      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.
    • setMode

      @Deprecated public void setMode(SelectionMode type)
      Deprecated.
      Use GtkListView or GtkColumnView
      Sets the selection mode of the selection. If the previous type was SelectionMode.MULTIPLE, then the anchor is kept selected, if it was previously selected.
      Parameters:
      type - The selection mode
    • setSelectFunction

      @Deprecated public void setSelectFunction(@Nullable TreeSelectionFunc func)
      Deprecated.
      Use GtkListView or GtkColumnView

      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
    • unselectAll

      @Deprecated public void unselectAll()
      Deprecated.
      Use GtkListView or GtkColumnView
      Unselects all the nodes.
    • unselectIter

      @Deprecated public void unselectIter(TreeIter iter)
      Deprecated.
      Use GtkListView or GtkColumnView
      Unselects the specified iterator.
      Parameters:
      iter - The GtkTreeIter to be unselected.
    • unselectPath

      @Deprecated public void unselectPath(TreePath path)
      Deprecated.
      Use GtkListView or GtkColumnView
      Unselects the row at path.
      Parameters:
      path - The GtkTreePath to be unselected.
    • unselectRange

      @Deprecated public void unselectRange(TreePath startPath, TreePath endPath)
      Deprecated.
      Use GtkListView or GtkColumnView
      Unselects a range of nodes, determined by startPath and endPath inclusive.
      Parameters:
      startPath - The initial node of the range.
      endPath - The initial node of the range.
    • onChanged

      Deprecated.
      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.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitChanged

      public void emitChanged()
      Deprecated.
      Emits the "changed" signal. See onChanged(TreeSelection.ChangedCallback).
    • builder

      public static TreeSelection.Builder<? extends TreeSelection.Builder> builder()
      Deprecated.
      A TreeSelection.Builder object constructs a TreeSelection with the specified properties. Use the various set...() methods to set properties, and finish construction with TreeSelection.Builder.build().
      Returns:
      the builder object