Re: Restoring a List View's position
- From: Matthew Braid <ptkperl mdb id au>
- To: "gtk-perl-list gnome org List" <gtk-perl-list gnome org>
- Subject: Re: Restoring a List View's position
- Date: Tue, 17 Mar 2009 16:25:49 +1000
Hi all,
2009/3/17 muppet <scott asofyet org>:
Were you asking for the visible range after having removed the model?
I thought that might be the issue since I was disconnecting the model
to load data and reconnecting afterwards, but the reconnection happens
before the position restore.
You may need to wait for the adjustment change to take effect. Try setting
the new scrollbar positions in an idle handler. This may result in
undesirable flicker, in which case, your next idea isn't terribly
inappropriate.
This seems to have done the trick - even the standard priority seems
to do it with little to no flicker as far as I can tell, and puts it
exactly at the right place. Ta :)
Incidentally I tried a timeout handler as well - still worked, but
there was visible flicker no matter how 'soon' I scheduled it for. 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]);
Well, if you want it to look to the user as though the view is just as he
left it, then simply scrolling a certain row onscreen may not be sufficient.
If i understand correctly, when you scroll to the list item, it's somewhat
random as to where it will be (depends on your parameters). So, scroll to
point isn't that bad of a compromise.
True - i forgot that scroll_to_cell doesn't really define where in the
view the cell will be.
2009/3/17 Kevin Ryde <user42 zip com au>:
I initially tried using $treeview->get_visible_range and
$treeview->scroll_to_cell, but get_visible_range seems to be a little
flakey on my system and often aborts with a message about some
assertion failing (something != nil I think).
Sounds like a bug.
It probably is - it seems the age of the current (approved) install of
Gtk and perl/Gtk is somewhat ancient. Maybe it would have been better
if I didn't find a solution to force an upgrade :)
MB
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]