I’m not sure if this is the appropriate place to raise these points and I would be happy to raise bugs / improvement requests in the appropriate places if members of this group think it best.
Also I don’t mean these to be critical of the ongoing GTK4 development direction, but just hopefully useful feedback.
I have just recently finished converting my little application to GTK4 and updating it to get rid of all the deprecated usages. This mainly consisted of converting the use of TreeView
and ListStore
to using ColumnView
and an implementation of ListModel
.
While this has generally been reasonably straight forward and I have a couple of outstanding features that I’m not able to complete. This, in my humble opinion, is because of some missing and/or incorrect behaviour in the new features.
- TreePath funtionality.
In one area of the application I have a simple two level tree. If the user selects a lower leaf of the tree, there is no straight forward way to know at what position in the tree the parent branch is.
-B1
|___L1
|___L2
|___L3
-B2
|___L4
|___L5
In the above example, L4 is selected there is no way of knowing its parent is in position 2. Similarly if B2 is selected, there is no way of knowing it is in position 2 as the index returned from the selection depends on the expansion state of the tree. It is easily possible to get the row from the TreeListModel and the underlying object, but without storing redundant (and therefore error prone) data in the underlying objects or by manually walking the tree and counting parent and child rows, the structure of a selection is hidden.
This is important to my application as I have an ordered model and a need to allow the user to reorder the items in both the parent and child models, e.g. move branch B2 before B1.
-
Selection behaviour
In a ColumnView, a mouse click with button 2 or 3 does not cause the clicked on row to be selected. So when using aGestureClick
it is not possible to know what row was a subject of the click and so showing a popup (context) menu and performing an action on the selected rows breaks from the accustomed conventions including the behaviour of TreeView. There is a potential workaround by settingSingleClickActivate
but that introduces a whole range of other undesireable behaviours when combined with a popup menu. The main problem here is that the seleced item in the underlying list will change if the user accidentally allows the mouse pointer to wander outside the popup menu. This can bee seen here Wrong folder trashed when using right click->"Move to trash" (#157) · Issues · GNOME / baobab · GitLab. -
TreeListModel invalidation
In my particular case, the UI is not well aware of how the underlying model may have changed. Imagine the model is backed by an external database and the user presses “Refresh”. In my case each time I need to display an updated view of the model I completely rebuild the TreeListModel, SelectionModel, etc and reconnect them to the view. While this is easily done a simpleinvalidate()
method on the model would be a convienience. -
Access to Row widget and children.
There is no apparent way to get the x,y coordinates of a selected row in the ColumnView. This is a usability issue when navigating with a keyboard and showing a popup (context) menu, as there is no way to locate the menu near to the selected row.
Studying the code for Gnome Files, they use a workaround of storing a pointer to one of the widgets in the model object within thebind
method of theListItemFactory
. This seems really unacceptable as, afaik, these widgets are reused and there are no gaurantees in the API that suggests this is safe.