diff options
author | Arnaud Desmons <adesmons@mandriva.com> | 2002-10-10 16:46:13 +0000 |
---|---|---|
committer | Arnaud Desmons <adesmons@mandriva.com> | 2002-10-10 16:46:13 +0000 |
commit | 64a0df9f767aa5646dec46e7948db9996aecabd9 (patch) | |
tree | fddb7816aa1578e4667038c86d2d12fc278c7e24 | |
parent | 3ed9ffaf8e87939a0489d5f5f4be41ab3b1a9014 (diff) | |
download | drakwizard-64a0df9f767aa5646dec46e7948db9996aecabd9.tar drakwizard-64a0df9f767aa5646dec46e7948db9996aecabd9.tar.gz drakwizard-64a0df9f767aa5646dec46e7948db9996aecabd9.tar.bz2 drakwizard-64a0df9f767aa5646dec46e7948db9996aecabd9.tar.xz drakwizard-64a0df9f767aa5646dec46e7948db9996aecabd9.zip |
chooser fillfunc, widget "is" tag
-rwxr-xr-x | drakwizard.pl | 139 |
1 files changed, 94 insertions, 45 deletions
diff --git a/drakwizard.pl b/drakwizard.pl index 1b438616..5d15cd50 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 %disabled); +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 $current_page %bool); use XML::Parser; use standalone; @@ -79,9 +79,9 @@ $::isWizard = 1; if (/-summary/) { get_parameter($o2, $xmltree); - $::Wizard_finished = 1; + $::Wizard_finished = 1; get_summary($o2, $xmltree); - robot($_[0], $o2->[0]); + is_disabled_summary($_[0], $o2->[0]); my $data = map_freetext($summary->{freetext}); $in->ask_from("summary", "", $data) && $::{$perl_module_name."::"}{"$summary_func"}->(); } @@ -127,10 +127,11 @@ sub load_wizard { } sub map_freetext { - my @liste; - my $valeur; + my @liste; + my $valeur; my @data = map { + my $toto = $_->{variableName}; if ($_->{main_order} eq 'combo') { if($_->{fillScript}){ @liste = (); @@ -140,38 +141,58 @@ sub map_freetext { $chooser_hash{$1} = $1; } } + if($_->{fillfunc}){ + @liste = $::{$perl_module_name."::"}{"$_->{fillfunc}"}->(); + } else { @liste = @{$_->{Option}}; } } + elsif ($_->{main_order} eq 'bool') { + } if ($_->{fillScript}) { $ENV{$variable{$_->{variableName}}} = `. $lib_script && $_->{fillScript}`; } - elsif (!$ENV{$variable{$_->{variableName}}} && $_->{fillfunc}) { - $ENV{$variable{$_->{variableName}}} = $::{$perl_module_name."::"}{"$_->{fillfunc}"}->(); - } if ($_->{main_order} eq 'entry') { + if (!$ENV{$variable{$_->{variableName}}} && $_->{fillfunc}) { + $ENV{$variable{$_->{variableName}}} = $::{$perl_module_name."::"}{"$_->{fillfunc}"}->(); + } { label => _($_->{helpText}), val => \$ENV{$variable{$_->{variableName}}}, type => $_->{main_order}, disabled => $disabled{$_->{variableName}}, help => $_->{help}} } - elsif ($_->{main_order} eq 'bool') { - { val => \$ENV{$variable{$_->{variableName}}}, - type => $_->{main_order}, - text => translate($_->{helpText}), - disabled => $disabled{$_->{variableName}}, - help => $_->{help} }} + elsif ($_->{main_order} eq 'bool') { + if ($_->{fillfunc}) { + my @list = $::{$perl_module_name."::"}{"$_->{fillfunc}"}->(); + map {{ val => \$bool{$_}, + label => "", + type => 'bool', + text => "$_", + help => "", + disabled => $disabled{$toto} + }} @list; + } + else { + { val => \$ENV{$variable{$_->{variableName}}}, + label => "", + type => $_->{main_order}, + text => translate($_->{helpText}), + disabled => $disabled{$_->{variableName}}, + help => $_->{help} } + } + } elsif ($_->{main_order} eq 'combo') { - { label => $_->{helptext}, val => \$ENV{$variable{$_->{variableName}}}, - 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}, - help => $_->{help}} } + { label => _($_->{helpText}), + val => \$ENV{$variable{$_->{variableName}}}, + 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}, + help => $_->{help}} } } @{$_[0]}; \@data; } @@ -190,7 +211,7 @@ sub get_parameter { Variable => sub { $variable{$leaf->{name}} = $leaf->{shellVariable}; $ENV{$variable{$leaf->{name}}} = $leaf->{defaultValue}; - $disabled{$leaf->{name}} = 0; + $disabled{$leaf->{name}} = sub { callback($leaf->{name})}; }, Page => sub { !$welcome and $welcome = $page; @@ -220,10 +241,10 @@ sub get_parameter { }, Freetext => $common_freetext_chooser = sub { push @{$page->{freetext}}, { %$leaf, main_order => - (($tag eq 'Chooser') ? 'combo' - : ($tag eq 'Boolean') ? 'bool' - : ($leaf->{editable} eq 'true') ? 'entry' - : 'field'), help => $leaf->{help}}; + (($tag eq 'Chooser') ? 'combo' + : ($tag eq 'Boolean') ? 'bool' + : ($leaf->{editable} eq 'true') ? 'entry' + : 'field'), help => $leaf->{help}}; }, Chooser => \&$common_freetext_chooser, Boolean => \&$common_freetext_chooser, @@ -231,6 +252,7 @@ sub get_parameter { push @{${$page->{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/){ @@ -290,6 +312,7 @@ sub navigation { my ($o, $page, $previous_page) = @_; $page->{old_page} ||= $previous_page; + $current_page = $page; display($o, $page); my ($next, $prev) = do { if (defined $perl_module_name && $page->{func}) { @@ -331,32 +354,57 @@ sub navigation { navigation($o, $next, $prev); } -sub robot { +sub is_disabled_summary { my ($widget, $page) = @_; if ($page->{is}) { - my ($val, $arg) = split(/\s*?=\s*/, $page->{is}); - if ($val eq $widget) { + my ($page_val, $page_arg) = split(/\s*?=\s*/, $page->{is}); + if ($page_val eq $widget) { foreach (@{$page->{freetext}}) { - $disabled{$_->{variableName}} = $arg ? ($ENV{$variable{$val}} != $arg) : !$ENV{$variable{$val}}; + my ($val, $arg) = split(/\s*?=\s*/, $_->{is}) if ($_->{is}); + $disabled{$_->{variableName}} = defined $arg ? $ENV{$variable{$val}} != $arg : !$ENV{$variable{$val}}; + $disabled{$_->{variableName}} = defined $page_arg ? ($ENV{$variable{$page_val}} != $page_arg) : !$ENV{$variable{$page_val}}; } } } - robot($widget, $page->{next_page}) if $page->{next_page}; + is_disabled_summary($widget, $page->{next_page}) if $page->{next_page}; } -sub callback { +sub is_disabled { + my ($widget, $page) = @_; + my $ret; + + foreach (@{$page->{freetext}}) { + if ($_->{is}) { + my ($val, $arg) = split(/\s*?=\s*/, $_->{is}); + $ret = defined $arg ? $ENV{$variable{$val}} != $arg : !$ENV{$variable{$val}}; + } + $disabled{$_->{variableName}} = $ret; + } +} + +sub callback_common { 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{$_}; - } - } + my $toto = $ENV{$variable{$_}}; + my $tata = $_; + foreach (keys %chooser_hash) { + if ($toto eq $_) { + $ENV{$variable{$tata}} = $chooser_hash{$_}; + } + } } - robot($_[0], $o2->[0]); + 0; +} + +sub callback_summary { + return 1 if callback_common($_[0]); + is_disabled_summary($_[0], $o2->[0]); +} + +sub callback { + return 1 if callback_common($_[0]); + is_disabled($_[0], $current_page); } sub get_summary { @@ -369,11 +417,12 @@ sub get_summary { my $common_freetext_chooser; my %actions = ( Wizard => sub { - load_wizard(@{$leaf}{qw(wizardTitle libScript perlModule rpm defaultImage summaryFunc)}) }, + load_wizard(@{$leaf}{ + qw(wizardTitle libScript perlModule rpm defaultImage summaryFunc)}) }, Variable => sub { $variable{$leaf->{name}} = $leaf->{shellVariable}; $ENV{$variable{$leaf->{name}}} = $leaf->{defaultValue}; - $disabled{$leaf->{name}} = sub { callback($leaf->{name})}; + $disabled{$leaf->{name}} = sub { callback_summary($leaf->{name})}; }, Freetext => $common_freetext_chooser = sub { my $main_order = ($tag eq 'Chooser') ? 'combo' @@ -390,7 +439,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})}; + $disabled{$leaf->{description}} = sub {callback_summary($leaf->{description})}; }); $actions{$tag} and &{$actions{$tag}}; } elsif ($leaf=~ /\w\D/){ |