Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
The TreeSelection
object is a helper object to manage the selection
for a TreeView
widget. The TreeSelection
object is
automatically created when a new TreeView
widget is created, and
cannot exist independently 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
treeViewGetSelection
. 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).
Synopsis
- newtype TreeSelection = TreeSelection (ManagedPtr TreeSelection)
- class (GObject o, IsDescendantOf TreeSelection o) => IsTreeSelection o
- toTreeSelection :: (MonadIO m, IsTreeSelection o) => o -> m TreeSelection
- treeSelectionCountSelectedRows :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> m Int32
- treeSelectionGetMode :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> m SelectionMode
- treeSelectionGetSelected :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> m (Bool, TreeModel, TreeIter)
- treeSelectionGetSelectedRows :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> m ([TreePath], TreeModel)
- treeSelectionGetTreeView :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> m TreeView
- treeSelectionIterIsSelected :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> TreeIter -> m Bool
- treeSelectionPathIsSelected :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> TreePath -> m Bool
- treeSelectionSelectAll :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> m ()
- treeSelectionSelectIter :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> TreeIter -> m ()
- treeSelectionSelectPath :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> TreePath -> m ()
- treeSelectionSelectRange :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> TreePath -> TreePath -> m ()
- treeSelectionSelectedForeach :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> TreeSelectionForeachFunc -> m ()
- treeSelectionSetMode :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> SelectionMode -> m ()
- treeSelectionSetSelectFunction :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> Maybe TreeSelectionFunc -> m ()
- treeSelectionUnselectAll :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> m ()
- treeSelectionUnselectIter :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> TreeIter -> m ()
- treeSelectionUnselectPath :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> TreePath -> m ()
- treeSelectionUnselectRange :: (HasCallStack, MonadIO m, IsTreeSelection a) => a -> TreePath -> TreePath -> m ()
- constructTreeSelectionMode :: (IsTreeSelection o, MonadIO m) => SelectionMode -> m (GValueConstruct o)
- getTreeSelectionMode :: (MonadIO m, IsTreeSelection o) => o -> m SelectionMode
- setTreeSelectionMode :: (MonadIO m, IsTreeSelection o) => o -> SelectionMode -> m ()
- type C_TreeSelectionChangedCallback = Ptr () -> Ptr () -> IO ()
- type TreeSelectionChangedCallback = IO ()
- afterTreeSelectionChanged :: (IsTreeSelection a, MonadIO m) => a -> TreeSelectionChangedCallback -> m SignalHandlerId
- genClosure_TreeSelectionChanged :: MonadIO m => TreeSelectionChangedCallback -> m (GClosure C_TreeSelectionChangedCallback)
- mk_TreeSelectionChangedCallback :: C_TreeSelectionChangedCallback -> IO (FunPtr C_TreeSelectionChangedCallback)
- noTreeSelectionChangedCallback :: Maybe TreeSelectionChangedCallback
- onTreeSelectionChanged :: (IsTreeSelection a, MonadIO m) => a -> TreeSelectionChangedCallback -> m SignalHandlerId
- wrap_TreeSelectionChangedCallback :: TreeSelectionChangedCallback -> C_TreeSelectionChangedCallback
Exported types
newtype TreeSelection Source #
Memory-managed wrapper type.
TreeSelection (ManagedPtr TreeSelection) |
Instances
Eq TreeSelection Source # | |
Defined in GI.Gtk.Objects.TreeSelection (==) :: TreeSelection -> TreeSelection -> Bool # (/=) :: TreeSelection -> TreeSelection -> Bool # | |
GObject TreeSelection Source # | |
Defined in GI.Gtk.Objects.TreeSelection | |
ManagedPtrNewtype TreeSelection Source # | |
Defined in GI.Gtk.Objects.TreeSelection toManagedPtr :: TreeSelection -> ManagedPtr TreeSelection | |
TypedObject TreeSelection Source # | |
Defined in GI.Gtk.Objects.TreeSelection | |
HasParentTypes TreeSelection Source # | |
Defined in GI.Gtk.Objects.TreeSelection | |
IsGValue (Maybe TreeSelection) Source # | Convert |
Defined in GI.Gtk.Objects.TreeSelection gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe TreeSelection -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe TreeSelection) | |
type ParentTypes TreeSelection Source # | |
Defined in GI.Gtk.Objects.TreeSelection |
class (GObject o, IsDescendantOf TreeSelection o) => IsTreeSelection o Source #
Type class for types which can be safely cast to TreeSelection
, for instance with toTreeSelection
.
Instances
(GObject o, IsDescendantOf TreeSelection o) => IsTreeSelection o Source # | |
Defined in GI.Gtk.Objects.TreeSelection |
toTreeSelection :: (MonadIO m, IsTreeSelection o) => o -> m TreeSelection Source #
Cast to TreeSelection
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, countSelectedRows, forceFloating, freezeNotify, getv, isFloating, iterIsSelected, notify, notifyByPspec, pathIsSelected, ref, refSink, runDispose, selectAll, selectIter, selectPath, selectRange, selectedForeach, stealData, stealQdata, thawNotify, unref, unselectAll, unselectIter, unselectPath, unselectRange, watchClosure.
Getters
getData, getMode, getProperty, getQdata, getSelected, getSelectedRows, getTreeView.
Setters
setData, setDataFull, setMode, setProperty, setSelectFunction.
countSelectedRows
treeSelectionCountSelectedRows Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> m Int32 | Returns: The number of rows selected. |
Returns the number of rows that have been selected in tree
.
Since: 2.2
getMode
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> m SelectionMode | Returns: the current selection mode |
Gets the selection mode for selection
. See
treeSelectionSetMode
.
getSelected
treeSelectionGetSelected Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> m (Bool, TreeModel, TreeIter) | Returns: TRUE, if there is a selected node. |
Sets iter
to the currently selected node if selection
is set to
GTK_SELECTION_SINGLE
or GTK_SELECTION_BROWSE
. iter
may be NULL if you
just want to test if selection
has any selected nodes. model
is filled
with the current model as a convenience. This function will not work if you
use selection
is GTK_SELECTION_MULTIPLE
.
getSelectedRows
treeSelectionGetSelectedRows Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> m ([TreePath], TreeModel) | Returns: A |
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 use treeRowReferenceNew
.
To free the return value, use:
C code
g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
Since: 2.2
getTreeView
treeSelectionGetTreeView Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> m TreeView | Returns: A |
Returns the tree view associated with selection
.
iterIsSelected
treeSelectionIterIsSelected Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> TreeIter |
|
-> m Bool | Returns: |
Returns True
if the row at iter
is currently selected.
pathIsSelected
treeSelectionPathIsSelected Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> TreePath |
|
-> m Bool | Returns: |
selectAll
treeSelectionSelectAll Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> m () |
Selects all the nodes. selection
must be set to GTK_SELECTION_MULTIPLE
mode.
selectIter
treeSelectionSelectIter Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> TreeIter |
|
-> m () |
Selects the specified iterator.
selectPath
treeSelectionSelectPath Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> TreePath |
|
-> m () |
Select the row at path
.
selectRange
treeSelectionSelectRange Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> TreePath |
|
-> TreePath |
|
-> m () |
Selects a range of nodes, determined by startPath
and endPath
inclusive.
selection
must be set to GTK_SELECTION_MULTIPLE
mode.
selectedForeach
treeSelectionSelectedForeach Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> TreeSelectionForeachFunc |
|
-> m () |
Calls a function for each selected node. Note that you cannot modify
the tree or selection from within this function. As a result,
treeSelectionGetSelectedRows
might be more useful.
setMode
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> SelectionMode |
|
-> m () |
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.
setSelectFunction
treeSelectionSetSelectFunction Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> Maybe TreeSelectionFunc |
|
-> m () |
unselectAll
treeSelectionUnselectAll Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> m () |
Unselects all the nodes.
unselectIter
treeSelectionUnselectIter Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> TreeIter |
|
-> m () |
Unselects the specified iterator.
unselectPath
treeSelectionUnselectPath Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> TreePath |
|
-> m () |
Unselects the row at path
.
unselectRange
treeSelectionUnselectRange Source #
:: (HasCallStack, MonadIO m, IsTreeSelection a) | |
=> a |
|
-> TreePath |
|
-> TreePath |
|
-> m () |
Unselects a range of nodes, determined by startPath
and endPath
inclusive.
Since: 2.2
Properties
mode
Selection mode.
See treeSelectionSetMode
for more information on this property.
Since: 3.2
constructTreeSelectionMode :: (IsTreeSelection o, MonadIO m) => SelectionMode -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “mode
” property. This is rarely needed directly, but it is used by new
.
getTreeSelectionMode :: (MonadIO m, IsTreeSelection o) => o -> m SelectionMode Source #
Get the value of the “mode
” property.
When overloading is enabled, this is equivalent to
get
treeSelection #mode
setTreeSelectionMode :: (MonadIO m, IsTreeSelection o) => o -> SelectionMode -> m () Source #
Set the value of the “mode
” property.
When overloading is enabled, this is equivalent to
set
treeSelection [ #mode:=
value ]
Signals
changed
type C_TreeSelectionChangedCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type TreeSelectionChangedCallback = IO () Source #
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.
afterTreeSelectionChanged :: (IsTreeSelection a, MonadIO m) => a -> TreeSelectionChangedCallback -> m SignalHandlerId Source #
Connect a signal handler for the changed signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
treeSelection #changed callback
genClosure_TreeSelectionChanged :: MonadIO m => TreeSelectionChangedCallback -> m (GClosure C_TreeSelectionChangedCallback) Source #
Wrap the callback into a GClosure
.
mk_TreeSelectionChangedCallback :: C_TreeSelectionChangedCallback -> IO (FunPtr C_TreeSelectionChangedCallback) Source #
Generate a function pointer callable from C code, from a C_TreeSelectionChangedCallback
.
noTreeSelectionChangedCallback :: Maybe TreeSelectionChangedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
TreeSelectionChangedCallback
onTreeSelectionChanged :: (IsTreeSelection a, MonadIO m) => a -> TreeSelectionChangedCallback -> m SignalHandlerId Source #
Connect a signal handler for the changed signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
treeSelection #changed callback