TreeSelectionProtocol
public protocol TreeSelectionProtocol : ObjectProtocol
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 GtkTreeSelectionchanged 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 GtkTreeSelectionchanged signal
when nothing has happened (mostly as a result of programmers calling
select_row on an already selected row).
The TreeSelectionProtocol protocol exposes the methods and properties of an underlying GtkTreeSelection instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see TreeSelection.
Alternatively, use TreeSelectionRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkTreeSelectioninstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
tree_selection_ptrDefault implementationTyped pointer to the underlying
GtkTreeSelectioninstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkTreeSelectioninstance.Declaration
Swift
var tree_selection_ptr: UnsafeMutablePointer<GtkTreeSelection>! { get } -
Required Initialiser for types conforming to
TreeSelectionProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
TreeSelectionPropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: TreeSelectionPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a TreeSelection property
Declaration
Swift
@inlinable func get(property: TreeSelectionPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a TreeSelection property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: TreeSelectionPropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
TreeSelectionSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: TreeSelectionSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
TreeSelectionSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: TreeSelectionSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onChanged(flags:Extension methodhandler: ) 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.
Note
This represents the underlyingchangedsignalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TreeSelectionRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
changedsignal is emitted -
changedSignalExtension methodTyped
changedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var changedSignal: TreeSelectionSignalName { get } -
onNotifyMode(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::modesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyMode(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TreeSelectionRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyModesignal is emitted -
notifyModeSignalExtension methodTyped
notify::modesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyModeSignal: TreeSelectionSignalName { get }
-
countSelectedRows()Extension methodReturns the number of rows that have been selected in
tree.Declaration
Swift
@inlinable func countSelectedRows() -> Int -
getMode()Extension methodGets the selection mode for
selection. Seegtk_tree_selection_set_mode().Declaration
Swift
@inlinable func getMode() -> GtkSelectionMode -
getSelectFunction()Extension methodReturns the current selection function.
Declaration
Swift
@inlinable func getSelectFunction() -> GtkTreeSelectionFunc! -
getSelected(model:Extension methoditer: ) Sets
iterto the currently selected node ifselectionis set toGTK_SELECTION_SINGLEorGTK_SELECTION_BROWSE.itermay be NULL if you just want to test ifselectionhas any selected nodes.modelis filled with the current model as a convenience. This function will not work if you useselectionisGTK_SELECTION_MULTIPLE.Declaration
Swift
@inlinable func getSelected(model: UnsafeMutablePointer<UnsafeMutablePointer<GtkTreeModel>?>! = nil, iter: TreeIterRef? = nil) -> Bool -
getSelected(model:Extension methoditer: ) Sets
iterto the currently selected node ifselectionis set toGTK_SELECTION_SINGLEorGTK_SELECTION_BROWSE.itermay be NULL if you just want to test ifselectionhas any selected nodes.modelis filled with the current model as a convenience. This function will not work if you useselectionisGTK_SELECTION_MULTIPLE.Declaration
Swift
@inlinable func getSelected<TreeIterT>(model: UnsafeMutablePointer<UnsafeMutablePointer<GtkTreeModel>?>! = nil, iter: TreeIterT?) -> Bool where TreeIterT : TreeIterProtocol -
getSelectedRows(model:Extension method) 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 usegtk_tree_row_reference_new().To free the return value, use: (C Language Example):
g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);Declaration
Swift
@inlinable func getSelectedRows(model: UnsafeMutablePointer<UnsafeMutablePointer<GtkTreeModel>?>! = nil) -> GLib.ListRef! -
getTreeView()Extension methodReturns the tree view associated with
selection.Declaration
Swift
@inlinable func getTreeView() -> TreeViewRef! -
getUserData()Extension methodReturns the user data for the selection function.
Declaration
Swift
@inlinable func getUserData() -> gpointer! -
iterIsSelected(iter:Extension method) Returns
trueif the row atiteris currently selected.Declaration
Swift
@inlinable func iterIsSelected<TreeIterT>(iter: TreeIterT) -> Bool where TreeIterT : TreeIterProtocol -
pathIsSelected(path:Extension method) Returns
trueif the row pointed to bypathis currently selected. Ifpathdoes not point to a valid location,falseis returnedDeclaration
Swift
@inlinable func pathIsSelected<TreePathT>(path: TreePathT) -> Bool where TreePathT : TreePathProtocol -
selectAll()Extension methodSelects all the nodes.
selectionmust be set toGTK_SELECTION_MULTIPLEmode.Declaration
Swift
@inlinable func selectAll() -
select(iter:Extension method) Selects the specified iterator.
Declaration
Swift
@inlinable func select<TreeIterT>(iter: TreeIterT) where TreeIterT : TreeIterProtocol -
select(path:Extension method) Select the row at
path.Declaration
Swift
@inlinable func select<TreePathT>(path: TreePathT) where TreePathT : TreePathProtocol -
selectRange(startPath:Extension methodendPath: ) Selects a range of nodes, determined by
start_pathandend_pathinclusive.selectionmust be set toGTK_SELECTION_MULTIPLEmode.Declaration
Swift
@inlinable func selectRange<TreePathT>(startPath: TreePathT, endPath: TreePathT) where TreePathT : TreePathProtocol -
selectedForeach(func:Extension methoddata: ) 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.Declaration
Swift
@inlinable func selectedForeach(func: GtkTreeSelectionForeachFunc?, data: gpointer! = nil) -
setMode(type:Extension method) Sets the selection mode of the
selection. If the previous type wasGTK_SELECTION_MULTIPLE, then the anchor is kept selected, if it was previously selected.Declaration
Swift
@inlinable func setMode(type: GtkSelectionMode) -
setSelectFunction(func:Extension methoddata: 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
trueif the state of the node may be toggled, andfalseif the state of the node should be left unchanged.Declaration
Swift
@inlinable func setSelectFunction(func: GtkTreeSelectionFunc? = nil, data: gpointer! = nil, destroy: GDestroyNotify?) -
unselectAll()Extension methodUnselects all the nodes.
Declaration
Swift
@inlinable func unselectAll() -
unselect(iter:Extension method) Unselects the specified iterator.
Declaration
Swift
@inlinable func unselect<TreeIterT>(iter: TreeIterT) where TreeIterT : TreeIterProtocol -
unselect(path:Extension method) Unselects the row at
path.Declaration
Swift
@inlinable func unselect<TreePathT>(path: TreePathT) where TreePathT : TreePathProtocol -
unselectRange(startPath:Extension methodendPath: ) Unselects a range of nodes, determined by
start_pathandend_pathinclusive.Declaration
Swift
@inlinable func unselectRange<TreePathT>(startPath: TreePathT, endPath: TreePathT) where TreePathT : TreePathProtocol -
modeExtension methodSelection mode. See
gtk_tree_selection_set_mode()for more information on this property.Declaration
Swift
@inlinable var mode: GtkSelectionMode { get nonmutating set } -
selectFunctionExtension methodReturns the current selection function.
Declaration
Swift
@inlinable var selectFunction: GtkTreeSelectionFunc! { get } -
treeViewExtension methodReturns the tree view associated with
selection.Declaration
Swift
@inlinable var treeView: TreeViewRef! { get } -
userDataExtension methodReturns the user data for the selection function.
Declaration
Swift
@inlinable var userData: gpointer! { get }
View on GitHub
Install in Dash
TreeSelectionProtocol Protocol Reference