summaryrefslogtreecommitdiffstats
path: root/drakwizard.pl
diff options
context:
space:
mode:
authorArnaud Desmons <adesmons@mandriva.com>2002-10-07 15:52:17 +0000
committerArnaud Desmons <adesmons@mandriva.com>2002-10-07 15:52:17 +0000
commit425d8154b0d94c2fa96681c4beaa3412884a7004 (patch)
tree8ca5b9d2b78044d514be6576d573117a679f1b86 /drakwizard.pl
parent79cc2a3141217682321c18b459a75504c908c5e9 (diff)
downloaddrakwizard-425d8154b0d94c2fa96681c4beaa3412884a7004.tar
drakwizard-425d8154b0d94c2fa96681c4beaa3412884a7004.tar.gz
drakwizard-425d8154b0d94c2fa96681c4beaa3412884a7004.tar.bz2
drakwizard-425d8154b0d94c2fa96681c4beaa3412884a7004.tar.xz
drakwizard-425d8154b0d94c2fa96681c4beaa3412884a7004.zip
disable works
Diffstat (limited to 'drakwizard.pl')
-rwxr-xr-xdrakwizard.pl69
1 files changed, 54 insertions, 15 deletions
diff --git a/drakwizard.pl b/drakwizard.pl
index 17c442da..f2822fb4 100755
--- a/drakwizard.pl
+++ b/drakwizard.pl
@@ -20,7 +20,7 @@
use lib qw(/usr/lib/libDrakX);
use strict;
-use vars qw($Wizard_title $Wizard_pix_up $lib_script $perl_module %variable $in $rpm %chooser_hash $welcome $perl_module_name $verbose %description $summary $summary_func);
+use vars qw($Wizard_title $Wizard_pix_up $lib_script $perl_module %variable $in $rpm %chooser_hash $welcome $perl_module_name $verbose %description $summary $summary_func %disabled);
use XML::Parser;
use standalone;
@@ -67,6 +67,7 @@ if (!defined($ARGV[0])) {
}
my $o = [];
+my $o2 = [];
my $xmltree = XML::Parser->new(Style => 'Tree')->parsefile($ARGV[0]);
local $_ = join '', @ARGV;
@@ -77,10 +78,12 @@ local $_ = join '', @ARGV;
$::isWizard = 1;
if (/-summary/) {
+ get_parameter($o2, $xmltree);
$::Wizard_finished = 1;
- get_summary($o, $xmltree);
+ get_summary($o2, $xmltree);
+ robot($_[0], $o2->[0]);
my $data = map_freetext($summary->{freetext});
- $in->ask_from("summary", "info", $data) && $::{$perl_module_name."::"}{"$summary_func"}->();
+ $in->ask_from("summary", "", $data) && $::{$perl_module_name."::"}{"$summary_func"}->();
}
else {
get_parameter($o, $xmltree);
@@ -115,12 +118,6 @@ sub load_wizard {
}
}
-sub push_options {
- my ($leaf) = @_;
- $chooser_hash{$leaf->{description}} = $leaf->{value};
- $description{$leaf->{value}} = $leaf->{description};
-}
-
sub map_freetext {
my @liste;
my $valeur;
@@ -149,14 +146,22 @@ sub map_freetext {
$ENV{$_->{variableName}} = $ENV{$variable{$_->{variableName}}};
if ($_->{main_order} eq 'entry') {
{ label => _($_->{helpText}),
- val => \$ENV{$variable{$_->{variableName}}}, type => $_->{main_order} } }
+ val => \$ENV{$variable{$_->{variableName}}}, type => $_->{main_order},
+ disabled => $disabled{$_->{variableName}} }
+ }
elsif ($_->{main_order} eq 'bool') { { val => \$ENV{$variable{$_->{variableName}}},
type => $_->{main_order},
- text => translate($_->{helpText}) } }
+ text => translate($_->{helpText}),
+ disabled => $disabled{$_->{variableName}} }}
elsif ($_->{main_order} eq 'combo') {
{ label => $_->{helptext}, val => \$ENV{$variable{$_->{variableName}}},
- list => [@liste], type => $_->{main_order} }
- }
+ list => [@liste], type => $_->{main_order},
+ disabled => $disabled{$_->{variableName}} }}
+ elsif ($_->{main_order} eq 'field') { { val =>
+ $description{$ENV{$variable{$_->{variableName}}}}?
+ $description{$ENV{$variable{$_->{variableName}}}} :
+ $ENV{$variable{$_->{variableName}}},
+ label => $_->{helpText} } }
} @{$_[0]};
\@data;
}
@@ -175,6 +180,7 @@ sub get_parameter {
Variable => sub {
$variable{$leaf->{name}} = $leaf->{shellVariable};
$ENV{$variable{$leaf->{name}}} = $leaf->{defaultValue};
+ $disabled{$leaf->{name}} = 0;
},
Page => sub {
!$welcome and $welcome = $page;
@@ -212,7 +218,8 @@ sub get_parameter {
: ($tag eq 'Boolean') ? 'bool'
: ($leaf->{editable} eq 'true') ? 'entry'
: 'field')};
- },
+ $page->{is_defined}->{$leaf->{variableName}} = 1;
+ },
Chooser => \&$common_freetext_chooser,
Boolean => \&$common_freetext_chooser,
Option => sub {
@@ -319,6 +326,36 @@ sub navigation {
navigation($o, $next, $prev);
}
+sub robot {
+ my ($widget, $page) = @_;
+
+ if ($page->{is}) {
+ my ($val, $arg) = split(/\s*?=\s*/, $page->{is});
+ print "$val:$arg\n";
+ if ($val eq $widget) {
+ foreach (@{$page->{freetext}}) {
+ $disabled{$_->{variableName}} = $arg ? ($ENV{$variable{$val}} != $arg) : !$ENV{$variable{$val}};
+ }
+ }
+ }
+ robot($widget, $page->{next_page}) if $page->{next_page};
+}
+
+sub callback {
+ return 1 if ($disabled{$_[0]} == 1);
+ foreach (keys %variable) {
+ my $toto = $ENV{$variable{$_}};
+ my $tata = $_;
+ foreach (keys %chooser_hash) {
+ if ($toto eq $_) {
+ $ENV{$variable{$tata}} = $chooser_hash{$_};
+ }
+ }
+ }
+ $disabled{$_[0]} = 0;
+ robot($_[0], $o2->[0]);
+}
+
sub get_summary {
my ($o, $tree, $tag, $page) = @_;
@@ -333,13 +370,14 @@ sub get_summary {
Variable => sub {
$variable{$leaf->{name}} = $leaf->{shellVariable};
$ENV{$variable{$leaf->{name}}} = $leaf->{defaultValue};
+ $disabled{$leaf->{name}} = sub { callback($leaf->{name})};
},
Freetext => $common_freetext_chooser = sub {
push @{$summary->{freetext}}, { %$leaf, main_order =>
(($tag eq 'Chooser') ? 'combo'
: ($tag eq 'Boolean') ? 'bool'
: ($leaf->{editable} eq 'true') ? 'entry'
- : 'field')};
+ : 'hidden')};
},
Chooser => \&$common_freetext_chooser,
Boolean => \&$common_freetext_chooser,
@@ -347,6 +385,7 @@ sub get_summary {
push @{${$summary->{freetext}}[-1]->{Option}}, $leaf->{description};
$chooser_hash{$leaf->{description}} = $leaf->{value};
$description{$leaf->{value}} = $leaf->{description};
+ $disabled{$leaf->{description}} = sub {callback($leaf->{description})};
});
$actions{$tag} and &{$actions{$tag}};
} elsif ($leaf=~ /\w\D/){