gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.SingleSelection

Contents

- Exported types
- Methods
  - getAutoselect
  - getCanUnselect
  - getModel
  - getSelected
  - getSelectedItem
  - new
  - setAutoselect
  - setCanUnselect
  - setModel
  - setSelected
- Properties
  - autoselect
  - canUnselect
  - itemType
  - model
  - nItems
  - selected
  - selectedItem

Description

A selection model that allows selecting a single item.

Note that the selection is *persistent* -- if the selected item is removed and re-added in the same ListModel::itemsChanged emission, it stays selected. In particular, this means that changing the sort order of an underlying sort model will preserve the selection.

Synopsis

- newtype SingleSelection = SingleSelection (ManagedPtr SingleSelection)
- class (GObject o, IsDescendantOf SingleSelection o) => IsSingleSelection o
- toSingleSelection :: (MonadIO m, IsSingleSelection o) => o -> m SingleSelection
- singleSelectionGetAutoselect :: (HasCallStack, MonadIO m, IsSingleSelection a) => a -> m Bool
- singleSelectionGetCanUnselect :: (HasCallStack, MonadIO m, IsSingleSelection a) => a -> m Bool
- singleSelectionGetModel :: (HasCallStack, MonadIO m, IsSingleSelection a) => a -> m (Maybe ListModel)
- singleSelectionGetSelected :: (HasCallStack, MonadIO m, IsSingleSelection a) => a -> m Word32
- singleSelectionGetSelectedItem :: (HasCallStack, MonadIO m, IsSingleSelection a) => a -> m (Maybe Object)
- singleSelectionNew :: (HasCallStack, MonadIO m, IsListModel a) => Maybe a -> m SingleSelection
- singleSelectionSetAutoselect :: (HasCallStack, MonadIO m, IsSingleSelection a) => a -> Bool -> m ()
- singleSelectionSetCanUnselect :: (HasCallStack, MonadIO m, IsSingleSelection a) => a -> Bool -> m ()
- singleSelectionSetModel :: (HasCallStack, MonadIO m, IsSingleSelection a, IsListModel b) => a -> Maybe b -> m ()
- singleSelectionSetSelected :: (HasCallStack, MonadIO m, IsSingleSelection a) => a -> Word32 -> m ()
- constructSingleSelectionAutoselect :: (IsSingleSelection o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSingleSelectionAutoselect :: (MonadIO m, IsSingleSelection o) => o -> m Bool
- setSingleSelectionAutoselect :: (MonadIO m, IsSingleSelection o) => o -> Bool -> m ()
- constructSingleSelectionCanUnselect :: (IsSingleSelection o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSingleSelectionCanUnselect :: (MonadIO m, IsSingleSelection o) => o -> m Bool
- setSingleSelectionCanUnselect :: (MonadIO m, IsSingleSelection o) => o -> Bool -> m ()
- getSingleSelectionItemType :: (MonadIO m, IsSingleSelection o) => o -> m GType
- clearSingleSelectionModel :: (MonadIO m, IsSingleSelection o) => o -> m ()
- constructSingleSelectionModel :: (IsSingleSelection o, MonadIO m, IsListModel a) => a -> m (GValueConstruct o)
- getSingleSelectionModel :: (MonadIO m, IsSingleSelection o) => o -> m (Maybe ListModel)
- setSingleSelectionModel :: (MonadIO m, IsSingleSelection o, IsListModel a) => o -> a -> m ()
- getSingleSelectionNItems :: (MonadIO m, IsSingleSelection o) => o -> m Word32
- constructSingleSelectionSelected :: (IsSingleSelection o, MonadIO m) => Word32 -> m (GValueConstruct o)
- getSingleSelectionSelected :: (MonadIO m, IsSingleSelection o) => o -> m Word32
- setSingleSelectionSelected :: (MonadIO m, IsSingleSelection o) => o -> Word32 -> m ()
- getSingleSelectionSelectedItem :: (MonadIO m, IsSingleSelection o) => o -> m (Maybe Object)

# Exported types

newtype SingleSelection Source #

Memory-managed wrapper type.

Constructors

SingleSelection (ManagedPtr SingleSelection) |

#### Instances

Instances details

Eq SingleSelection Source # |
Instance details Defined in GI.Gtk.Objects.SingleSelection Methods (==) :: SingleSelection -> SingleSelection -> Bool Source # (/=) :: SingleSelection -> SingleSelection -> Bool Source #
GObject SingleSelection Source # |
Instance details Defined in GI.Gtk.Objects.SingleSelection
ManagedPtrNewtype SingleSelection Source # |
Instance details Defined in GI.Gtk.Objects.SingleSelection Methods toManagedPtr :: SingleSelection -> ManagedPtr SingleSelection Source #
TypedObject SingleSelection Source # |
Instance details Defined in GI.Gtk.Objects.SingleSelection Methods glibType :: IO GType Source #
HasParentTypes SingleSelection Source # |
Instance details Defined in GI.Gtk.Objects.SingleSelection
IsGValue (Maybe SingleSelection) Source # | Convert `SingleSelection` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.SingleSelection Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe SingleSelection -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe SingleSelection) Source #
type ParentTypes SingleSelection Source # |
Instance details Defined in GI.Gtk.Objects.SingleSelection type ParentTypes SingleSelection = '[Object, ListModel, SectionModel, SelectionModel]

class (GObject o, IsDescendantOf SingleSelection o) => IsSingleSelection o Source #

Type class for types which can be safely cast to `SingleSelection`, for instance with `toSingleSelection`.

#### Instances

Instances details

(GObject o, IsDescendantOf SingleSelection o) => IsSingleSelection o Source # |
Instance details Defined in GI.Gtk.Objects.SingleSelection

toSingleSelection :: (MonadIO m, IsSingleSelection o) => o -> m SingleSelection Source #

Cast to `SingleSelection`, 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

Expand

#### Methods

bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, isSelected, itemsChanged, notify, notifyByPspec, ref, refSink, runDispose, sectionsChanged, selectAll, selectItem, selectRange, selectionChanged, stealData, stealQdata, thawNotify, unref, unselectAll, unselectItem, unselectRange, watchClosure.

#### Getters

getAutoselect, getCanUnselect, getData, getItem, getItemType, getModel, getNItems, getProperty, getQdata, getSection, getSelected, getSelectedItem, getSelection, getSelectionInRange.

#### Setters

setAutoselect, setCanUnselect, setData, setDataFull, setModel, setProperty, setSelected, setSelection.

## getAutoselect

singleSelectionGetAutoselect Source #

Arguments

:: (HasCallStack, MonadIO m, IsSingleSelection a) |
=> a | `self`: a `GtkSingleSelection`
-> m Bool | Returns: `True` if autoselect is enabled

Checks if autoselect has been enabled or disabled via `singleSelectionSetAutoselect`.

## getCanUnselect

singleSelectionGetCanUnselect Source #

Arguments

:: (HasCallStack, MonadIO m, IsSingleSelection a) |
=> a | `self`: a `GtkSingleSelection`
-> m Bool | Returns: `True` to support unselecting

If `True`, `selectionModelUnselectItem` is supported and allows unselecting the selected item.

## getModel

singleSelectionGetModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsSingleSelection a) |
=> a | `self`: a `GtkSingleSelection`
-> m (Maybe ListModel) | Returns: The model being wrapped

Gets the model that `self` is wrapping.

## getSelected

singleSelectionGetSelected Source #

Arguments

:: (HasCallStack, MonadIO m, IsSingleSelection a) |
=> a | `self`: a `GtkSingleSelection`
-> m Word32 | Returns: The position of the selected item

Gets the position of the selected item.

If no item is selected, `INVALID_LIST_POSITION` is returned.

## getSelectedItem

singleSelectionGetSelectedItem Source #

Arguments

:: (HasCallStack, MonadIO m, IsSingleSelection a) |
=> a | `self`: a `GtkSingleSelection`
-> m (Maybe Object) | Returns: The selected item

Gets the selected item.

If no item is selected, `Nothing` is returned.

## new

singleSelectionNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsListModel a) |
=> Maybe a | `model`: the `GListModel` to manage
-> m SingleSelection | Returns: a new `GtkSingleSelection`

