Scrolling to a GtkListBoxRow after adding it to a GtkListBox

Hey all,

I assume I'm missing something obvious here, but what's the right/best way to ensure that a GtkListBoxRow child is visible (i.e. scrolled to at least the bottom of the viewport) in a scrolled GtkListBox right after adding it? I have a GtkListBox as a child of a GtkScrolledWindow, and when adding rows I am connecting to the size-allocate signal of the GtkListBoxRow being added, and when that is triggered get the y-coord from the row's allocation, then set the scrolled window's vertical adjustment's value to that, then disconnect from size-allocate to avoid unwanted scrolling later if the row changes size.

This usually works, but sometimes doesn't, and so I'm trying to work out what a better approach is.

I assume that when it doesn't work, the problem is a race between the row being added and allocated vs the list box's allocation being adjusted and hence picked up by the scrolled window. One solution might be to connect to size-allocate on the list, but since multiple rows could be be added at the same time, it would be hard to work out which once should be getting scrolled to when the list's size-allocate signal is fired.

As I mention, connecting to size-allocate on the row usually works, but configure and map either don't work or don't help. Does anyone have any better suggestions?


⊨ Michael Gratton, Percept Wrangler.
⚙ <>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]