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.Interfaces.SectionModel

Contents

- Exported types
- Methods
  - getSection
  - sectionsChanged
- Signals
  - sectionsChanged

Description

An interface that adds support for sections to list models.

A `GtkSectionModel` groups successive items into so-called sections. List widgets like `GtkListView` and `GtkGridView` then allow displaying section headers for these sections by installing a header factory.

Many GTK list models support sections inherently, or they pass through the sections of a model they are wrapping.

When the section groupings of a model change, the model will emit the SectionModel::sectionsChanged signal by calling the `sectionModelSectionsChanged` function. All sections in the given range then need to be queried again. The ListModel::itemsChanged signal has the same effect, all sections in that range are invalidated, too.

Since: 4.12

Synopsis

- newtype SectionModel = SectionModel (ManagedPtr SectionModel)
- class (GObject o, IsDescendantOf SectionModel o) => IsSectionModel o
- toSectionModel :: (MonadIO m, IsSectionModel o) => o -> m SectionModel
- sectionModelGetSection :: (HasCallStack, MonadIO m, IsSectionModel a) => a -> Word32 -> m (Word32, Word32)
- sectionModelSectionsChanged :: (HasCallStack, MonadIO m, IsSectionModel a) => a -> Word32 -> Word32 -> m ()
- type SectionModelSectionsChangedCallback = Word32 -> Word32 -> IO ()
- afterSectionModelSectionsChanged :: (IsSectionModel a, MonadIO m) => a -> ((?self :: a) => SectionModelSectionsChangedCallback) -> m SignalHandlerId
- onSectionModelSectionsChanged :: (IsSectionModel a, MonadIO m) => a -> ((?self :: a) => SectionModelSectionsChangedCallback) -> m SignalHandlerId

# Exported types

newtype SectionModel Source #

Memory-managed wrapper type.

Constructors

SectionModel (ManagedPtr SectionModel) |

#### Instances

Instances details

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

class (GObject o, IsDescendantOf SectionModel o) => IsSectionModel o Source #

Type class for types which can be safely cast to `SectionModel`, for instance with `toSectionModel`.

#### Instances

Instances details

(GObject o, IsDescendantOf SectionModel o) => IsSectionModel o Source # |
Instance details Defined in GI.Gtk.Interfaces.SectionModel

toSectionModel :: (MonadIO m, IsSectionModel o) => o -> m SectionModel Source #

Cast to `SectionModel`, 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, itemsChanged, notify, notifyByPspec, ref, refSink, runDispose, sectionsChanged, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getData, getItem, getItemType, getNItems, getProperty, getQdata, getSection.

#### Setters

setData, setDataFull, setProperty.

## getSection

sectionModelGetSection Source #

Arguments

:: (HasCallStack, MonadIO m, IsSectionModel a) |
=> a | `self`: a `GtkSectionModel`
-> Word32 | `position`: the position of the item to query
-> m (Word32, Word32) |

Query the section that covers the given position. The number of items in the section can be computed by `out_end - out_start`.

If the position is larger than the number of items, a single range from n_items to G_MAXUINT will be returned.

Since: 4.12

## sectionsChanged

sectionModelSectionsChanged Source #

Arguments

:: (HasCallStack, MonadIO m, IsSectionModel a) |
=> a | `self`: a `GtkSectionModel`
-> Word32 | `position`: the first changed item
-> Word32 | `nItems`: the number of changed items
-> m () |

This function emits the SectionModel::sectionsChanged signal to notify about changes to sections.

It must cover all positions that used to be a section start or that are now a section start. It does not have to cover all positions for which the section has changed.

The ListModel::itemsChanged implies the effect of the SectionModel::sectionsChanged signal for all the items it covers.

It is recommended that when changes to the items cause section changes in a larger range, that the larger range is included in the emission of the ListModel::itemsChanged instead of emitting two signals.

Since: 4.12

# Signals

## sectionsChanged

type SectionModelSectionsChangedCallback Source #

Arguments

= Word32 | `position`: The first item that may have changed
-> Word32 | `nItems`: number of items with changes
-> IO () |

Emitted when the start-of-section state of some of the items in `model` changes.

Note that this signal does not specify the new section state of the items, they need to be queried manually. It is also not necessary for a model to change the section state of any of the items in the section model, though it would be rather useless to emit such a signal.

The ListModel::itemsChanged implies the effect of the SectionModel::sectionsChanged signal for all the items it covers.

Since: 4.12

afterSectionModelSectionsChanged :: (IsSectionModel a, MonadIO m) => a -> ((?self :: a) => SectionModelSectionsChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the sectionsChanged signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after sectionModel #sectionsChanged 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.

onSectionModelSectionsChanged :: (IsSectionModel a, MonadIO m) => a -> ((?self :: a) => SectionModelSectionsChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the sectionsChanged signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on sectionModel #sectionsChanged callback