diff options
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/Xconfigurator.pm | 28 | ||||
-rw-r--r-- | perl-install/install2.pm | 2 | ||||
-rw-r--r-- | perl-install/install_steps.pm | 7 | ||||
-rw-r--r-- | perl-install/install_steps_newt.pm | 16 | ||||
-rw-r--r-- | perl-install/interactive_newt.pm | 228 | ||||
-rw-r--r-- | perl-install/my_gtk.pm | 1 |
6 files changed, 269 insertions, 13 deletions
diff --git a/perl-install/Xconfigurator.pm b/perl-install/Xconfigurator.pm index 5973f4b8d..8c492f542 100644 --- a/perl-install/Xconfigurator.pm +++ b/perl-install/Xconfigurator.pm @@ -386,18 +386,13 @@ sub autoDefaultResolution(;$$) { $monitorSize2resolution[$#monitorSize2resolution]; #- no corresponding resolution for this size. It means a big monitor, take biggest we have } -sub chooseResolutions($$;$) { +sub chooseResolutionsGtk($$;$) { my ($card, $chosen_depth, $chosen_w) = @_; my $W = my_gtk->new(_("Resolution")); my %txt2depth = reverse %depths; - my ($r, $best_w, $depth_combo, %w2depth, %w2h, %w2widget); - - my $set_depth = sub { $depth_combo->entry->set_text(translate($depths{$chosen_depth})) }; - - #- the set function is usefull to toggle the CheckButton with the callback being ignored - my $ignore; - my $set = sub { $ignore = 1; $_[0]->set_active(1); $ignore = 0; }; + my ($r, $depth_combo, %w2depth, %w2h, %w2widget); + my $best_w; while (my ($depth, $res) = each %{$card->{depth}}) { foreach (@$res) { $w2h{$_->[0]} = $_->[1]; @@ -407,6 +402,13 @@ sub chooseResolutions($$;$) { } } $chosen_w = $best_w; + + my $set_depth = sub { $depth_combo->entry->set_text(translate($depths{$chosen_depth})) }; + + #- the set function is usefull to toggle the CheckButton with the callback being ignored + my $ignore; + my $set = sub { $ignore = 1; $_[0]->set_active(1); $ignore = 0; }; + while (my ($w, $h) = each %w2h) { my $V = $w . "x" . $h; $w2widget{$w} = $r = new Gtk::RadioButton($r ? ($V, $r) : $V); @@ -420,7 +422,6 @@ sub chooseResolutions($$;$) { } }); } - gtkadd($W->{window}, gtkpack_($W->create_box_with_title(_("Choose resolution and color depth")), 1, gtkpack(new Gtk::HBox(0,20), @@ -448,6 +449,15 @@ sub chooseResolutions($$;$) { ($chosen_depth, $chosen_w); } +sub chooseResolutions($$;$) { + my ($card, $chosen_depth, $chosen_w) = @_; + + my $best_w; + local $_ = $in->ask_from_list('', _(""), + [ map_each { map { "$_->[0]x$_->[1] ${main::a}bpp" } @$::b } %{$card->{depth}} ]) or return; + reverse /(\d+)x\S+ (\d+)/; +} + sub resolutionsConfiguration($%) { my ($o, %options) = @_; diff --git a/perl-install/install2.pm b/perl-install/install2.pm index ddd77d49c..0a6f0bb91 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -341,7 +341,7 @@ sub doInstallStep { $o->afterInstallPackages; } #------------------------------------------------------------------------------ -sub miscellaneous { +sub miscellaneous { $o->{miscellaneous}{memsize} ||= $1 if first(cat_("/proc/cmdline")) =~ /mem=(\S+)/; $o->miscellaneous($_[0]); addToBeDone { diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index dd30e6dd9..60718fc88 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -323,11 +323,12 @@ sub addUser($) { foreach (@l) { if (! -d "$p$_->{home}") { - eval { commands::cp("-f", "$p/etc/skel", "$p$_->{home}") }; + my $mode = $o->{security} < 3 ? 0755 : 0750; + eval { commands::cp("-f", "$p/etc/skel", "$p$_->{home}") }; if ($@) { - log::l("copying of skel failed: $@"); mkdir("$p$_->{home}", 0750); + log::l("copying of skel failed: $@"); mkdir("$p$_->{home}", $mode); } else { - chmod 0750, "$p$_->{home}"; + chmod $mode, "$p$_->{home}"; } } commands::chown_("-r", "$_->{uid}.$_->{gid}", "$p$_->{home}") diff --git a/perl-install/install_steps_newt.pm b/perl-install/install_steps_newt.pm new file mode 100644 index 000000000..1383ad372 --- /dev/null +++ b/perl-install/install_steps_newt.pm @@ -0,0 +1,16 @@ +package install_steps_newt; + +use diagnostics; +use strict; +use vars qw(@ISA); + +@ISA = qw(install_steps_interactive interactive_newt); + +#-###################################################################################### +#- misc imports +#-###################################################################################### +use install_steps_interactive; +use interactive_newt; + +1; + diff --git a/perl-install/interactive_newt.pm b/perl-install/interactive_newt.pm new file mode 100644 index 000000000..b6d5823a3 --- /dev/null +++ b/perl-install/interactive_newt.pm @@ -0,0 +1,228 @@ +package interactive_newt; + +use diagnostics; +use strict; +use vars qw(@ISA); + +@ISA = qw(interactive); + +use interactive; +use common qw(:common :functional); +use Term::Newt; + +my $n = Term::Newt->new; +$n->init; +$n->cls; + +#sub ask_from_entryW { +# my ($o, $title, $messages, $def) = @_; +# my $w = my_gtk->new($title, %$o); +# $w->_ask_from_entry(@$messages); +# $w->main; +#} +sub ask_from_listW { + my ($o, $title_, $messages, $l, $def) = @_; + my ($title, @okcancel) = ref $title_ ? @$title_ : ($title_, _("Ok"), _("Cancel")); + my $mesg = join("\n", @$messages); + + if (@$l == 1) { + $n->win_message($title, @$l, $mesg); + $l->[0]; + } elsif (@$l == 2) { + $l->[$n->win_choice($title, @$l, $mesg) - 1]; + } elsif (@$l == 3) { + $l->[$n->win_ternary($title, @$l, $mesg) - 1]; + } else { + my $i; map_index { $i = $::i if $def eq $_ } @$l; + print STDERR "($i)\n"; + my ($r, $e) = $n->newtWinMenu($title, $mesg, 40, 5, 5, 8, $l, $i, @okcancel); + return if $r > 1; + $l->[$e]; + } +} + +#sub ask_many_from_list_refW($$$$$) { +# my ($o, $title, $messages, $list, $val) = @_; +# my $n = 0; +# my $w = my_gtk->new('', %$o); +# my $box = gtkpack(new Gtk::VBox(0,0), +# map { +# my $nn = $n++; +# my $o = Gtk::CheckButton->new($_); +# $o->set_active(${$val->[$nn]}); +# $o->signal_connect(clicked => sub { invbool \${$val->[$nn]} }); +# $o; +# } @$list); +# gtkadd($w->{window}, +# gtkpack_(create_box_with_title($w, @$messages), +# 1, @$list > 11 ? gtkset_usize(createScrolledWindow($box), 0, 250) : $box, +# 0, $w->create_okcancel, +# ) +# ); +# $w->{ok}->grab_focus; +# $w->main && $val; +#} +# +# +#sub ask_from_entries_refW { +# my ($o, $title, $messages, $l, $val, %hcallback) = @_; +# my ($title_, @okcancel) = ref $title ? @$title : $title; +# my $num_fields = @{$l}; +# my $ignore = 0; #-to handle recursivity +# +# my $w = my_gtk->new($title_, %$o); +# #-the widgets +# my @widgets = map { +# if ($_->{type} eq "list") { +# my $w = new Gtk::Combo; +# $w->set_use_arrows_always(1); +# $w->entry->set_editable(!$_->{not_edit}); +# $w->set_popdown_strings(@{$_->{list}}); +# $w->disable_activate; +# $_->{val} ||= $_->{list}[0]; +# $w; +# } elsif ($_->{type} eq "bool") { +# my $w = Gtk::CheckButton->new($_->{text}); +# $w->set_active(${$_->{val}}); +# my $i = $_; $w->signal_connect(clicked => sub { $ignore or invbool \${$i->{val}} }); +# $w; +# } else { +# new Gtk::Entry; +# } +# } @{$val}; +# my $ok = $w->create_okcancel(@okcancel); +# +# sub widget { +# my ($w, $ref) = @_; +# ($ref->{type} eq "list" && @{$ref->{list}}) ? $w->entry : $w +# } +# my @updates = mapn { +# my ($w, $ref) = @_; +# sub { +# $ref->{type} eq "bool" and return; +# ${$ref->{val}} = widget($w, $ref)->get_text; +# }; +# } \@widgets, $val; +# +# my @updates_inv = mapn { +# my ($w, $ref) = @_; +# sub { +# $ref->{type} eq "bool" ? +# $w->set_active(${$ref->{val}}) : +# widget($w, $ref)->set_text(${$ref->{val}}) +# }; +# } \@widgets, $val; +# +# +# for (my $i = 0; $i < $num_fields; $i++) { +# my $ind = $i; #-cos lexical bindings pb !! +# my $widget = widget($widgets[$i], $val->[$i]); +# my $changed_callback = sub { +# return if $ignore; #-handle recursive deadlock +# &{$updates[$ind]}; +# if ($hcallback{changed}) { +# &{$hcallback{changed}}($ind); +# #update all the value +# $ignore = 1; +# &$_ foreach @updates_inv; +# $ignore = 0; +# }; +# }; +# if ($hcallback{focus_out}) { +# my $focusout_callback = sub { +# return if $ignore; +# &{$hcallback{focus_out}}($ind); +# #update all the value +# $ignore = 1; +# &$_ foreach @updates_inv; +# $ignore = 0; +# }; +# $widget->signal_connect(focus_out_event => $focusout_callback); +# } +# if (ref $widget eq "Gtk::Entry") { +# $widget->signal_connect(changed => $changed_callback); +# my $go_to_next = sub { +# if ($ind == ($num_fields -1)) { +# $w->{ok}->grab_focus(); +# } else { +# widget($widgets[$ind+1],$val->[$ind+1])->grab_focus(); +# } +# }; +# $widget->signal_connect(activate => $go_to_next); +# $widget->signal_connect(key_press_event => sub { +# my ($w, $e) = @_; +# #-don't know why it works, i believe that +# #-i must say before &$go_to_next, but with it doen't work HACK! +# $w->signal_emit_stop("key_press_event") if chr($e->{keyval}) eq "\x8d"; +# }); +# $widget->set_text(${$val->[$i]{val}}) if ${$val->[$i]{val}}; +# $widget->set_visibility(0) if $val->[$i]{hidden}; +# } +# &{$updates[$i]}; +# } +# +# my @entry_list = mapn { [($_[0], $_[1])]} $l, \@widgets; +# +# gtkadd($w->{window}, +# gtkpack( +# create_box_with_title($w, @$messages), +# create_packtable({}, @entry_list), +# $ok +# )); +# widget($widgets[0],$val->[0])->grab_focus(); +# if ($hcallback{complete}) { +# my $callback = sub { +# my ($error, $focus) = &{$hcallback{complete}}; +# #-update all the value +# $ignore = 1; +# foreach (@updates_inv) { &{$_};} +# $ignore = 0; +# if ($error) { +# $focus ||= 0; +# widget($widgets[$focus], $val->[$focus])->grab_focus(); +# } else { +# return 1; +# } +# }; +# #$w->{ok}->signal_connect(clicked => $callback) +# $w->main($callback); +# } else { +# $w->main(); +# } +#} +# +# +#sub wait_messageW($$$) { +# my ($o, $title, $message) = @_; +# +# my $w = my_gtk->new($title, %$o, grab => 1); +# my $W = pop @$message; +# gtkadd($w->{window}, +# gtkpack(new Gtk::VBox(0,0), +# @$message, +# $w->{wait_messageW} = new Gtk::Label($W))); +# $w->sync; +# $w; +#} +#sub wait_message_nextW { +# my ($o, $message, $w) = @_; +# $w->{wait_messageW}->set($message); +# $w->sync; +#} +#sub wait_message_endW { +# my ($o, $w) = @_; +# $w->destroy; +#} +# +#sub kill { +# my ($o) = @_; +# $o->{before_killing} ||= 0; +# while (@interactive::objects > $o->{before_killing}) { +# my $w = pop @interactive::objects; +# $w->destroy; +# } +# @my_gtk::grabbed = (); +# $o->{before_killing} = @interactive::objects; +#} + +1; diff --git a/perl-install/my_gtk.pm b/perl-install/my_gtk.pm index 12f0e6eb7..5dcd9b4da 100644 --- a/perl-install/my_gtk.pm +++ b/perl-install/my_gtk.pm @@ -462,6 +462,7 @@ sub _ask_from_list { $list->moveto($_[0], 0, 0.5, 0); }; + $list->signal_connect(button_release_event => $leave) if ref $title && !@okcancel; $list->signal_connect(select_row => sub { my ($w, $row, undef, $e) = @_; $curr = $row; |