Next: , Previous: GtkTreeModel, Up: Top


33 GtkTreeSelection

The selection object for

33.1 Overview

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

The <gtk-tree-selection> object is gotten from a <gtk-tree-view> 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 "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 "changed" signal when nothing has happened (mostly as a result of programmers calling select_row on an already selected row).

33.2 Usage

— Class: <gtk-tree-selection>

Derives from <gobject>.

This class defines no direct slots.

— Signal on <gtk-tree-selection>: changed

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.

— Function: gtk-tree-selection-set-mode (self <gtk-tree-selection>) (type <gtk-selection-mode>)
— Method: set-mode

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.

selection
A <gtk-tree-selection>.
type
The selection mode
— Function: gtk-tree-selection-get-mode (self <gtk-tree-selection>) ⇒  (ret <gtk-selection-mode>)
— Method: get-mode

Gets the selection mode for selection. See gtk-tree-selection-set-mode.

selection
a <gtk-tree-selection>
ret
the current selection mode
— Function: gtk-tree-selection-get-tree-view (self <gtk-tree-selection>) ⇒  (ret <gtk-tree-view>)
— Method: get-tree-view

Returns the tree view associated with selection.

selection
A <gtk-tree-selection>
ret
A <gtk-tree-view>
— Function: gtk-tree-selection-get-selected (self <gtk-tree-selection>) ⇒  (model <gtk-tree-model>) (iter <gtk-tree-iter>)
— Method: get-selected
— Method: get-selected

Retrieve the current selection, if selection is set to <gtk-selection-single> or <gtk-selection-browse>.

This function will not work if you use selection is <gtk-selection-multiple>.

selection
A <gtk-tree-selection>.
model
A pointer to set to the <gtk-tree-model>, or NULL.
iter
The <gtk-tree-iter>, or NULL.
— Function: gtk-tree-selection-select-path (self <gtk-tree-selection>) (path <gtk-tree-path>)
— Method: select-path

Select the row at path.

selection
A <gtk-tree-selection>.
path
The <gtk-tree-path> to be selected.
— Function: gtk-tree-selection-unselect-path (self <gtk-tree-selection>) (path <gtk-tree-path>)
— Method: unselect-path

Unselects the row at path.

selection
A <gtk-tree-selection>.
path
The <gtk-tree-path> to be unselected.
— Function: gtk-tree-selection-path-is-selected (self <gtk-tree-selection>) (path <gtk-tree-path>) ⇒  (ret bool)
— Method: path-is-selected

Returns ‘#t’ if the row pointed to by path is currently selected. If path does not point to a valid location, ‘#f’ is returned

selection
A <gtk-tree-selection>.
path
A <gtk-tree-path> to check selection on.
ret
#t’ if path is selected.
— Function: gtk-tree-selection-select-iter (self <gtk-tree-selection>) (iter <gtk-tree-iter>)
— Method: select-iter

Selects the specified iterator.

selection
A <gtk-tree-selection>.
iter
The <gtk-tree-iter> to be selected.
— Function: gtk-tree-selection-unselect-iter (self <gtk-tree-selection>) (iter <gtk-tree-iter>)
— Method: unselect-iter

Unselects the specified iterator.

selection
A <gtk-tree-selection>.
iter
The <gtk-tree-iter> to be unselected.
— Function: gtk-tree-selection-iter-is-selected (self <gtk-tree-selection>) (iter <gtk-tree-iter>) ⇒  (ret bool)
— Method: iter-is-selected

Returns ‘#t’ if the row at iter is currently selected.

selection
A <gtk-tree-selection>
iter
A valid <gtk-tree-iter>
ret
#t’, if iter is selected
— Function: gtk-tree-selection-select-all (self <gtk-tree-selection>)
— Method: select-all

Selects all the nodes. selection must be set to <gtk-selection-multiple> mode.

selection
A <gtk-tree-selection>.
— Function: gtk-tree-selection-unselect-all (self <gtk-tree-selection>)
— Method: unselect-all

Unselects all the nodes.

selection
A <gtk-tree-selection>.
— Function: gtk-tree-selection-select-range (self <gtk-tree-selection>) (start_path <gtk-tree-path>) (end_path <gtk-tree-path>)
— Method: select-range

Selects a range of nodes, determined by start-path and end-path inclusive. selection must be set to <gtk-selection-multiple> mode.

selection
A <gtk-tree-selection>.
start-path
The initial node of the range.
end-path
The final node of the range.
— Function: gtk-tree-selection-unselect-range (self <gtk-tree-selection>) (start_path <gtk-tree-path>) (end_path <gtk-tree-path>)
— Method: unselect-range

Unselects a range of nodes, determined by start-path and end-path inclusive.

selection
A <gtk-tree-selection>.
start-path
The initial node of the range.
end-path
The initial node of the range.

Since 2.2