gi-gtk-4.0.4: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.Sorter

Description

Sorter is the way to describe sorting criteria. 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 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 Sorter and provide one's own sorter.

Synopsis

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 #

(/=) :: Sorter -> Sorter -> Bool #

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

TypedObject Sorter Source # 
Instance details

Defined in GI.Gtk.Objects.Sorter

Methods

glibType :: IO GType

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

gvalueSet_ :: Ptr GValue -> Maybe Sorter -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Sorter)

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

changed

sorterChanged Source #

Arguments

:: (HasCallStack, MonadIO m, IsSorter a) 
=> a

self: a Sorter

-> SorterChange

change: How the sorter changed

-> m () 

Emits the changed signal to notify all users of the sorter that it has changed. 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 implementors of Sorter 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 Sorter

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

-> 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 C_SorterChangedCallback = Ptr () -> CUInt -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type SorterChangedCallback Source #

Arguments

 = SorterChange

change: how the sorter changed

-> IO () 

This signal is 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 -> 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

genClosure_SorterChanged :: MonadIO m => SorterChangedCallback -> m (GClosure C_SorterChangedCallback) Source #

Wrap the callback into a GClosure.

mk_SorterChangedCallback :: C_SorterChangedCallback -> IO (FunPtr C_SorterChangedCallback) Source #

Generate a function pointer callable from C code, from a C_SorterChangedCallback.

onSorterChanged :: (IsSorter a, MonadIO m) => 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