Menu

Keeping a GTK4 SortListModel in Order When Items Change
📰

Keeping a GTK4 SortListModel in Order When Items Change

DEV Community: rust·Justin - FromTheArchitect·4 days ago
#R6EM9iXf
#devtorust#devto#dev#task#store
Reading 0:00
15s threshold

This is the seventh entry in A Field Guide to GTK Widgets , a series about which widget to reach for, when, and what bites you when you do. It picks up where the filter and sort post left off and replaces the workaround that one ended on. The complete, runnable code lives in the companion repo .

Where we left off

The last post built a task list four models deep: a GListStore at the bottom, then a FilterListModel , a SortListModel and a MultiSelection . It searched, hid done tasks and sorted three ways, and two parts of it were workarounds.

Hiding done tasks had to be a BoolFilter with watch-items switched on, because watch-items only sees properties through filters built from expressions. A CustomFilter was invisible to it. Sorting had nothing at all. SortListModel has no watch-items of its own, so the Mark done button finished by calling sorter.changed(gtk::SorterChange::Different) to make it look again.

That call only helps when the change goes through that button.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.