Finding GtkColumnView sort order (Gtk4)

I’m working on a music player app, and I really like the GListModel / GtkColumnView API so far. One thing I’m having trouble with is sorting my underlying playlist GListModel when the GtkColumnViewColumn headers are clicked. I can use a GtkSortListModel, but this only updates the order the tracks are shown, so asking a playlist for its next track might return something different than what is presented to the user by the ColumnView. I was wondering if there is a good way to find out when a column header has been clicked so I can sort my playlist at the same time?

The sorting is part of the model in GtkListView. So if you need access to the sorted items, you’ll need to give your business logic access to the sort model.

Access to the sort model might be doable, but wouldn’t it revert to the unsorted order once I restart my app? I’d like to make sort order persistent (and allow different playlists to have different sort orders, if possible)

Ah, I see what your problem is now.

The only api we have to set up sort order programmatically is gtk_column_view_sort_by_column. And I don’t think we have sufficient api to extract and store the current state, when it comes to sorting. That might be worth filing as an issue.

One could argue that this is ui state that GTK should persist on its own, but… we don’t.

Sure. Should I submit that on the issue tracker? What info should I include in the description?

Should I submit that on the issue tracker?

That would be my suggestion.

What info should I include in the description?

If you mention the fact that you’d like to persist the sort order across restarts, that should be enough.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.