Skip to content

Draft: Port SysprofMarksPage to GtkListView

Ivan Molodetskikh requested to merge YaLTeR/sysprof:marks-page-list-view into master

A few preparatory commits followed by the main deal.

image

Issues I was unable to fix:

  1. Just like the current TreeView implementation, things start losing their allocations left and right as soon as you open the page. If I remove the call to gtk_scrolled_window_set_hadjustment (), the issue disappears (but of course then the marks view will have a separate scroll bar). If I replace ListView with a long enough Label, the issue is still there. I'd say this is some sort of a bug with ScrolledWindow (the "Replace TextView with Label" fix would also suggest that).
  2. Resizing the window when scrolled to the right jumps the ListView to some weird horizontal position. Perhaps related to the above.
  3. Sometimes the duration box inside the row widget does not show up until I do something like toggle the dark style. As far as I can tell with debug prints, it does get allocated properly when that happens. Perhaps some GTK bug.
ListView brings a number of advantages over TreeView, such as:
- ability to use real row widgets and style them with CSS,
- ability to use property bindings,
- avoiding an unreasonably wide texture when zoomed in causing issues
  with the GL renderer,
- speed improvements (probably),
- not being soft-deprecated.

This change consists of a number of steps.

1. Extract SysprofMarksModel's Item struct into a proper
   SysprofMarksModelItem object.

We are changing our TreeModel to a ListModel, which returns GObjects.
Exposing Item fields as properties allows for using the natural .ui
property binding workflow for most of the labels that were previously
updated in code.

2. Change SysprofMarksModel from a TreeModel to a ListModel.

This mainly involves removing a lot of TreeModel interface code as the
ListModel interface is vastly simpler. One functional change is that
instead of storing a GArray of Items, the model now stores a GPtrArray
of SysprofMarksModelItems. We cannot construct them on-demand because
ListModels must return the same GObject pointer when queried for the
same item position.

3. Change SysprofCellRendererDuration to a SysprofMarksDurationWidget.

One of the benefits of ListView is that it allows us to use real row
widgets instead of cell renderers. We take full advantage of this by
replacing custom snapshot drawing with a Box styled with CSS and a
Label. The new widget exposes properties to be bound to
SysprofMarksModelItem.

The measure function always returns the zoom manager width, and the
usual maximum of the children's sizes for the height. Importantly, we do
not want to depend on the label's width here for both adjustment value
compatibility and scrolling performance reasons.

The allocation computes the Box's width the same way as the cell
renderer did and takes a mandatory max with its min width, then
allocates the label after a small padding. SysprofMarksDurationWidget
uses overflow = hidden to prevent the label overflowing to the right
(remember that our width must not depend on the label's width).

4. Change SysprofMarksPage to use a ListView.

Remove some now-unused TreeView code, change other to the ListView
equivalent. Add a manual Duration header label to mimic that of the
TreeView column. Replace manual updates with property bindings as much
as possible.

Merge request reports