diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-08-09 15:51:39 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-08-09 15:51:39 +0000 |
commit | 38579d7edd7bc5ea0d11872f02720c3c9f90ebd2 (patch) | |
tree | fb0920812a0b18aaaaf41f23edbf577abb530650 /perl-install/interactive | |
parent | 705b50e8d9e634e3738370eff8451ab3f9feacfd (diff) | |
download | drakx-38579d7edd7bc5ea0d11872f02720c3c9f90ebd2.tar drakx-38579d7edd7bc5ea0d11872f02720c3c9f90ebd2.tar.gz drakx-38579d7edd7bc5ea0d11872f02720c3c9f90ebd2.tar.bz2 drakx-38579d7edd7bc5ea0d11872f02720c3c9f90ebd2.tar.xz drakx-38579d7edd7bc5ea0d11872f02720c3c9f90ebd2.zip |
really make ComboBox with tree inside work
Diffstat (limited to 'perl-install/interactive')
-rw-r--r-- | perl-install/interactive/gtk.pm | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm index f35ddb438..045b7e4f1 100644 --- a/perl-install/interactive/gtk.pm +++ b/perl-install/interactive/gtk.pm @@ -558,8 +558,6 @@ sub ask_fromW { my @formatted_list = map { may_apply($e->{format}, $_) } @{$e->{list}}; $e->{formatted_list} = \@formatted_list; - my $sep = quotemeta $e->{separator}; - my @flat_formatted_list = $e->{separator} ? map { top(split($sep, $_)) } @formatted_list : @formatted_list; my @l = sort { $b <=> $a } map { length } @formatted_list; my $width = $l[@l / 16]; # take the third octile (think quartile) @@ -597,18 +595,24 @@ sub ask_fromW { $set = sub { my $s = may_apply($e->{format}, $_[0]); if ($model) { - $model->set($w->get_active_iter, 0 => $s); - #$w->set_active($model->{indexes}{$s}); + eval { + my $i = find_index { $s eq $_ } @{$e->{formatted_list}}; + my $path_str = $model->{path_str_list}[$i]; + $w->set_active_iter($model->get_iter_from_string($path_str)); + }; } else { $w->set_text($s) if $s ne $w->get_text && $_[0] ne $w->get_text; } }; - $get = sub { - my $s = $model ? $model->get($w->get_active_iter, 0) : $w->get_text; - my $i = eval { find_index { $s eq $_ } @flat_formatted_list }; - $s = $e->{list}[$i] if defined $i; - $s = top(split($sep, $s)) if $e->{separator}; - $s; + $get = sub { + my $i = $model ? do { + my $s = $model->get_string_from_iter($w->get_active_iter); + eval { find_index { $s eq $_ } @{$model->{path_str_list}} }; + } : do { + my $s = $w->get_text; + eval { find_index { $s eq $_ } @formatted_list }; + }; + defined $i ? $e->{list}[$i] : $w->get_text; }; } else { $w = Gtk2::Entry->new; |