Package ch.bailu.gtk.gtk
Class TreeSelection
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gtk.TreeSelection
- All Implemented Interfaces:
PointerInterface
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).
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).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the number of rows that have been selected in @tree.static ClassHandler
static int
int
getMode()
Gets the selection mode for @selection.static long
static TypeSystem.TypeSize
Returns the tree view associated with @selection.static long
static TypeSystem.TypeSize
Returns the user data for the selection function.boolean
iterIsSelected
(TreeIter iter) Returns %TRUE if the row at @iter is currently selected.onChanged
(TreeSelection.OnChanged signal) Connect to signal "changed".boolean
pathIsSelected
(TreePath path) Returns %TRUE if the row pointed to by @path is currently selected.void
Selects all the nodes.void
Calls a function for each selected node.void
selectIter
(TreeIter iter) Selects the specified iterator.void
selectPath
(TreePath path) Select the row at @path.void
selectRange
(TreePath start_path, TreePath end_path) Selects a range of nodes, determined by @start_path and @end_path inclusive.void
setMode
(int type) Sets the selection mode of the @selection.void
setSelectFunction
(TreeSelection.OnTreeSelectionFunc func, Pointer data, TreeSelection.OnDestroyNotify destroy) Sets the selection function.void
Unselects all the nodes.void
unselectIter
(TreeIter iter) Unselects the specified iterator.void
unselectPath
(TreePath path) Unselects the row at @path.void
unselectRange
(TreePath start_path, TreePath end_path) Unselects a range of nodes, determined by @start_path and @end_path
inclusive.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_CHANGED
- See Also:
-
-
Constructor Details
-
TreeSelection
-
-
Method Details
-
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
Returns the tree view associated with @selection.- Returns:
- A `GtkTreeView`
-
getUserData
Returns the user data for the selection function.- Returns:
- The user data.
-
iterIsSelected
Returns %TRUE if the row at @iter is currently selected.- Parameters:
iter
- A valid `GtkTreeIter`- Returns:
- %TRUE, if @iter is selected
-
pathIsSelected
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
Selects the specified iterator.- Parameters:
iter
- The `GtkTreeIter` to be selected.
-
selectPath
Select the row at @path.- Parameters:
path
- The `GtkTreePath` to be selected.
-
selectRange
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
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 %NULLdata
- The selection function’s data. May be %NULLdestroy
- The destroy function for user data. May be %NULL
-
unselectAll
public void unselectAll()Unselects all the nodes. -
unselectIter
Unselects the specified iterator.- Parameters:
iter
- The `GtkTreeIter` to be unselected.
-
unselectPath
Unselects the row at @path.- Parameters:
path
- The `GtkTreePath` to be unselected.
-
unselectRange
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
Connect to signal "changed".
SeeTreeSelection.OnChanged.onChanged()
for signal description.
FieldSIGNAL_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
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-