From 2e4e1e142c254e7c503360ce4954e2d8de402d66 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Mon, 3 Mar 2003 21:14:51 +0000 Subject: a few treeview/list fixes: - when selecting a value, scroll it like in treeview/tree - use saved_default_val dirty hackery to really honour default value - fix not calling $select again when trying to select an already selected value (happens when clicking or keyboard-selecting; broken, it ended up in always scrolling the selected value to the center) --- perl-install/interactive/gtk.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'perl-install') diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm index 1dd35e951..e5e6e5183 100644 --- a/perl-install/interactive/gtk.pm +++ b/perl-install/interactive/gtk.pm @@ -74,7 +74,10 @@ sub create_treeview_list { my $textcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new(), 'text' => 0); $list_tv->append_column($textcolumn); - my $select = sub { $list_tv->set_cursor($_[0], $textcolumn, 0) }; + my $select = sub { + $list_tv->set_cursor($_[0], undef, 0); + $list_tv->scroll_to_cell($_[0], undef, 1, 0.5, 0); + }; my ($starting_word, $start_reg) = ('', '^'); my $timeout; @@ -134,7 +137,7 @@ sub create_treeview_list { eval { my $nb = find_index { $_ eq $v } @{$e->{list}}; my ($old_path) = $list_tv->get_cursor; - if (!$old_path || $nb != $old_path) { + if (!$old_path || $nb != $old_path->to_string) { $select->(my $path = Gtk2::TreePath->new_from_string($nb)); $path->free; } @@ -482,6 +485,7 @@ sub ask_fromW { $size = 6; ($w, $set, $focus_w) = create_treeview_list($e, $may_go_to_next, $changed, sub { $do_action->('Modify') if $_[1]->type =~ /^2/ }); + $e->{saved_default_val} = ${$e->{val}}; %buttons = map { my $action = $_; @@ -509,7 +513,12 @@ sub ask_fromW { ($w, $set, $size) = create_treeview_tree(@para, $e->{tree_expanded}); $e->{saved_default_val} = ${$e->{val}}; #- during realization, signals will mess up the default val :( } else { - ($w, $set, $focus_w) = $use_boxradio ? create_boxradio(@para) : create_treeview_list(@para); + if ($use_boxradio) { + ($w, $set, $focus_w) = create_boxradio(@para); + } else { + ($w, $set, $focus_w) = create_treeview_list(@para); + $e->{saved_default_val} = ${$e->{val}}; + } } if (@{$e->{list}} > (@$l == 1 ? 10 : 4) || $e->{add_modify_remove}) { $has_scroll = $expand = 1; -- cgit v1.2.1