summaryrefslogtreecommitdiffstats
path: root/perl-install/interactive/gtk.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2005-05-27 00:15:56 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2005-05-27 00:15:56 +0000
commitae310b76ccf56afbefa7e7b036f58a75df863e4a (patch)
treedaceae89d4b5d15da6e9b7899997cb2b9d35a530 /perl-install/interactive/gtk.pm
parent2729e7e4a9b1bdbce7cd97b1df0082472e4009aa (diff)
downloaddrakx-backup-do-not-use-ae310b76ccf56afbefa7e7b036f58a75df863e4a.tar
drakx-backup-do-not-use-ae310b76ccf56afbefa7e7b036f58a75df863e4a.tar.gz
drakx-backup-do-not-use-ae310b76ccf56afbefa7e7b036f58a75df863e4a.tar.bz2
drakx-backup-do-not-use-ae310b76ccf56afbefa7e7b036f58a75df863e4a.tar.xz
drakx-backup-do-not-use-ae310b76ccf56afbefa7e7b036f58a75df863e4a.zip
(ask_fromW) fix set/get from sub leaf of ComboBox with tree
Diffstat (limited to 'perl-install/interactive/gtk.pm')
-rw-r--r--perl-install/interactive/gtk.pm18
1 files changed, 11 insertions, 7 deletions
diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm
index 0438dfdd0..7435384cc 100644
--- a/perl-install/interactive/gtk.pm
+++ b/perl-install/interactive/gtk.pm
@@ -558,6 +558,8 @@ sub ask_fromW {
my @formatted_list = map { may_apply($e->{format}, $_) } @{$e->{list}};
$e->{formatted_list} = \@formatted_list;
+ my $sep = "\\" . $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)
@@ -582,6 +584,8 @@ sub ask_fromW {
$w->set_attributes($renderer, "pixbuf", 1);
$w->pack_start($renderer = Gtk2::CellRendererText->new, 0);
$w->set_attributes($renderer, "text", 2);
+ ${$e->{val}} = top(split($sep, ${$e->{val}})) if $e->{separator};
+
$w->set_active($model->{indexes}{ ref($e->{val}) ? may_apply($e->{format}, ${$e->{val}}) : $formatted_list[0] });
}
($real_w, $w) = ($w, $w->entry);
@@ -596,18 +600,18 @@ sub ask_fromW {
my $s = may_apply($e->{format}, $_[0]);
next if !($s ne $w->get_text && $_[0] ne $w->get_text);
if ($model) {
- $w->set_active($model->{indexes}{$s});
+ $model->set($w->get_active_iter, 0 => may_apply($e->{format}, $s));
+ #$w->set_active($model->{indexes}{$s});
} else {
$w->set_text($s);
}
};
$get = sub {
- my $s;
- if ($model) {
- $s = { reverse %{$model->{indexes}} }->{$w->get_active};
- } else { $s = $w->get_text }
- my $i = eval { find_index { $s eq $_ } @formatted_list };
- defined $i ? $e->{list}[$i] : $s;
+ 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;
};
} else {
$w = Gtk2::Entry->new;