## org.gnu.gtk
Class TreeSelection

    java.lang.Object
      org.gnu.glib.GObject
          org.gnu.gtk.TreeSelection

public class TreeSelection
extends GObject

The TreeSelection object is a helper object to manage the selection for a `TreeView` widget. The TreeSelection object is automatically created when a newTreeView widget is created, and cannot exist independentally of this widget. The primary reason the 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 TreeView widget instead of a separate function.

The TreeSelection object is gotten from a TreeView by calling `TreeView.getSelection()`. 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 "changed" event 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 "changed" event when nothing has happened (mostly as a result of programmers calling selectRow on an already selected row).

See Also:
  `TreeView`

Field Summary

Fields inherited from class org.gnu.glib.GObject
`eventsInitialized`

Constructor Summary
`protected` `TreeSelection(Handle handle)` constructs a new selection using handle from a native function..

Method Summary
`void` `addListener(TreeSelectionListener listener)` Register an object to handle Selection change events which are emitted whenever the selection has (possibly) changed
`int` `countRows()` Returns the number of rows that have been selected.
`protected void` `fireSelectionEvent(TreeSelectionEvent event)`
`void` `forEachSelected(TreeSelectionForEach implementor)` Calls the forEach method of the specified class for every selected value.
`java.lang.Class` `getEventListenerClass(java.lang.String signal)`
`EventType` `getEventType(java.lang.String signal)`
`SelectionMode` `getMode()`
`boolean` `getSelected(TreeIter iter)` Returns TRUE if the row pointed to by iter is currently selected.
`boolean` `getSelected(TreePath path)` Returns TRUE if the row pointed to by path is currently selected.
`TreePath[]` `getSelectedRows()` Returns an array of rows which are currently selected
`TreeView` `getTreeView()` Returns the `TreeView` associated with the selection.
`static Type` `getType()` Retrieve the runtime type used by the GLib library.
`protected static int` `gtk_tree_selection_count_selected_rows(Handle selection)`
`protected static int` `gtk_tree_selection_get_mode(Handle selection)`
`protected static Handle[]` `gtk_tree_selection_get_selected_rows(Handle selection)`
`protected static Handle` `gtk_tree_selection_get_tree_view(Handle selection)`
`protected static int` `gtk_tree_selection_get_type()`
`protected static boolean` `gtk_tree_selection_iter_is_selected(Handle selection, Handle iter)`
`protected static boolean` `gtk_tree_selection_path_is_selected(Handle selection, Handle path)`
`protected static void` `gtk_tree_selection_select_all(Handle selection)`
`protected static void` `gtk_tree_selection_select_iter(Handle selection, Handle iter)`
`protected static void` `gtk_tree_selection_select_path(Handle selection, Handle path)`
`protected static void` `gtk_tree_selection_select_range(Handle selection, Handle startPath, Handle endPath)`
`protected static void` `gtk_tree_selection_set_mode(Handle selection, int type)`
`protected static void` `gtk_tree_selection_unselect_all(Handle selection)`
`protected static void` `gtk_tree_selection_unselect_iter(Handle selection, Handle iter)`
`protected static void` `gtk_tree_selection_unselect_path(Handle selection, Handle path)`
`protected static void` `gtk_tree_selection_unselect_range(Handle selection, Handle startPath, Handle endPath)`
`void` `removeListener(TreeSelectionListener listener)` Removes a listener
`void` `select(TreeIter iter)` Selects the specified iterator.
`void` `select(TreePath path)` Select the row at path.
`void` `select(TreePath startPath, TreePath endPath)` Selects a range of nodes, determined by startPath and endPath inclusive.
`void` `selectAll()` Selects all the nodes.
`void` `setMode(SelectionMode mode)` Sets the selection mode of the selection.
`void` `unselect(TreeIter iter)` Unselects the specified iterator.
`void` `unselect(TreePath path)` Unselects the row at path.
`void` `unselect(TreePath startPath, TreePath endPath)`
`void` `unselectAll()` Unselects all the nodes.

Methods inherited from class org.gnu.glib.GObject

`addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, equals, freezeNotify, getBooleanProperty, getData, getData, getDoubleProperty, getFloatProperty, getGObjectFromHandle, getHandle, getIntFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getNullHandle, getPixbufProperty, getProperty, getStringFromHandle, getStringProperty, hashCode, hasProperty, instantiateJGObjectFromGType, notify, removeEventHandler, removeListener, retrieveGObject, setBooleanProperty, setData, setData, setDoubleProperty, setFloatProperty, setHandle, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TreeSelection

    protected TreeSelection(Handle handle)

  constructs a new selection using handle from a native function..

Method Detail

### forEachSelected

    public void forEachSelected(TreeSelectionForEach implementor)

  Calls the forEach method of the specified class for every selected value.

### setMode

    public void setMode(SelectionMode mode)

  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:
    `mode` - The selection mode to use.

### getMode

    public SelectionMode getMode()

### getTreeView

    public TreeView getTreeView()

  Returns the `TreeView` associated with the selection.

  Returns:
    Associated widget

### select

    public void select(TreePath path)

  Select the row at path.

  Parameters:
    `path` - The path to be selected.

### unselect

    public void unselect(TreePath path)

  Unselects the row at path.

  Parameters:
    `path` - The path to be deselected

### getSelected

    public boolean getSelected(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 patch to check the selection on
  Returns:
    True if the path is selected.

### select

    public void select(TreeIter iter)

  Selects the specified iterator.

  Parameters:
    `iter` - The `TreeIter` to be selected.

### unselect

    public void unselect(TreeIter iter)

  Unselects the specified iterator.

  Parameters:
    `iter` - The `TreeIter` to be unselected.

### getSelected

    public boolean getSelected(TreeIter iter)

  Returns TRUE if the row pointed to by iter is currently selected.

  Parameters:
    `iter` - The iter to test the selection of
  Returns:
    true if the iter is selected.

### selectAll

    public void selectAll()

  Selects all the nodes. Mode must be set to SelectionMode.MULTIPLE

### unselectAll

    public void unselectAll()

  Unselects all the nodes.

### select

    public void select(TreePath startPath,
                       TreePath endPath)

  Selects a range of nodes, determined by startPath and endPath inclusive.

  Parameters:
    `startPath` - The initial node of the range.
    `endPath` - The final node of the range.

### unselect

    public void unselect(TreePath startPath,
                         TreePath endPath)

### getSelectedRows

    public TreePath[] getSelectedRows()

  Returns an array of rows which are currently selected

  Since:
    2.2

### countRows

    public int countRows()

  Returns the number of rows that have been selected.

  Since:
    2.2

### addListener

    public void addListener(TreeSelectionListener listener)

  Register an object to handle Selection change events which are emitted whenever the selection has (possibly) changed

  See Also:
    `TreeSelectionListener`

### removeListener

    public void removeListener(TreeSelectionListener listener)

  Removes a listener

  See Also:
    `addListener(TreeSelectionListener)`

### fireSelectionEvent

    protected void fireSelectionEvent(TreeSelectionEvent event)

### getEventListenerClass

    public java.lang.Class getEventListenerClass(java.lang.String signal)

  Overrides:
    `getEventListenerClass` in class `GObject`

### getEventType

    public EventType getEventType(java.lang.String signal)

  Overrides:
    `getEventType` in class `GObject`

### getType

    public static Type getType()

  Retrieve the runtime type used by the GLib library.

### gtk_tree_selection_get_type

    protected static final int gtk_tree_selection_get_type()

### gtk_tree_selection_set_mode

    protected static final void gtk_tree_selection_set_mode(Handle selection,
                                                            int type)

### gtk_tree_selection_get_mode

    protected static final int gtk_tree_selection_get_mode(Handle selection)

### gtk_tree_selection_get_tree_view

    protected static final Handle gtk_tree_selection_get_tree_view(Handle selection)

### gtk_tree_selection_get_selected_rows

    protected static final Handle[] gtk_tree_selection_get_selected_rows(Handle selection)

### gtk_tree_selection_count_selected_rows

    protected static final int gtk_tree_selection_count_selected_rows(Handle selection)

### gtk_tree_selection_select_path

    protected static final void gtk_tree_selection_select_path(Handle selection,
                                                               Handle path)

### gtk_tree_selection_unselect_path

    protected static final void gtk_tree_selection_unselect_path(Handle selection,
                                                                 Handle path)

### gtk_tree_selection_select_iter

    protected static final void gtk_tree_selection_select_iter(Handle selection,
                                                               Handle iter)

### gtk_tree_selection_unselect_iter

    protected static final void gtk_tree_selection_unselect_iter(Handle selection,
                                                                 Handle iter)

### gtk_tree_selection_path_is_selected

    protected static final boolean gtk_tree_selection_path_is_selected(Handle selection,
                                                                       Handle path)

### gtk_tree_selection_iter_is_selected

    protected static final boolean gtk_tree_selection_iter_is_selected(Handle selection,
                                                                       Handle iter)

### gtk_tree_selection_select_all

    protected static final void gtk_tree_selection_select_all(Handle selection)

### gtk_tree_selection_unselect_all

    protected static final void gtk_tree_selection_unselect_all(Handle selection)

### gtk_tree_selection_select_range

    protected static final void gtk_tree_selection_select_range(Handle selection,
                                                                Handle startPath,
                                                                Handle endPath)

### gtk_tree_selection_unselect_range

    protected static final void gtk_tree_selection_unselect_range(Handle selection,
                                                                  Handle startPath,
                                                                  Handle endPath)