summaryrefslogtreecommitdiffstats
path: root/drakwizard.pl
diff options
context:
space:
mode:
authorArnaud Desmons <adesmons@mandriva.com>2002-08-02 13:51:33 +0000
committerArnaud Desmons <adesmons@mandriva.com>2002-08-02 13:51:33 +0000
commite505c007ae0aef872b88ca6f00f513f4875b3562 (patch)
tree5a549d03ab0026236c8afe2f0a9d2014e1931201 /drakwizard.pl
parent8c5b8739f9ab1f86d386c68f0476b14d4ca1ac12 (diff)
downloaddrakwizard-e505c007ae0aef872b88ca6f00f513f4875b3562.tar
drakwizard-e505c007ae0aef872b88ca6f00f513f4875b3562.tar.gz
drakwizard-e505c007ae0aef872b88ca6f00f513f4875b3562.tar.bz2
drakwizard-e505c007ae0aef872b88ca6f00f513f4875b3562.tar.xz
drakwizard-e505c007ae0aef872b88ca6f00f513f4875b3562.zip
added subWizard support
Diffstat (limited to 'drakwizard.pl')
-rwxr-xr-xdrakwizard.pl102
1 files changed, 58 insertions, 44 deletions
diff --git a/drakwizard.pl b/drakwizard.pl
index 09c31065..039e69ba 100755
--- a/drakwizard.pl
+++ b/drakwizard.pl
@@ -20,7 +20,7 @@
use lib qw(/usr/lib/libDrakX);
#use strict;
-use vars qw($wizard_title $lib_script $perl_module %variable $in);
+use vars qw($wizard_title $lib_script $perl_module %variable $in $welcome);
use XML::Parser;
use standalone;
@@ -37,7 +37,7 @@ sub member { my $e = shift; foreach (@_) { $e eq $_ and return 1 } 0 }
sub get_parameter {
my ($o, $tree, $tag ,$page) = @_;
-
+
foreach my $leaf (@$tree) {
if (ref($leaf) eq 'ARRAY') {
$page = get_parameter($o, $leaf, $tag, $page);
@@ -46,12 +46,19 @@ sub get_parameter {
my %actions = (
Wizard => sub {
($wizard_title, $lib_script, $perl_module) = @{$leaf}{qw(wizardTitle libScript perlModule)};
+ if ($perl_module) {
+ require $perl_module;
+ }
+ if ($perl_module =~ /.*\/(.*)\.pm/) {
+ $::perl_module_name = $1;
+ }
},
Variable => sub {
$variable{$leaf->{name}} = $leaf->{shellVariable};
$ENV{$leaf->{shellVariable}} = $leaf->{defaultValue};
},
- Page => sub {
+ Page => sub {
+ !$welcome and $welcome = $page;
my $old_page = $page;
push @$o, $page = { %$leaf };
$old_page->{next_page} = $page;
@@ -65,8 +72,11 @@ sub get_parameter {
$page->{info} =~ s/\\a/\&/g;
},
Freetext => $common_freetext_chooser = sub {
- push @{$page->{freetext}}, { %$leaf, main_order => ($tag eq 'Chooser') ? 'combo'
- : (($tag eq 'Boolean') ? 'bool' : 'entry') };
+ push @{$page->{freetext}}, { %$leaf, main_order =>
+ (($tag eq 'Chooser') ? 'combo'
+ : ($tag eq 'Boolean') ? 'bool'
+ : ($leaf->{editable} eq 'true') ? 'entry'
+ : 'field')};
},
Chooser => \&$common_freetext_chooser,
@@ -89,16 +99,19 @@ sub find_page {
sub display {
my ($o, $page) = @_;
-
- if ( $page->{nextFinish} eq 'true') {
+
+ if ($page->{name} eq $welcome->{name}) {
+ $::Wizard_no_previous = 1;
+ }
+ if ($page->{nextFinish} eq 'true') {
$::Wizard_no_previous = 1;
$in->ask_okcancel(translate($page->{name}),
- translate($page->{info}), 1) or quit_global($in, 0);
+ translate($page->{info})) or quit_global($in, 0);
$in->exit;
} elsif (!$page->{freetext}) {
- $in->ask_okcancel(translate($page->{name}),
- translate($page->{info}), 1) or navigation($o, $page->{old_page});
- }
+ $in->ask_okcancel(translate($page->{name}),
+ translate($page->{info})) or navigation($o, $page->{old_page});
+ }
else {
my $valeur;
my @liste;
@@ -106,13 +119,13 @@ sub display {
for ($_->{fillScript}) {
system("source $lib_script ; $_->{fillScript}");
}
- if($_->{main_order} eq 'combo'){
+ if ($_->{main_order} eq 'combo') {
if($_->{fillScript}){
$valeur = `$_->{fillScript}`;
while( $valeur =~ /(.+)\n/g){
push @liste, $1;
}
- }else{
+ } else{
@liste = @{$_->{Option}};
push @list, $1;
}
@@ -121,6 +134,8 @@ sub display {
val => \$ENV{$variable{$_->{variableName}}}, type => $_->{main_order} }
: ($_->{main_order} eq 'bool') ? { val => \$ENV{$variable{$_->{variableName}}}, type => $_->{main_order},
text => translate($_->{helpText}, advanced => 1) }
+ : ($_->{main_order} eq 'field') ? { val => $ENV{$variable{$_->{variableName}}},
+ label => translate($_->{helpText}) }
: { label => translate($_->{helpText}), val => \$ENV{$variable{$_->{variableName}}},
list => [@liste, ""], type => $_->{main_order} };
} @{$page->{freetext}};
@@ -128,6 +143,7 @@ sub display {
$in->ask_from(translate($page->{name}), translate($page->{info}),
\@data) or navigation($o, $page->{old_page});
foreach(@{$page->{freetext}}) {
+ print "$_->{variableName} : $ENV{$variable{$_->{variableName}}}\n";
if($_->{main_order} eq 'bool'){
$ENV{$variable{$_->{variableName}}} = $ENV{$variable{$_->{variableName}}} ? 1 : 0;
}
@@ -143,32 +159,37 @@ sub navigation {
display($o, $page);
my ($next, $prev) = do {
- if (defined $perl_module_name && $page->{func}) {
- @func_arg = split(/\s/, $page->{func});
- $modStatus = $::{$perl_module_name."::"}{"$func_arg[0]"}->($func_arg[1]);
-
- if ($page->{Target}->{jumpIndex}) {
- find_page($o, $page->{Target}->{jumpIndex}->{int($modStatus)}), $page;
- }
- elsif ($page->{jumpPage}) {
- find_page($o, $page->{jumpPage}), $page->{old_page};
- }
+ if (defined $perl_module_name && $page->{func}) {
+ @func_arg = split(/\s/, $page->{func});
+ $modStatus = $::{$perl_module_name."::"}{"$func_arg[0]"}->($func_arg[1]);
+ if ($page->{Target}->{jumpIndex}) {
+ find_page($o, $page->{Target}->{jumpIndex}->{int($modStatus)}), $page;
}
- elsif($page->{jumpScript}) {
- system("source $lib_script ; $page->{jumpScript}");
- if ($page->{Target}->{jumpIndex}) {
- $? = $? >> 8;
- find_page($o, $page->{Target}->{jumpIndex}->{$?}), $page;
- }
- else {
- $page->{next_page}, $page->{old_page};
- }
+ elsif ($page->{jumpPage}) {
+ find_page($o, $page->{jumpPage}), $page->{old_page};
}
+ }
+ elsif($page->{jumpScript}) {
+ system("source $lib_script ; $page->{jumpScript}");
+ if ($page->{Target}->{jumpIndex}) {
+ $? = $? >> 8;
+ find_page($o, $page->{Target}->{jumpIndex}->{$?}), $page;
+ }
else {
- $page->{next_page}, $page;
+ $page->{next_page}, $page->{old_page};
}
- };
- navigation($o, $next, $prev);
+ }
+ elsif($page->{subWizard}) {
+ my $o = [];
+ my $xmltree = XML::Parser->new(Style => 'Tree')->parsefile($page->{subWizard});
+ get_parameter($o, $xmltree);
+ eval { navigation($o, $o->[0]); };
+ }
+ else {
+ $page->{next_page}, $page;
+ }
+ };
+ navigation($o, $next, $prev);
}
my $o = [];
@@ -176,18 +197,11 @@ my $xmltree = XML::Parser->new(Style => 'Tree')->parsefile($ARGV[0]);
get_parameter($o, $xmltree);
-if ($perl_module) {
- require $perl_module;
-}
-
-if ($perl_module =~ /.*\/(.*)\.pm/) {
- $::perl_module_name = $1;
-}
-
!$::isEmbedded && $in->isa('interactive_gtk') and $::isWizard=1;
$::Wizard_title = translate($wizard_title);
$::Wizard_pix_up = "wiz_drakconnect.png";
$::direct = /-direct/;
$::Wizard_no_previous = 1;
$::isWizard = 1;
-navigation($o, $o->[0]);
+eval { navigation($o, $o->[0]); };
+$in->exit if $@ =~ /wizcancel/;