I have code that invokes scroll_to_cell to center a selection after a particular action, but the scrolling did not occur. It did not occur whether I called scroll_to_cell directly or in idle_add. I discovered yesterday that the scrolling did occur when I called scroll_to_cell in timeout_add with a time of 0. I would have thought that timeout_add with a time of 0 would be the same as idle_add.
To add to the mystery, there is another situation in which the same TreeView needs to scroll. scroll_to_cell in idle_add was working in that situation, but when I switched to timeout_add it stopped working. I solved both problems by calling scroll_to_cell twice, first in timeout_add and then in idle_add.
This surprising hack solves my problem, but I am curious to know whether anyone has any insight into why idle_add(…) and timeout_add(0, …) produce different results – and why scroll_to_cell is working only with one of them.