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 |
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
- 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 C_SorterChangedCallback = Ptr () -> CUInt -> Ptr () -> IO ()
- type SorterChangedCallback = SorterChange -> IO ()
- afterSorterChanged :: (IsSorter a, MonadIO m) => a -> SorterChangedCallback -> m SignalHandlerId
- genClosure_SorterChanged :: MonadIO m => SorterChangedCallback -> m (GClosure C_SorterChangedCallback)
- mk_SorterChangedCallback :: C_SorterChangedCallback -> IO (FunPtr C_SorterChangedCallback)
- noSorterChangedCallback :: Maybe SorterChangedCallback
- onSorterChanged :: (IsSorter a, MonadIO m) => a -> SorterChangedCallback -> m SignalHandlerId
- wrap_SorterChangedCallback :: SorterChangedCallback -> C_SorterChangedCallback
Exported types
Memory-managed wrapper type.
Instances
Eq Sorter Source # | |
GObject Sorter Source # | |
Defined in GI.Gtk.Objects.Sorter | |
ManagedPtrNewtype Sorter Source # | |
Defined in GI.Gtk.Objects.Sorter toManagedPtr :: Sorter -> ManagedPtr Sorter | |
TypedObject Sorter Source # | |
Defined in GI.Gtk.Objects.Sorter | |
HasParentTypes Sorter Source # | |
Defined in GI.Gtk.Objects.Sorter | |
IsGValue (Maybe Sorter) Source # | Convert |
Defined in GI.Gtk.Objects.Sorter gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Sorter -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Sorter) | |
type ParentTypes Sorter Source # | |
Defined in GI.Gtk.Objects.Sorter |
class (GObject o, IsDescendantOf Sorter o) => IsSorter o Source #
Instances
(GObject o, IsDescendantOf Sorter o) => IsSorter o Source # | |
Defined in GI.Gtk.Objects.Sorter |
Methods
Click to display all available methods, including inherited ones
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
changed
:: (HasCallStack, MonadIO m, IsSorter a) | |
=> a |
|
-> SorterChange |
|
-> 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
:: (HasCallStack, MonadIO m, IsSorter a, IsObject b, IsObject c) | |
=> a |
|
-> b |
|
-> c |
|
-> m Ordering | Returns: |
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
:: (HasCallStack, MonadIO m, IsSorter a) | |
=> a |
|
-> 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 #
= SorterChange |
|
-> 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
.
noSorterChangedCallback :: Maybe SorterChangedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
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