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 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 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
GtkTreeSelection
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
tree_selection_ptr
Default implementationTyped pointer to the underlying
GtkTreeSelection
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkTreeSelection
instance.Declaration
Swift
var tree_selection_ptr: UnsafeMutablePointer<GtkTreeSelection>! { get }
-
Required Initialiser for types conforming to
TreeSelectionProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
TreeSelectionPropertyName
source 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 : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a TreeSelection property
Declaration
Swift
@inlinable func get(property: TreeSelectionPropertyName) -> GLibObject.Value
Parameters
property
the 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
property
the 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
TreeSelectionSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: TreeSelectionSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The 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
TreeSelectionSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: TreeSelectionSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The 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 underlyingchanged
signalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TreeSelectionRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
changed
signal is emitted -
changedSignal
Extension methodTyped
changed
signal 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 innotify
being 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::mode
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyMode(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TreeSelectionRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyMode
signal is emitted -
notifyModeSignal
Extension methodTyped
notify::mode
signal 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
iter
to the currently selected node ifselection
is set toGTK_SELECTION_SINGLE
orGTK_SELECTION_BROWSE
.iter
may be NULL if you just want to test ifselection
has any selected nodes.model
is filled with the current model as a convenience. This function will not work if you useselection
isGTK_SELECTION_MULTIPLE
.Declaration
Swift
@inlinable func getSelected(model: UnsafeMutablePointer<UnsafeMutablePointer<GtkTreeModel>?>! = nil, iter: TreeIterRef? = nil) -> Bool
-
getSelected(model:
Extension methoditer: ) Sets
iter
to the currently selected node ifselection
is set toGTK_SELECTION_SINGLE
orGTK_SELECTION_BROWSE
.iter
may be NULL if you just want to test ifselection
has any selected nodes.model
is filled with the current model as a convenience. This function will not work if you useselection
isGTK_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
GtkTreeRowReference
s. 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
true
if the row atiter
is currently selected.Declaration
Swift
@inlinable func iterIsSelected<TreeIterT>(iter: TreeIterT) -> Bool where TreeIterT : TreeIterProtocol
-
pathIsSelected(path:
Extension method) Returns
true
if the row pointed to bypath
is currently selected. Ifpath
does not point to a valid location,false
is returnedDeclaration
Swift
@inlinable func pathIsSelected<TreePathT>(path: TreePathT) -> Bool where TreePathT : TreePathProtocol
-
selectAll()
Extension methodSelects all the nodes.
selection
must be set toGTK_SELECTION_MULTIPLE
mode.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_path
andend_path
inclusive.selection
must be set toGTK_SELECTION_MULTIPLE
mode.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
true
if the state of the node may be toggled, andfalse
if 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_path
andend_path
inclusive.Declaration
Swift
@inlinable func unselectRange<TreePathT>(startPath: TreePathT, endPath: TreePathT) where TreePathT : TreePathProtocol
-
mode
Extension methodSelection mode. See
gtk_tree_selection_set_mode()
for more information on this property.Declaration
Swift
@inlinable var mode: GtkSelectionMode { get nonmutating set }
-
selectFunction
Extension methodReturns the current selection function.
Declaration
Swift
@inlinable var selectFunction: GtkTreeSelectionFunc! { get }
-
treeView
Extension methodReturns the tree view associated with
selection
.Declaration
Swift
@inlinable var treeView: TreeViewRef! { get }
-
userData
Extension methodReturns the user data for the selection function.
Declaration
Swift
@inlinable var userData: gpointer! { get }