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.Sorter

Contents

- Exported types
- Methods
  - changed
  - compare
  - getOrder
- Signals
  - changed

Description

Describes sorting criteria for a `SortListModel`.

Its primary user is `SortListModel`

The model will use a sorter to determine the order in which its items should appear by calling `sorterCompare` for pairs of items.

Sorters may change their sorting behavior through their lifetime. In that case, they will emit the Sorter::changed signal to notify that the sort order is no longer valid and should be updated by calling `sorterCompare` again.

GTK provides various pre-made sorter implementations for common sorting operations. `ColumnView` has built-in support for sorting lists via the ColumnViewColumn:sorter property, where the user can change the sorting by clicking on list headers.

Of course, in particular for large lists, it is also possible to subclass `GtkSorter` and provide one's own sorter.

Synopsis

- newtype Sorter = Sorter (ManagedPtr Sorter)
- class (GObject o, IsDescendantOf Sorter o) => IsSorter o
- toSorter :: (MonadIO m, IsSorter o) => o -> m Sorter
- sorterChanged :: (HasCallStack, MonadIO m, IsSorter a) => a -> SorterChange -> m ()
- sorterCompare :: (HasCallStack, MonadIO m, IsSorter a, IsObject b, IsObject c) => a -> b -> c -> m Ordering
- sorterGetOrder :: (HasCallStack, MonadIO m, IsSorter a) => a -> m SorterOrder
- type SorterChangedCallback = SorterChange -> IO ()
- afterSorterChanged :: (IsSorter a, MonadIO m) => a -> ((?self :: a) => SorterChangedCallback) -> m SignalHandlerId
- onSorterChanged :: (IsSorter a, MonadIO m) => a -> ((?self :: a) => SorterChangedCallback) -> m SignalHandlerId

# Exported types

newtype Sorter Source #

Memory-managed wrapper type.

Constructors

Sorter (ManagedPtr Sorter) |

#### Instances

Instances details

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

class (GObject o, IsDescendantOf Sorter o) => IsSorter o Source #

Type class for types which can be safely cast to `Sorter`, for instance with `toSorter`.

#### Instances

Instances details

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

toSorter :: (MonadIO m, IsSorter o) => o -> m Sorter Source #

Cast to `Sorter`, 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, changed, compare, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getData, getOrder, getProperty, getQdata.

#### Setters

setData, setDataFull, setProperty.

## changed

sorterChanged Source #

Arguments

:: (HasCallStack, MonadIO m, IsSorter a) |
=> a | `self`: a `GtkSorter`
-> SorterChange | `change`: How the sorter changed
-> m () |

Notifies all users of the sorter that it has changed.

This emits the Sorter::changed signal. Users of the sorter should then update the sort order via `sorterCompare`.

Depending on the `change` parameter, it may be possible to update the sort order without a full resorting. Refer to the `SorterChange` documentation for details.

This function is intended for implementers of `GtkSorter` subclasses and should not be called from other functions.

## compare

sorterCompare Source #

Arguments

:: (HasCallStack, MonadIO m, IsSorter a, IsObject b, IsObject c) |
=> a | `self`: a `GtkSorter`
-> b | `item1`: first item to compare
-> c | `item2`: second item to compare
-> m Ordering | Returns: `OrderingEqual` if `item1` == `item2`, `OrderingSmaller` if `item1` < `item2`, `OrderingLarger` if `item1` > `item2`

Compares two given items according to the sort order implemented by the sorter.

Sorters implement a partial order:

- It is reflexive, ie a = a
- It is antisymmetric, ie if a < b and b < a, then a = b
- It is transitive, ie given any 3 items with a ≤ b and b ≤ c, then a ≤ c

The sorter may signal it conforms to additional constraints via the return value of `sorterGetOrder`.

## getOrder

sorterGetOrder Source #

Arguments

:: (HasCallStack, MonadIO m, IsSorter a) |
=> a | `self`: a `GtkSorter`
-> m SorterOrder | Returns: The order

Gets the order that `self` conforms to.

See `SorterOrder` for details of the possible return values.

This function is intended to allow optimizations.

# Signals

## changed

type SorterChangedCallback Source #

Arguments

= SorterChange | `change`: how the sorter changed
-> IO () |

Emitted whenever the sorter changed.

Users of the sorter should then update the sort order again via `sorterCompare`.

`SortListModel` handles this signal automatically.

Depending on the `change` parameter, it may be possible to update the sort order without a full resorting. Refer to the `SorterChange` documentation for details.

afterSorterChanged :: (IsSorter a, MonadIO m) => a -> ((?self :: a) => SorterChangedCallback) -> 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 sorter #changed callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onSorterChanged :: (IsSorter a, MonadIO m) => a -> ((?self :: a) => SorterChangedCallback) -> 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 sorter #changed callback