TreeView: internal VAdjustment delayed?



Hi,

any hints welcome for this strange behaviour (latest stable
gtk but previous versions as well, here on win32, not tested
on linux):

I use a TreeView as a simple list to display log messages.
To scroll it to the bottom automatically after each new line
I use gtk_tree_view_get_vadjustment() and then
gtk_adjustment_set_value() to the maximum value
(upper-page_size). For debugging reasons I have not even
attached a scrollbar.

The problem: It appears that the 'upper' value of the
Adjustment is updated by gtk very delayed, so scrolling
mostly does not work for the last new line.

Here is the sequence in pseudo code. Sidenote: I use
g_idle_add() to wrap gtk functions and make it thread-safe
(which works in all other places for years):


1) printf( current upper-value of the VAdjustment): 500

2) Creating an idle function (g_idle_add) which adds a row
to the bottom of the list-store of the TreeView
(gtk_list_store_append).  After that but still inside this
idle function: printf( current upper-value of the
VAdjustment): Still 500.

3) Another idle function is added:
printf( current upper-value of the VAdjustment): Still 500!
Now, still inside this idle function, the TreeView shall be
scrolled to the bottom by gtk_tree_view_get_vadjustment()
and gtk_adjustment_set_value( upper - page_size). Of course,
no scrolling happens, since the upper value has still not
changed yet.

4) For debugging, sleeping 1 second.

5) Repeating step 3. Now the upper value has changed to 520,
scrolling works.

Any hints welcome...
 Felix




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