summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorpad <pad@mandriva.com>1999-09-04 22:41:06 +0000
committerpad <pad@mandriva.com>1999-09-04 22:41:06 +0000
commitfa70060091fcae8b97d8a958f7a8e4dcb594b8ce (patch)
tree9e21393f038268dc0759f721aa63418fcbaeee70 /perl-install
parent7670157b32ceb6f0437c0b7b154ee1f4bf454e62 (diff)
downloaddrakx-fa70060091fcae8b97d8a958f7a8e4dcb594b8ce.tar
drakx-fa70060091fcae8b97d8a958f7a8e4dcb594b8ce.tar.gz
drakx-fa70060091fcae8b97d8a958f7a8e4dcb594b8ce.tar.bz2
drakx-fa70060091fcae8b97d8a958f7a8e4dcb594b8ce.tar.xz
drakx-fa70060091fcae8b97d8a958f7a8e4dcb594b8ce.zip
t le ask_from_entries avec les callbacks
refait code sur la gestion des erreurs refait code install2, la gestion des defaults, les dependances des profiles et modules, les combo dans interactive
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/install_steps_interactive.pm21
-rw-r--r--perl-install/interactive.pm4
-rw-r--r--perl-install/interactive_gtk.pm49
3 files changed, 53 insertions, 21 deletions
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index af70a6fa1..5254dd10f 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -89,7 +89,6 @@ sub rebootNeeded($) {
install_steps::rebootNeeded($o);
}
#------------------------------------------------------------------------------
-
sub choosePartitionsToFormat($$) {
my ($o, $fstab) = @_;
@@ -164,6 +163,7 @@ sub timeConfig {
install_steps::timeConfig($o,$f);
}
+#------------------------------------------------------------------------------
sub printerConfig($) {
my ($o) = @_;
$o->{printer}{want} =
@@ -171,7 +171,7 @@ sub printerConfig($) {
_("Would you like to configure a printer?"),
$o->{printer}{want});
return if !$o->{printer}{want};
-
+
$o->{printer}{complete} = 0;
if ($::expert) {
#std info
@@ -189,7 +189,7 @@ sub printerConfig($) {
},
);
}
-
+
$o->{printer}{str_type} =
$o->ask_from_list_(_("Select Printer Connection"),
_("How is the printer connected?"),
@@ -197,7 +197,7 @@ sub printerConfig($) {
${$o->{printer}}{str_type},
);
$o->{printer}{TYPE} = $printer::printer_type{$o->{printer}{str_type}};
-
+
if ($o->{printer}{TYPE} eq "LOCAL") {
eval { modules::load("lp"); };
my @port = ();
@@ -206,17 +206,14 @@ sub printerConfig($) {
push @port, "/dev/$_" if open LP, ">/dev/$_"
}
eval { modules::unload("lp") };
-
- my $string = _("What device is your printer connected to
-(note that /dev/lp0 is equivalent to LPT1:)?\n");
- $string .= _("I detect :");
- $string .= join(", ", @port);
+ @port =("lp0", "lp1", "lp2");
$o->{printer}{DEVICE} = $port[0] if $port[0];
-
+
+
return if !$o->ask_from_entries_ref(_("Local Printer Device"),
- $string,
+ _("What device is your printer connected to \n(note that /dev/lp0 is equivalent to LPT1:)?\n"),
[_("Printer Device:")],
- [\$o->{printer}{DEVICE}],
+ [{val => \$o->{printer}{DEVICE}, list => \@port, is_edit => 1}],
);
#TAKE A GOODDEFAULT TODO
diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm
index c466dabbf..de9998145 100644
--- a/perl-install/interactive.pm
+++ b/perl-install/interactive.pm
@@ -1,4 +1,5 @@
+
package interactive;
use diagnostics;
@@ -104,8 +105,9 @@ sub ask_from_entries_ref($$$$;$%) {
my ($o, $title, $message, $l, $val, %callback) = @_;
$message = ref $message ? $message : [ $message ];
+ my $val_hash = [ map { (ref $_) eq "SCALAR" ? { val => $_ } : {(%{$_}, type => "list")}} @{$val} ];
- $o->ask_from_entries_refW($title, $message, $l, $val, %callback)
+ $o->ask_from_entries_refW($title, $message, $l, $val_hash, %callback)
}
sub wait_message($$$) {
diff --git a/perl-install/interactive_gtk.pm b/perl-install/interactive_gtk.pm
index 0926d5327..719313549 100644
--- a/perl-install/interactive_gtk.pm
+++ b/perl-install/interactive_gtk.pm
@@ -79,17 +79,35 @@ sub ask_from_entries_refW {
my $ignore = 0;
my $w = my_gtk->new($title, %$o);
- my @entries = map { new Gtk::Entry } @{$l};
+ my @entries = map {
+ if ($_->{type} eq "list") {
+ if (@{$_->{list}}) {
+ my $depth_combo = new Gtk::Combo;
+ $depth_combo->set_use_arrows_always(1);
+ $depth_combo->entry->set_editable($_->{is_edit});
+ $depth_combo->set_popdown_strings(@{$_->{list}});
+ $depth_combo;
+ } else {
+ new Gtk::Entry;
+ }
+ } else {
+ new Gtk::Entry;
+ }
+ } @{$val};
my $ok = $w->create_okcancel;
+ sub comb_entry {
+ my ($entry, $ref) = @_;
+ ($ref->{type} eq "list" && @{$ref->{list}}) ? $entry->entry : $entry
+ }
my @updates = mapn {
my ($entry, $ref) = @_;
- return sub { ${$ref} = $entry->get_text };
+ return sub { ${$ref->{val}} = comb_entry($entry, $ref)->get_text };
} \@entries, $val;
my @updates_inv = mapn {
my ($entry, $ref) = @_;
- sub { $entry->set_text(${$ref})
+ sub { comb_entry($entry, $ref)->set_text(${$ref->{val}})
};
} \@entries, $val;
@@ -108,23 +126,38 @@ sub ask_from_entries_refW {
}
};
my $entry = $entries[$i];
- $entry->signal_connect(changed => $callback);
- $entry->signal_connect(activate => sub {
+ comb_entry($entry,$val->[$i])->signal_connect(changed => $callback);
+ comb_entry($entry,$val->[$i])->signal_connect(activate => sub {
($ind == ($num_champs -1)) ?
$w->{ok}->grab_focus() : $entries[$ind+1]->grab_focus();
});
- $entry->set_text(${$val->[$i]}) if ${$val->[$i]};
- $entry->set_visibility(0) if $_[0] =~ /password/i;
+ comb_entry($entry,$val->[$i])->set_text(${$val->[$i]{val}}) if ${$val->[$i]{val}};
+ comb_entry($entry,$val->[$i])->set_visibility(0) if $_[0] =~ /password/i;
# &{$updates[$i]};
}
+
my @entry_list = mapn { [($_[0], $_[1])]} $l, \@entries;
+
gtkadd($w->{window},
gtkpack(
create_box_with_title($w, @$messages),
create_packtable({}, @entry_list),
$ok
));
-
+
+ if ($hcallback{complete}) {
+ my $callback = sub {
+ my ($error, $focus) = &{$hcallback{changed}};
+ #update all the value
+ $ignore = 1;
+ foreach (@updates_inv) { &{$_};}
+ $ignore = 0;
+ if ($error) {
+ $entries[$focus]->grab_focus();
+ }
+ };
+ $w->{ok}->signal_connect(activate => $callback)
+ }
$entries[0]->grab_focus();
$w->main();
}