Creates a new selection to handle `model`.

## setAutoselect

singleSelectionSetAutoselect Source #

Arguments

:: (HasCallStack, MonadIO m, IsSingleSelection a) |
=> a | `self`: a `GtkSingleSelection`
-> Bool | `autoselect`: `True` to always select an item
-> m () |

Enables or disables autoselect.

If `autoselect` is `True`, `self` will enforce that an item is always selected. It will select a new item when the currently selected item is deleted and it will disallow unselecting the current item.

## setCanUnselect

singleSelectionSetCanUnselect Source #

Arguments

:: (HasCallStack, MonadIO m, IsSingleSelection a) |
=> a | `self`: a `GtkSingleSelection`
-> Bool | `canUnselect`: `True` to allow unselecting
-> m () |

If `True`, unselecting the current item via `selectionModelUnselectItem` is supported.

Note that setting SingleSelection:autoselect will cause unselecting to not work, so it practically makes no sense to set both at the same time.

## setModel

singleSelectionSetModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsSingleSelection a, IsListModel b) |
=> a | `self`: a `GtkSingleSelection`
-> Maybe b | `model`: A `GListModel` to wrap
-> m () |

Sets the model that `self` should wrap.

If `model` is `Nothing`, `self` will be empty.

## setSelected

singleSelectionSetSelected Source #

