Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GtkSorter
is an object 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 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
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 type ParentTypes Sorter = '[Object] |
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 () |
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 implementors of GtkSorter
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 SorterChangedCallback Source #
= SorterChange |
|
-> 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