diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2000-08-06 00:38:57 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2000-08-06 00:38:57 +0000 |
commit | c75193289b79d4c0687aa6a597b51436568f8360 (patch) | |
tree | 0dde0958b1d48a729e30be420f9f8c94004b7ef8 /perl-install/interactive.pm | |
parent | c5d30320d3d120ccd291ccc7b7271400a4f20e4a (diff) | |
download | drakx-c75193289b79d4c0687aa6a597b51436568f8360.tar drakx-c75193289b79d4c0687aa6a597b51436568f8360.tar.gz drakx-c75193289b79d4c0687aa6a597b51436568f8360.tar.bz2 drakx-c75193289b79d4c0687aa6a597b51436568f8360.tar.xz drakx-c75193289b79d4c0687aa6a597b51436568f8360.zip |
no_comment
Diffstat (limited to 'perl-install/interactive.pm')
-rw-r--r-- | perl-install/interactive.pm | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm index 46abd8628..0ef20cc19 100644 --- a/perl-install/interactive.pm +++ b/perl-install/interactive.pm @@ -76,19 +76,30 @@ sub ask_warn($$$) { sub ask_yesorno($$$;$) { my ($o, $title, $message, $def) = @_; - ask_from_list2_($o, $title, $message, [ __("Yes"), __("No") ], $def ? "Yes" : "No") eq "Yes"; + ask_from_list_($o, $title, $message, [ __("Yes"), __("No") ], $def ? "Yes" : "No") eq "Yes"; } sub ask_okcancel($$$;$) { my ($o, $title, $message, $def) = @_; - ask_from_list2_($o, $title, $message, [ __("Ok"), __("Cancel") ], $def ? "Ok" : "Cancel") eq "Ok"; + ask_from_list_($o, $title, $message, [ __("Ok"), __("Cancel") ], $def ? "Ok" : "Cancel") eq "Ok"; } sub ask_from_list_ { my ($o, $title, $message, $l, $def) = @_; - @$l == 0 and die ''; - @$l == 1 and return $l->[0]; - goto &ask_from_list2_; + ask_from_listf($o, $title, $message, sub { translate($_[0]) }, @$l, $def); +} + +sub ask_from_listf_ { + my ($o, $title, $message, $f, $l, $def) = @_; + ask_from_listf($o, $title, $message, sub { translate($f->(@_)) }, $l, $def); +} +sub ask_from_listf { + my ($o, $title, $message, $f, $l, $def) = @_; + my %l; my $i = 0; foreach (@$l) { + $l{$f->($_, $i++)} = $_; + } + my $r = ask_from_list($o, $title, $message, [ keys %l ], $f->($def)) or return; + $l{$r}; } sub ask_from_list { @@ -98,13 +109,6 @@ sub ask_from_list { goto &ask_from_list2; } -sub ask_from_list2_($$$$;$) { - my ($o, $title, $message, $l, $def) = @_; - untranslate( - ask_from_list($o, $title, $message, [ map { translate($_) } @$l ], translate($def)), - @$l); -} - sub ask_from_list2($$$$;$) { my ($o, $title, $message, $l, $def) = @_; @@ -160,6 +164,10 @@ sub ask_from_treelistW($$$$;$) { +sub ask_many_from_list_refH { + my ($o, $title, $message, @l) = @_; + $o->ask_many_from_list_ref($title, $message, map { [ keys %$_ ], [ values %$_ ] } @l); +} sub ask_many_from_list_ref { my ($o, $title, $message, @l) = @_; $o->ask_many_from_list_with_help_ref($title, [ deref($message) ], map { ($_->[0], [], $_->[1]) } combine(2, @l)); |