diff options
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/ChangeLog | 16 | ||||
-rw-r--r-- | perl-install/Newt/Newt.xs | 52 | ||||
-rw-r--r-- | perl-install/install2.pm | 14 | ||||
-rw-r--r-- | perl-install/install_any.pm | 2 | ||||
-rw-r--r-- | perl-install/install_steps.pm | 1 | ||||
-rw-r--r-- | perl-install/interactive_newt.pm | 65 | ||||
-rwxr-xr-x | perl-install/standalone/adduserdrake | 10 |
7 files changed, 98 insertions, 62 deletions
diff --git a/perl-install/ChangeLog b/perl-install/ChangeLog index 28e9a770c..157cb6605 100644 --- a/perl-install/ChangeLog +++ b/perl-install/ChangeLog @@ -1,3 +1,17 @@ +2000-04-26 Pixel <pixel@mandrakesoft.com> + + * install_any.pm (relGetFile): added auto_inst to files to get + from Mandrake/base + + * install2.pm (main): changed auto_inst behaviour + + * standalone/adduserdrake: fix a bug (s/$o/$in/g) + + * interactive_newt.pm (ask_from_entries_refW): now handling + complete/changed/focus_out callbacks (at least more than before) + + * Newt/Newt.xs: added rough callback handling + 2000-04-25 François Pons <fpons@mandrakesoft.com> * printerdrake.pm: added support for PPA more easily, allow @@ -10,7 +24,7 @@ 2000-04-25 Pixel <pixel@mandrakesoft.com> - * lilo.pm (suggest): moved the generation of the keytable here. It + * lilo.pm (install): moved the generation of the keytable here. It is used by both lilo & grub (lilo is not always installed as was assumed) diff --git a/perl-install/Newt/Newt.xs b/perl-install/Newt/Newt.xs index 9423c85c0..97c056ee6 100644 --- a/perl-install/Newt/Newt.xs +++ b/perl-install/Newt/Newt.xs @@ -9,6 +9,13 @@ static void suspend() { newtResume(); } +static void componentCallback(newtComponent co, void *data) { + dSP; + PUSHMARK(SP); + perl_call_sv((SV *) data, G_DISCARD); +} + + typedef newtComponent Newt__Component; typedef newtGrid Newt__Grid; @@ -22,38 +29,6 @@ DESTROY() newtFinished(); } -void -changeColors() - CODE: -{ -const struct newtColors colors = { - "cyan", "black", /* root fg, bg */ - "black", "blue", /* border fg, bg */ - "white", "blue", /* window fg, bg */ - "white", "black", /* shadow fg, bg */ - "white", "blue", /* title fg, bg */ - "yellow", "cyan", /* button fg, bg */ - "white", "cyan", /* active button fg, bg */ - "yellow", "blue", /* checkbox fg, bg */ - "blue", "brown", /* active checkbox fg, bg */ - "yellow", "blue", /* entry box fg, bg */ - "white", "blue", /* label fg, bg */ - "black", "cyan", /* listbox fg, bg */ - "yellow", "cyan", /* active listbox fg, bg */ - "white", "blue", /* textbox fg, bg */ - "cyan", "black", /* active textbox fg, bg */ - "white", "blue", /* help line */ - "yellow", "blue", /* root text */ - "blue", /* scale full */ - "red", /* scale empty */ - "blue", "cyan", /* disabled entry fg, bg */ - "white", "blue", /* compact button fg, bg */ - "yellow", "red", /* active & sel listbox */ - "black", "brown" /* selected listbox */ -}; - newtSetColors(colors); -} - int newtInit() @@ -167,6 +142,13 @@ newtWinMenu(title,text,suggestedWidth,flexDown,flexUp,maxListHeight,list,def,but MODULE = Newt PACKAGE = Newt::Component PREFIX = newt +void +addCallback(co, callback) + Newt::Component co; + SV *callback; + CODE: + newtComponentAddCallback(co, componentCallback, callback); + Newt::Component newtCompactButton(left,top,text) int left; @@ -239,9 +221,9 @@ newtListboxGetCurrent(co) Newt::Component co; void -newtListboxSetCurrentByKey(co,key) +newtListboxSetCurrent(co,indice) Newt::Component co; - char * key; + int indice; void newtListboxSetWidth(co,width) @@ -249,7 +231,7 @@ newtListboxSetWidth(co,width) int width; int -newtListboxAddEntry(co,text,data) +newtListboxAddEntry(co,text) Newt::Component co; const char * text; CODE: diff --git a/perl-install/install2.pm b/perl-install/install2.pm index ca4d18cd3..e8e833133 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -544,9 +544,9 @@ sub main { text => sub { $o->{interactive} = "newt" }, stdio => sub { $o->{interactive} = "stdio"}, corporate => sub { $::corporate = 1 }, - ks => sub { $::auto_install = 1 }, - kickstart => sub { $::auto_install = 1 }, - auto_install => sub { $::auto_install = 1 }, + ks => sub { $::auto_install = $v }, + kickstart => sub { $::auto_install = $v }, + auto_install => sub { $::auto_install = $v }, simple_themes => sub { $o->{simple_themes} = 1 }, alawindows => sub { $o->{security} = 0; $o->{partitioning}{clearall} = 1; $o->{bootloader}{crushMbr} = 1 }, g_auto_install => sub { $::testing = $::g_auto_install = 1; $o->{partitioning}{auto_allocate} = 1 }, @@ -593,8 +593,12 @@ sub main { if ($::auto_install) { require install_steps_auto_install; - eval { $o = $::o = install_any::loadO($o, "Mandrake/auto_inst.cfg.pl") }; - eval { $o = $::o = install_any::loadO($o, "floppy") } if $@; + if ($::auto_install eq 'floppy') { + eval { $o = $::o = install_any::loadO($o, "auto_inst.cfg.pl") }; + eval { $o = $::o = install_any::loadO($o, "floppy") } if $@; + } else { + eval { $o = $::o = install_any::loadO($o, $::auto_install) }; + } if ($@) { log::l("error using auto_install, continuing"); undef $::auto_install; diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 103e1dd73..94922ba1a 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -61,7 +61,7 @@ sub relGetFile($) { local $_ = $_[0]; m,^(Mandrake|lnx4win)/, and return $_; /\.img$/ and return "images/$_"; - my $dir = m|/| ? "Mandrake/mdkinst" : /^(?:compss|compssList|compssUsers|filelist|depslist.*|hdlist.*)$/ ? + my $dir = m|/| ? "Mandrake/mdkinst" : /^(?:compss|compssList|compssUsers|filelist|depslist.*|hdlist.*|auto_inst.*)$/ ? "Mandrake/base/": "$::o->{packages}[2]{$asked_medium}{rpmsdir}/"; "$dir$_"; } diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 363149d52..44acc1958 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -719,7 +719,6 @@ sub setupBootloaderBefore { $e->{append} .= " prof=Home"; } lilo::suggest_floppy($o->{bootloader}) if $o->{security} <= 3; - $o->{bootloader}{keytable} ||= keyboard::keyboard2kmap($o->{keyboard}); } } diff --git a/perl-install/interactive_newt.pm b/perl-install/interactive_newt.pm index ac5947116..67238844b 100644 --- a/perl-install/interactive_newt.pm +++ b/perl-install/interactive_newt.pm @@ -17,7 +17,6 @@ my @wait_messages; sub new() { Newt::Init; - Newt::changeColors; Newt::Cls; Newt::SetSuspendCallback; open STDERR,">/dev/null" if $::isStandalone; @@ -121,17 +120,18 @@ sub ask_many_from_list_with_help_refW { sub ask_from_entries_refW { my ($o, $title, $messages, $l, $val, %hcallback) = @_; my ($title_, @okcancel) = deref($title); - my $ignore = 0; #-to handle recursivity + my $ignore; #-to handle recursivity + my $old_focus = -2; #-the widgets my @widgets = map { - $_->{type} = "entry" if $_->{type} eq "list" && !$_->{not_edit}; +#- $_->{type} = "entry" if $_->{type} eq "list" && !$_->{not_edit}; ${$_->{val}} ||= ''; - if ($_->{type} eq "list" && $_->{not_edit}) { + if ($_->{type} eq "list") { $_->{val} ||= $_->{list}[0]; my $w = Newt::Component::Listbox(-1, -1, 1, 0); $w->ListboxSetWidth(20); - map_index { $w->ListboxAddEntry($_, $_) } @{$_->{list}}; + $w->ListboxAddEntry($_) foreach @{$_->{list}}; $w; } elsif ($_->{type} eq "bool") { Newt::Component::Checkbox(-1, -1, $_->{text} || '', checkval(${$_->{val}}), " *"); @@ -154,17 +154,45 @@ sub ask_from_entries_refW { my @updates_inv = mapn { my ($w, $ref) = @_; - my $val = ${$ref->{val}}; sub { - $ref->{type} eq "bool" ? - $w->CheckboxSetValue(checkval($val)) : - $ref->{type} eq "list" ? - $w->ListboxSetCurrentByKey($val) : - $w->EntrySet($val, 1); + my $val = ${$ref->{val}}; + $ignore = 1; + if ($ref->{type} eq "bool") { + $w->CheckboxSetValue(checkval($val)); + } elsif ($ref->{type} eq "list") { + map_index { + $w->ListboxSetCurrent($::i) if $val eq $_; + } @{$ref->{list}}; + } else { + $w->EntrySet($val, 1); + } + $ignore = 0; }; } \@widgets, $val; - map { &{$updates_inv[$_]} } 0..$#widgets; + &$_ foreach @updates_inv; + + #- !! callbacks must be kept in a list otherwise perl will free them !! + #- (better handling of addCallback needed) + my @callbacks = map_index { + my $ind = $::i; + sub { + return if $ignore; #-handle recursive deadlock + return $old_focus++ if $old_focus == -2; #- handle special first case + + &$_ foreach @updates; + + #- TODO: this is very rough :( + if ($old_focus == $ind) { + $hcallback{changed}->($ind) if $hcallback{changed}; + } else { + $hcallback{focus_out}->($ind) if $hcallback{focus_out}; + } + &$_ foreach @updates_inv; + $old_focus = $ind; + }; + } @widgets; + map_index { $_->addCallback($callbacks[$::i]) } @widgets; my $grid = Newt::Grid::CreateGrid(3, int @$l); map_index { @@ -174,12 +202,21 @@ sub ask_from_entries_refW { my ($buttons, $ok, $cancel) = Newt::Grid::ButtonBar(@okcancel); - my $form = Newt::Component::Form(\undef, '', 0); + my $form = Newt::Component::Form(\undef, '', 0) or die; my $window = Newt::Grid::GridBasicWindow(first(myTextbox(@$messages)), $grid, $buttons); $window->GridWrappedWindow($title_); $window->GridAddComponentsToForm($form, 1); + + run: my $r = $form->RunForm; - map { &{$updates[$_]} } 0..$#widgets; + &$_ foreach @updates; + + if ($$r != $$cancel && $hcallback{complete}) { + my ($error, $focus) = $hcallback{complete}->(); + #-update all the value + &$_ foreach @updates_inv; + goto run if $error; + } $form->FormDestroy; Newt::PopWindow; $$r != $$cancel; diff --git a/perl-install/standalone/adduserdrake b/perl-install/standalone/adduserdrake index 843d6821b..be03ed9f3 100755 --- a/perl-install/standalone/adduserdrake +++ b/perl-install/standalone/adduserdrake @@ -53,11 +53,11 @@ if ($in->ask_from_entries_refH( } }, complete => sub { - $u->{password} eq $u->{password2} or $o->ask_warn('', [ _("The passwords do not match"), _("Please try again") ]), return (1,3); - $security > 3 && length($u->{password}) < 6 and $o->ask_warn('', _("This password is too simple")), return (1,2); - $u->{name} or $o->ask_warn('', _("Please give a user name")), return (1,0); - $u->{name} =~ /^[a-z0-9_-]+$/ or $o->ask_warn('', _("The user name must contain only lower cased letters, numbers, `-' and `_'")), return (1,0); - member($u->{name}, map { $_->{name} } @users) and $o->ask_warn('', _("This user name is already added")), return (1,0); + $u->{password} eq $u->{password2} or $in->ask_warn('', [ _("The passwords do not match"), _("Please try again") ]), return (1,3); + $security > 3 && length($u->{password}) < 6 and $in->ask_warn('', _("This password is too simple")), return (1,2); + $u->{name} or $in->ask_warn('', _("Please give a user name")), return (1,0); + $u->{name} =~ /^[a-z0-9_-]+$/ or $in->ask_warn('', _("The user name must contain only lower cased letters, numbers, `-' and `_'")), return (1,0); + member($u->{name}, map { $_->{name} } @users) and $in->ask_warn('', _("This user name is already added")), return (1,0); $u->{icon} = untranslate($u->{icon}, @any::users); return 0; }, |