Arguments

:: (HasCallStack, MonadIO m, IsSingleSelection a) |
=> a | `self`: a `GtkSingleSelection`
-> Word32 | `position`: the item to select or `INVALID_LIST_POSITION`
-> m () |

Selects the item at the given position.

If the list does not have an item at `position` or `INVALID_LIST_POSITION` is given, the behavior depends on the value of the SingleSelection:autoselect property: If it is set, no change will occur and the old item will stay selected. If it is unset, the selection will be unset and no item will be selected. This also applies if SingleSelection:canUnselect is set to `False`.

# Properties

## autoselect

If the selection will always select an item.

constructSingleSelectionAutoselect :: (IsSingleSelection o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`autoselect`” property. This is rarely needed directly, but it is used by `new`.

getSingleSelectionAutoselect :: (MonadIO m, IsSingleSelection o) => o -> m Bool Source #

Get the value of the “`autoselect`” property. When overloading is enabled, this is equivalent to

    get singleSelection #autoselect

setSingleSelectionAutoselect :: (MonadIO m, IsSingleSelection o) => o -> Bool -> m () Source #

Set the value of the “`autoselect`” property. When overloading is enabled, this is equivalent to

    set singleSelection [ #autoselect := value ]

## canUnselect

If unselecting the selected item is allowed.

constructSingleSelectionCanUnselect :: (IsSingleSelection o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`can-unselect`” property. This is rarely needed directly, but it is used by `new`.

getSingleSelectionCanUnselect :: (MonadIO m, IsSingleSelection o) => o -> m Bool Source #

Get the value of the “`can-unselect`” property. When overloading is enabled, this is equivalent to

    get singleSelection #canUnselect

setSingleSelectionCanUnselect :: (MonadIO m, IsSingleSelection o) => o -> Bool -> m () Source #

Set the value of the “`can-unselect`” property. When overloading is enabled, this is equivalent to

    set singleSelection [ #canUnselect := value ]

## itemType

The type of items. See `listModelGetItemType`.

Since: 4.8

getSingleSelectionItemType :: (MonadIO m, IsSingleSelection o) => o -> m GType Source #

Get the value of the “`item-type`” property. When overloading is enabled, this is equivalent to

    get singleSelection #itemType

## model

The model being managed.

clearSingleSelectionModel :: (MonadIO m, IsSingleSelection o) => o -> m () Source #

Set the value of the “`model`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #model

constructSingleSelectionModel :: (IsSingleSelection o, MonadIO m, IsListModel a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`model`” property. This is rarely needed directly, but it is used by `new`.

getSingleSelectionModel :: (MonadIO m, IsSingleSelection o) => o -> m (Maybe ListModel) Source #

Get the value of the “`model`” property. When overloading is enabled, this is equivalent to

    get singleSelection #model

setSingleSelectionModel :: (MonadIO m, IsSingleSelection o, IsListModel a) => o -> a -> m () Source #

Set the value of the “`model`” property. When overloading is enabled, this is equivalent to

    set singleSelection [ #model := value ]

## nItems

The number of items. See `listModelGetNItems`.

Since: 4.8

getSingleSelectionNItems :: (MonadIO m, IsSingleSelection o) => o -> m Word32 Source #

Get the value of the “`n-items`” property. When overloading is enabled, this is equivalent to

    get singleSelection #nItems

## selected

Position of the selected item.

constructSingleSelectionSelected :: (IsSingleSelection o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`selected`” property. This is rarely needed directly, but it is used by `new`.

getSingleSelectionSelected :: (MonadIO m, IsSingleSelection o) => o -> m Word32 Source #

Get the value of the “`selected`” property. When overloading is enabled, this is equivalent to

    get singleSelection #selected

setSingleSelectionSelected :: (MonadIO m, IsSingleSelection o) => o -> Word32 -> m () Source #

Set the value of the “`selected`” property. When overloading is enabled, this is equivalent to

    set singleSelection [ #selected := value ]

## selectedItem

The selected item.

getSingleSelectionSelectedItem :: (MonadIO m, IsSingleSelection o) => o -> m (Maybe Object) Source #

Get the value of the “`selected-item`” property. When overloading is enabled, this is equivalent to

    get singleSelection #selectedItem