gi-gio-hs-list-model: Haskell implementation of GListModel interface from gi-gio

[ graphics, lgpl, library ] [ Propose Tags ] [ Report a vulnerability ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1
Change log CHANGELOG.md
Dependencies base (>=4.14.1.0 && <4.15), containers, gi-gio, gi-gobject, haskell-gi-base [details]
License LGPL-2.1-only
Author Akshay Mankar
Maintainer itsakshaymankar@gmail.com
Category Graphics
Home page https://git.coop/akshay/gi-gio-hs-list-model#gi-gio-hs-list-model
Bug tracker https://git.coop/akshay/gi-gio-hs-list-model/-/issues
Source repo head: git clone https://git.coop/akshay/gi-gio-hs-list-model.git
Uploaded by axeman at 2021-08-12T17:43:12Z
Distributions
Downloads 312 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2021-08-12 [all 2 reports]

Readme for gi-gio-hs-list-model-0.1.0.1

[back to package description]

gi-gio-hs-list-model

This library implements the GListModelInterface which is required for using ListView. The library can be used in two ways:

  1. use the provided SeqStore which uses a Seq underneath to store the list, or
  2. implement functions required for CustomStoreImpl in the way SeqStore does.

Example use of SeqStore with ListView

data Person = Person { name :: Text, age :: Int } mkListView :: IO Gtk.ListView mkListView workChan messageViewStore = do factory <- new Gtk.SignalListItemFactory [ On #setup createEmptyItem , On #bind populateItem ] model <- seqStoreNew [ Person "Faizal Khan" 30 , Person "Ramadhir Singh" 60 ] selection <- new Gtk.SingleSelection [#model := model] new Gtk.ListView [ #model := selection, #factory := factory] createEmptyItem :: Gtk.ListItem -> IO () createEmptyItem listItem = do label <- new Gtk.Label [] set listItem [#child := label] populateItem :: Gtk.ListItem -> IO () populateItem listItem = do item <- fromJust <$> get listItem #item person <- fromJust <$> CustomStoreItem.fromObject @Person storeItem child <- fromJust <$> get convListItem #child label <- fromJust <$> Gtk.castTo Gtk.Label child set label [ #label := name person <> ", " <> Text.pack (show (age person)) ]