Hi again, Look at me, I'm replying to myself!
2009/3/17 Matthew Braid <ptkp...@mdb.id.au>: > In case someone is searching for some code to help in future, the > following works (although doesn't handle the horizontal scrollbars > obviously): > > Glib::Idle->add(sub { > my $args = shift; > my ($pos, $list) = @$args; > my $adj = $list->get_vadjustment; > return 0 if not defined $adj; ## JIC > $pos = $adj->upper if $pos > $adj->upper; # In case the list has shrunk since > $adj->set_value($pos); > 0; > }, [$listposition, $listview]); As it turns out, this is not quite correct. If a list's contents have shrunk significantly between loads, resetting the position to the adjustment's upper value may be too far. The position is where the _top_ of the scroll bar page should be, not the bottom, so if you tell it to go too low you get a weird empty list with a scroll bar with no page position and an active 'up' button. Scrolling up fixes everything, but is obviously not what the user (or the programmer for that matter) is expecting. To fix that little issue, the above becomes: Glib::Idle->add(sub { my $args = shift; my ($pos, $list) = @$args; my $adj = $list->get_vadjustment; return 0 if not defined $adj; ## JIC $pos = $adj->upper - $adj->page_size ## Set the top position correctly if $pos > $adj->upper - $adj->page_size; # In case the list has shrunk since $adj->set_value($pos); 0; }, [$listposition, $listview]); Ta, MB _______________________________________________ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list