diff options
author | damien <damien@mandriva.com> | 2000-11-28 16:56:52 +0000 |
---|---|---|
committer | damien <damien@mandriva.com> | 2000-11-28 16:56:52 +0000 |
commit | 0880c7ba8ce88e87fa600aeb367a8f88a3ae71e7 (patch) | |
tree | 33f7ac905998f9ad6d85090f777ee4c0d0c67032 /perl-install/install_steps_gtk.pm | |
parent | d5c526273db473a7d87a26000585900fc10dda7d (diff) | |
download | drakx-topic/unlabeled-1.1.1.tar drakx-topic/unlabeled-1.1.1.tar.gz drakx-topic/unlabeled-1.1.1.tar.bz2 drakx-topic/unlabeled-1.1.1.tar.xz drakx-topic/unlabeled-1.1.1.zip |
branch to build the firewall install.topic/unlabeled-1.1.1
Diffstat (limited to 'perl-install/install_steps_gtk.pm')
-rw-r--r-- | perl-install/install_steps_gtk.pm | 1077 |
1 files changed, 431 insertions, 646 deletions
diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm index 150ff183f..a3ca086a4 100644 --- a/perl-install/install_steps_gtk.pm +++ b/perl-install/install_steps_gtk.pm @@ -1,4 +1,4 @@ -package install_steps_gtk; +package install_steps_gtk; # $Id$ use diagnostics; use strict; @@ -9,162 +9,18 @@ use vars qw(@ISA); #-###################################################################################### #- misc imports #-###################################################################################### +use install_steps_interactive; +use interactive_gtk; use common qw(:common :file :functional :system); -use partition_table qw(:types); use my_gtk qw(:helpers :wrappers); use Gtk; -use Gtk::XmHTML; use devices; -use fsedit; -use keyboard; -use network; use modules; -use printer; -use install_steps; -use run_program; -use install_steps_interactive; -use Xconfigurator; -use Xconfig; -use interactive_gtk; +use install_gtk; use install_any; -use diskdrake; -use pkgs; -use log; +use mouse; use help; -use lang; - -#-##################################################################################### -#-INTERN CONSTANT -#-##################################################################################### -my $w_help; -my $itemsNB = 1; -my (@background1, @background2); -my ($width, $height) = (640, 480); -my ($stepswidth, $stepsheight) = (140, $height); -my ($logowidth, $logoheight) = ($width - $stepswidth, 40); -my ($helpwidth, $helpheight) = ($width - $stepswidth, 100); -my ($windowwidth, $windowheight) = ($width - $stepswidth, $height - $helpheight - $logoheight); - -my @themes_vga16 = qw(blue blackwhite savane); -my @themes = qw(DarkMarble marble3d blueHeart); - -my @circle_head = ( - "19 17 4 1" -); - -my @circle_body = ( -" c None", -"+ c #FFFFFF", -" ===== ", -" ========= ", -" =+++======= ", -" =++========== ", -" ==+============ ", -" +++============ ", -" ================o", -" ================o", -" ================o", -" ===============oo", -" ===============oo", -" =============oo ", -" ============ooo ", -" o=========ooo ", -" oo=====oooo ", -" ooooooooo ", -" ooooo ", -); - -#-my @questionmark_head = ( -#-"39 97 6 1", -#-" c None", -#-". c #000000", -#-"+ c #FFFFFF", -#-"o c #AAAAAA", -#-); -#-my @questionmark_body = ( -#-("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO") x 10, -#-"OOOOOOOOOOOOO.......OOOOOOOOOOOOOOOOOOO", -#-"OOOOOOOOOOOO..OOOOOOO.OOOOOOOOOOOOOOOOO", -#-"OOOOOOOOOO..OOOOOOOOOOOOOOOOOOOOOOOOOOO", -#-"OOOOOOOOOO..OOOOOOOOOOOOOOOOOOOOOOOOOOO", -#-"OOOOOOOO..OOOOOOOOOOOOOOOOOOOOOOOOOOOOO", -#-"OOOOOOOO..OOOOOOOOOOOOOOOOOOOOOOOOOOOOO", -#-"OOOOOOO..OOOOOOOOOOOOOOOOOOXOOOOOOOOOOO", -#-"OOOOOOO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", -#-"OOOOOO.OOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOO", -#-"OOOOO..OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", -#-"OOOOO.OOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOO", -#-"OOOO..OOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOO", -#-"OOOO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", -#-"OOOO.OOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOO", -#-"OOO..OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", -#-"OOO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOO", -#-"OO..OOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOO", -#-"OOO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOO", -#-"OO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOO", -#-"OO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOO", -#-"O..OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOO", -#-"OO.OOOOOOOOOOOoo+++++ooOOOOOOOOOOXOOOOO", -#-"O.OOOOOOOOOOo+++o+++++++oOOOOOOOOOXOOOO", -#-"O.OOOOOOOOO+++OOOOo+++++++OOOOOOOOXOOOO", -#-"O.OOOOOOOOo++oOOOOOo++++++oOOOOOOOXOOOO", -#-"O.OOOOOOOo+++oOOOOOO+++++++OOOOOOOXOOOO", -#-"..OOOOOOOo++++OOOOOOo++++++oOOOOOOXOOOO", -#-"O.OOOOOOO+++++oOOOOOo+++++++OOOOOOXOOOO", -#-".OOOOOOOO++++++OOOOOo+++++++OOOOOOOXOOO", -#-".OOOOOOOO++++++OOOOOo+++++++OOOOOOXOOOO", -#-".OOOOOOOOo++++oOOOOOo++++++oOOOOOOOXOOO", -#-".OOOOOOOOOo++oOOOOOOo++++++oOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOOOO+++++++OOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOOOO++++++OOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOOOo+++++oOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOOO+++++OOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOOo+++oOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOO+++oOOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOo++OOOOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOO++OOOOOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOO+oOOOOOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOO+OOOOOOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOO+OOOOOOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOoOOOOOOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOO", -#-"O.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOO", -#-"OOOOOOOOOOOOOOOOoooOOOOOOOOOOOOOOOOXOOO", -#-".OOOOOOOOOOOOOO+++++OOOOOOOOOOOOOOXOOOO", -#-"O.OOOOOOOOOOOO++++++oOOOOOOOOOOOOOXXOOO", -#-"O.OOOOOOOOOOOo+++++++OOOOOOOOOOOOOXOOOO", -#-"O.OOOOOOOOOOOo+++++++OOOOOOOOOOOOOXOOOO", -#-"O.OOOOOOOOOOOo+++++++OOOOOOOOOOOOOXOOOO", -#-"OOOOOOOOOOOOOO++++++oOOOOOOOOOOOOOXOOOO", -#-"O.OOOOOOOOOOOOO+++++OOOOOOOOOOOOOXXOOOO", -#-"OO.OOOOOOOOOOOOOoooOOOOOOOOOOOOOOOXOOOO", -#-"OO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOO", -#-"OO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOXXOOOOO", -#-"OOO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOO", -#-"OOO.OOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOO", -#-"OOOO.OOOOOOOOOOOOOOOOOOOOOOOOOOXXOOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOO", -#-"OOOOO.OOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXXOOOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOO", -#-"OOOOOO.OOOOOOOOOOOOOOOOOOOOOOXXOOOOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOOOOXXOOOOOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOOOXXOOOOOOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOXXXOOOOOOOOOOO", -#-"OOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOO", -#-"OOOOOOOOOOOOXOOOOOOOOOOXXXOOOOOOOOOOOOO", -#-"OOOOOOOOOOOOOOXOOOOOOXXXOOOOOOOOOOOOOOO", -#-"OOOOOOOOOOOOOOOXXXXXXXOOOOOOOOOOOOOOOOO", -#-("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO") x 10); - -my @red_circle = (@circle_head, "= c #FF0000", "o c #AA5500", @circle_body); -my @orange_circle = (@circle_head, "= c #FFAA00", "o c #AA5500", @circle_body); -my @green_circle = (@circle_head, "= c #00FF00", "o c #00AA00", @circle_body); +use log; #-###################################################################################### #- In/Out Steps Functions @@ -175,51 +31,79 @@ sub new($$) { my $old = $SIG{__DIE__}; $SIG{__DIE__} = sub { $_[0] !~ /my_gtk\.pm/ and goto $old }; - $ENV{DISPLAY} = $o->{display} || ":0"; + $ENV{DISPLAY} ||= $o->{display} || ":0"; unless ($::testing) { $my_gtk::force_focus = $ENV{DISPLAY} eq ":0"; - my $f = "/tmp/Xconf"; - createXconf($f, @{$o->{mouse}}{"XMOUSETYPE", "device"}); + if ($ENV{DISPLAY} eq ":0" && !$::live) { + my $f = "/tmp/Xconf"; + install_gtk::createXconf($f, @{$o->{mouse}}{"XMOUSETYPE", "device"}, $o->{wacom}); + devices::make("/dev/kbd"); + + local (*T1, *T2); + open T1, ">/dev/tty5"; + open T2, ">/dev/tty6"; - if ($ENV{DISPLAY} eq ":0") { my $launchX = sub { my $ok = 1; - local $SIG{CHLD} = sub { $ok = 0 }; + local $SIG{CHLD} = sub { $ok = 0 if waitpid(-1, c::WNOHANG()) > 0 }; unless (fork) { - exec $_[0], "-kb", "-dpms","-s" ,"240", "-allowMouseOpenFail", "-xf86config", $f or exit 1; + exec $_[0], (arch() =~ /^sparc/ || arch() eq "ppc" ? () : ("-kb")), "-dpms","-s" ,"240", + ($_[0] =~ /Xsun/ || $_[0] =~ /Xpmac/ ? ("-fp", "/usr/X11R6/lib/X11/fonts:unscaled") : + ("-allowMouseOpenFail", "-xf86config", $f)) or exit 1; } - foreach (1..10) { + foreach (1..60) { sleep 1; - return 0 if !$ok; + log::l("Server died"), return 0 if !$ok; return 1 if c::Xtest($ENV{DISPLAY}); } + log::l("Timeout!!"); 0; }; - - if (listlength(cat_("/proc/fb"))) { - &$launchX("XF86_FBDev"); - $o->{allowFB} = 1; #- keep in mind FB is used. - } else { + my @servers = qw(FBDev VGA16); #-) + if (arch() eq "alpha") { + require Xconfigurator; + my $card = Xconfigurator::cardConfigurationAuto(); + Xconfigurator::updateCardAccordingName($card, $card->{type}) if $card && $card->{type}; + @servers = $card->{server} || "TGA"; + #-@servers = qw(SVGA 3DLabs TGA) + } elsif (arch() =~ /^sparc/) { + local $_ = cat_("/proc/fb"); + if (/Mach64/) { @servers = qw(Mach64) } + elsif (/Permedia2/) { @servers = qw(3DLabs) } + else { @servers = qw(Xsun24) } + } elsif (arch() eq "ppc") { + @servers = qw(Xpmac); + } + + foreach (@servers) { + log::l("Trying with server $_"); my $dir = "/usr/X11R6/bin"; - unless (-x "$dir/XF86_VGA16") { - unlink "$dir/XF86_FBDev"; - local *F; open F, ">$dir/XF86_VGA16" or die ''; - local $/ = \ (16 * 1024); - my $f = install_any::getFile("$dir/XF86_VGA16") or die ''; - syswrite F, $_ foreach <$f>; - chmod 0755, "$dir/XF86_VGA16"; + my $prog = /Xsun|Xpmac/ ? $_ : "XF86_$_"; + unless (-x "$dir/$prog") { + unlink $_ foreach glob_("$dir/X*"); + install_any::getAndSaveFile("Mandrake/mdkinst$dir/$prog", "$dir/$prog") or die "failed to get server $prog: $!"; + chmod 0755, "$dir/$prog"; + } + if (/FB/) { + !$o->{vga16} && $o->{allowFB} or next; + + $o->{allowFB} = &$launchX($prog) #- keep in mind FB is used. + and goto OK; + } else { + $o->{vga16} = 1 if /VGA16/; + &$launchX($prog) and goto OK; } - &$launchX("XF86_VGA16"); } + return undef; } } - @themes = @themes_vga16 if $o->{simple_themes} || !$o->{display} && !($o->{allowFB} ||= $::testing); + OK: + install_gtk::init_sizes(); + install_gtk::default_theme($o); + install_gtk::create_logo_window($o); - install_theme($o); - create_logo_window($o); - - $my_gtk::force_center = [ $width - $windowwidth, $logoheight, $windowwidth, $windowheight ]; + $my_gtk::force_center = [ $::rootwidth - $::windowwidth, $::logoheight, $::windowwidth, $::windowheight ]; (bless {}, ref $type || $type)->SUPER::new($o); } @@ -227,9 +111,10 @@ sub new($$) { sub enteringStep { my ($o, $step) = @_; + printf "Entering step `%s'\n", $o->{steps}{$step}{text}; $o->SUPER::enteringStep($step); - create_steps_window($o); - create_help_window($o); + install_gtk::create_steps_window($o); + install_gtk::create_help_window($o); } sub leavingStep { my ($o, $step) = @_; @@ -242,244 +127,333 @@ sub leavingStep { #- Steps Functions #-###################################################################################### sub selectLanguage { - my ($o) = @_; + my ($o, $first_time) = @_; $o->SUPER::selectLanguage; Gtk->set_locale; - install_theme($o); + install_gtk::install_theme($o); + + $o->ask_warn('', +_("Your system is low on resource. You may have some problem installing +Linux-Mandrake. If that occurs, you can try a text install instead. For this, +press `F1' when booting on CDROM, then enter `text'.")) if $first_time && availableRamMB() < 60; # 60MB + } #------------------------------------------------------------------------------ -sub doPartitionDisks($$) { - my ($o, $hds, $raid) = @_; +sub selectInstallClass1 { + my ($o, $verif, $l, $def, $l2, $def2) = @_; + $::live || @$l == 1 and return $o->SUPER::selectInstallClass1($verif, $l, $def, $l2, $def2); - while (1) { - diskdrake::main($hds, $raid, interactive_gtk->new, $o->{partitions}); - if (!grep { isSwap($_) } fsedit::get_fstab(@{$o->{hds}})) { - if ($::beginner) { - $o->ask_warn('', _("You must have a swap partition")); - } elsif (!$::expert) { - $o->ask_okcancel('', _("You don't have a swap partition\n\nContinue anyway?")) and last; - } else { last } - } else { last } - } + my $w = my_gtk->new(''); + my ($radio, $focused); + gtkadd($w->{window}, + gtkpack($o->create_box_with_title(_("Please, choose one of the following classes of installation:")), + (my @radios = map { $radio = new Gtk::RadioButton($_, $radio ? $radio : ()); + $radio->set_active($_ eq $def); $radio } @$l), + gtkadd(create_hbox(), + map { my $v = $_; + my $b = new Gtk::Button(translate($_)); + $focused = $b if $_ eq $def2; + gtksignal_connect($b, "clicked" => sub { $w->{retval} = $v; Gtk->main_quit }); + } @$l2) + )); + $focused->grab_focus if $focused; + $w->main; + + mapn { $verif->($_[1]) if $_[0]->active } \@radios, $l; + install_gtk::create_steps_window($o); + + $w->{retval}; } #------------------------------------------------------------------------------ -sub choosePackages { - my ($o, $packages, $compss, $compssUsers, $first_time) = @_; +sub selectMouse { + my ($o, $force) = @_; + my %old = %{$o->{mouse}}; + $o->SUPER::selectMouse($force); + my $mouse = $o->{mouse}; + $mouse->{type} eq 'none' || + $old{type} eq $mouse->{type} && + $old{name} eq $mouse->{name} && + $old{device} eq $mouse->{device} && !$force and return; + + local $my_gtk::grab = 1; #- unsure a crazy mouse don't go wild clicking everywhere - return if $::beginner; - chooseSizeToInstall(@_); - install_steps_interactive::choosePackages(@_); - choosePackagesTree(@_) if $::expert; + while (1) { + log::l("telling X server to use another mouse"); + eval { modules::load('serial') } if $mouse->{device} =~ /ttyS/; + + if (!$::testing) { + symlinkf($mouse->{device}, "/dev/mouse"); + c::setMouseLive($ENV{DISPLAY}, mouse::xmouse2xId($mouse->{XMOUSETYPE}), $mouse->{nbuttons} < 3); + } + install_gtk::test_mouse($mouse) and return; + $o->SUPER::selectMouse(1); + $mouse = $o->{mouse}; + } } + +#------------------------------------------------------------------------------ sub chooseSizeToInstall { - my ($o, $packages, $compss, $compssUsers, $first_time) = @_; - my $availableSpace = int(install_any::getAvailableSpace($o) / sqr(1024)); - my $default = pkgs::correctSize((sum map { $_->{size} } grep { $_->{selected} } values %$packages) / sqr(1024) || $availableSpace * 0.7); + my ($o, $packages, $min_size, $max_size_, $availableC, $individual) = @_; + my $max_size = min($max_size_, $availableC); + my $enough = $max_size == $max_size_; + my $percentage = int 100 * $max_size / $max_size_; + + #- don't ask anything if the difference between min and max is too small + return $max_size if $min_size && $max_size / $min_size < 1.05; + + log::l("choosing size to install between $min_size and $max_size"); my $w = my_gtk->new(''); - my $adj = create_adjustment($default, 100, $availableSpace); - my $spin = gtkset_usize(new Gtk::SpinButton($adj, 0, 0), 100, 0); + my $adj = create_adjustment($percentage, $min_size * 100 / $max_size_, $percentage); + my $spin = gtkset_usize(new Gtk::SpinButton($adj, 0, 0), 20, 0); + my $val; + require pkgs; gtkadd($w->{window}, gtkpack(new Gtk::VBox(0,20), - create_packtable({ col_spacings => 10 }, - [ _("Choose the size you want to install"), $spin, _("MB"), ], + _("The total size for the groups you have selected is approximately %d MB.\n", pkgs::correctSize($max_size_ / sqr(1024))) . + ($enough ? +_("If you wish to install less than this size, +select the percentage of packages that you want to install. + +A low percentage will install only the most important packages; +a percentage of 100%% will install all selected packages.") : +_("You have space on your disk for only %d%% of these packages. + +If you wish to install less than this, +select the percentage of packages that you want to install. +A low percentage will install only the most important packages; +a percentage of %d%% will install as many packages as possible.", $percentage, $percentage)) +. ($individual ? "\n\n" . _("You will be able to choose them more specifically in the next step.") : ''), + create_packtable({}, + [ _("Percentage of packages to install") . ' ', $spin, "%", my $mb = new Gtk::Label ], [ undef, new Gtk::HScrollbar($adj) ], ), create_okcancel($w) ) ); + $spin->signal_connect(changed => my $changed = sub { + $val = $spin->get_value_as_int / 100 * $max_size_; + $mb->set(sprintf("(%dMB)", pkgs::correctSize($val / sqr(1024)))); + }); &$changed(); $spin->signal_connect(activate => sub { $w->{retval} = 1; Gtk->main_quit }); $spin->grab_focus(); - $w->main or return; - - $_->{selected} = 0 foreach values %$packages; - pkgs::setSelectedFromCompssList($o->{compssListLevels}, $o->{packages}, pkgs::invCorrectSize($spin->get_value_as_int) * sqr(1024), $o->{installClass}, $o->{lang}, $o->{isUpgrade}); + $w->main and $val + 1; #- add a single byte (hack?) to make selection of 0 bytes ok. } sub choosePackagesTree { - my ($o, $packages, $compss, $compssUsers) = @_; - my $availableSpace = int(install_any::getAvailableSpace($o) / sqr(1024)); - my $w = my_gtk->new(''); - add2hash_($o->{packages_}, { show_level => 0 }); #- keep show more or less 80 }); + my ($o, $packages, $compss) = @_; - my ($current, $ignore, $showall, $selectall, $w_size, $info_widget, $showall_button, $selectall_button, $go, %items) = 0, 0, 0, 0; + $o->set_help('choosePackagesTree'); + my ($curr, $parent, $info_widget, $w_size, $go, $idle, $flat, $auto_deps); + my (%wtree, %ptree); + + my $w = my_gtk->new(''); my $details = new Gtk::VBox(0,0); - $compss->{tree} = new Gtk::Tree(); - $compss->{tree}->set_selection_mode('multiple'); - - my $clean; $clean = sub { - my ($p) = @_; - foreach (values %{$p->{childs}}) { - &$clean($_) if $_->{childs}; - delete $_->{itemNB}; - delete $_->{tree}; - delete $_->{packages_item}; - } - }; &$clean($compss); - - my $update = sub { - my $size = 0; - $ignore = 1; - foreach (grep { $_->[0] } values %items) { - $compss->{tree}->unselect_child($_->[0]); - $compss->{tree}->select_child($_->[0]) if $_->[1]{selected}; + my $tree = Gtk::CTree->new(3, 0); + $tree->set_selection_mode('browse'); + $tree->set_column_width(0, 200); + $tree->set_column_auto_resize($_, 1) foreach 1..2; + + gtkadd($w->{window}, + gtkpack_(new Gtk::VBox(0,5), + 0, _("Choose the packages you want to install"), + 1, gtkpack(new Gtk::HBox(0,0), + createScrolledWindow($tree), + gtkadd(gtkset_usize(new Gtk::Frame(_("Info")), $::windowwidth - 490, 0), + createScrolledWindow($info_widget = new Gtk::Text), + )), + 0, my $l = new Gtk::HBox(0,15), + 0, gtkpack(new Gtk::HBox(0,10), + $go = gtksignal_connect(new Gtk::Button(_("Install")), "clicked" => sub { $w->{retval} = 1; Gtk->main_quit }), + ) + )); + gtkpack__($l, my $toolbar = new Gtk::Toolbar('horizontal', 'icons')); + gtkpack__($l, gtksignal_connect(new Gtk::CheckButton(_("Automatic dependencies")), clicked => sub { invbool \$auto_deps })); + $l->pack_end($w_size = new Gtk::Label(''), 0, 1, 20); + + $w->{window}->set_usize(map { $_ - 2 * $my_gtk::border - 4 } $::windowwidth, $::windowheight); + $go->grab_focus; + $w->{rwindow}->show_all; + + my $pix_base = [ gtkcreate_xpm($w->{window}, "$ENV{SHARE_PATH}/rpm-base.xpm") ]; + my $pix_selected = [ gtkcreate_xpm($w->{window}, "$ENV{SHARE_PATH}/rpm-selected.xpm") ]; + my $pix_unselect = [ gtkcreate_xpm($w->{window}, "$ENV{SHARE_PATH}/rpm-unselected.xpm") ]; + my $pix_semisele = [ gtkcreate_xpm($w->{window}, "$ENV{SHARE_PATH}/rpm-semiselected.xpm") ]; + my $pix_installed= [ gtkcreate_xpm($w->{window}, "$ENV{SHARE_PATH}/rpm-installed.xpm") ]; + + my $add_parent; $add_parent = sub { + $_[0] or return undef; + if (my $w = $wtree{$_[0]}) { return $w } + my $s; foreach (split '/', $_[0]) { + my $s2 = $s ? "$s/$_" : $_; + $wtree{$s2} ||= do { + my $n = $tree->insert_node($s ? $add_parent->($s) : undef, undef, [$_, '', ''], 5, (undef) x 4, 0, 0); + $n; + }; + $s = $s2; } - $ignore = 0; - - foreach (values %$packages) { - $size += $_->{size} - ($_->{installedCumulSize} || 0) if $_->{selected}; #- on upgrade, installed packages will be removed. + $tree->node_set_pixmap($wtree{$s}, 1, $pix_semisele->[0], $pix_semisele->[1]); + $wtree{$s}; + }; + my $add_node = sub { + my ($leaf, $root) = @_; + my $p = $packages->[0]{$leaf} or return; + $p->{medium}{selected} or return; + my $node = $tree->insert_node($add_parent->($root), + undef, [$leaf, '', ''], 5, (undef) x 4, 1, 0); + my $pix = pkgs::packageFlagBase($p) ? $pix_base : pkgs::packageFlagSelected($p) ? $pix_selected : pkgs::packageFlagInstalled($p) ? $pix_installed : $pix_unselect; + $tree->node_set_pixmap($node, 1, $pix->[0], $pix->[1]); + push @{$ptree{$leaf}}, $node; + }; + my $add_nodes = sub { + %ptree = %wtree = (); + + $tree->freeze; + while (1) { $tree->remove_node($tree->node_nth(0) || last) } + + my ($root, $leaf); + if ($flat = $_[0]) { + $add_node->($_, undef) foreach sort grep { my $pkg = pkgs::packageByName($packages, $_); + $pkg->{medium}{selected} } keys %{$packages->[0]}; + } else { + foreach (sort @$compss) { + ($root, $leaf) = m|(.*)/(.+)|o or ($root, $leaf) = ('', $_); + my $pkg = pkgs::packageByName($packages, $leaf); + $add_node->($leaf, $root) if $pkg->{medium}{selected}; + } } - - $w_size->set(_("Total size: ") . int (pkgs::correctSize($size / sqr(1024))) . " / $availableSpace " . _("MB") ); + $tree->thaw; }; - my $new_item = sub { - my ($p, $name, $parent) = @_; - my $w = create_treeitem($name); - $items{++$itemsNB} = [ $w, $p ]; - $parent->{packages_item}{$itemsNB} = undef if $parent; - $w->show; - $w->set_sensitive(!$p->{base} && !$p->{installed}); - $w->signal_connect(focus_in_event => sub { - my $p = pkgs::getHeader($p); - gtktext_insert($info_widget, - _("Version: %s\n", c::headerGetEntry($p, 'version') . '-' . c::headerGetEntry($p, 'release')) . - _("Size: %d KB\n", c::headerGetEntry($p, 'size') / 1024) . - - formatLines(c::headerGetEntry($p, 'description'))); - }) unless $p->{childs}; - $itemsNB; + $add_nodes->($flat); + + my %toolbar = my @toolbar = + ( + ftout => [ _("Expand Tree") , sub { $tree->expand_recursive(undef) } ], + ftin => [ _("Collapse Tree") , sub { $tree->collapse_recursive(undef) } ], + reload=> [ _("Toggle between flat and group sorted"), sub { $add_nodes->(!$flat) } ], + ); + $toolbar->set_button_relief("none"); + foreach (grep_index { $::i % 2 == 0 } @toolbar) { + gtksignal_connect($toolbar->append_item(undef, $toolbar{$_}[0], undef, gtkxpm($tree, "$ENV{SHARE_PATH}/$_.xpm")), + clicked => $toolbar{$_}[1]); + } + $toolbar->set_style("icons"); + + my $display_info = sub { + my $p = $packages->[0]{$curr} or return gtktext_insert($info_widget, ''); + pkgs::extractHeaders($o->{prefix}, [$p], $p->{medium}); + $p->{header} or die; + + my $ind = $o->{compssListLevels}{$o->{installClass}}; + my $imp = translate($pkgs::compssListDesc{pkgs::packageFlagBase($p) ? 100 : round_down($p->{values}[$ind], 10)}); + + gtktext_insert($info_widget, $@ ? _("Bad package") : + _("Name: %s\n", pkgs::packageName($p)) . + _("Version: %s\n", pkgs::packageVersion($p) . '-' . pkgs::packageRelease($p)) . + _("Size: %d KB\n", pkgs::packageSize($p) / 1024) . + ($imp && _("Importance: %s\n", $imp)) . "\n" . + formatLines(c::headerGetEntry($p->{header}, 'description'))); + c::headerFree(delete $p->{header}); + 0; }; - $compss->{tree}->signal_connect(selection_changed => sub { - $ignore and return; - - my %s; @s{$_[0]->selection} = (); - my @changed; - #- needs to find @changed first, _then_ change the selected, otherwise - #- we won't be able to find the changed - foreach (values %items) { - push @changed, $_->[1] if ($_->[1]{selected} xor exists $s{$_->[0]}); + my $update_size = sub { + my $size = pkgs::selectedSize($packages); + $w_size->set(_("Total size: %d / %d MB", + pkgs::correctSize($size / sqr(1024)), + install_any::getAvailableSpace($o) / sqr(1024))); + }; + my $select = sub { + my %l; + my $isSelection = !pkgs::packageFlagSelected($_[0]); + foreach (@_) { + pkgs::togglePackageSelection($packages, $_, my $l = {}); + @l{grep {$l->{$_}} keys %$l} = (); } - #- works before @changed is (or must be!) one element - foreach (@changed) { - if ($_->{childs}) { - my $s = invbool \$_->{selected}; - my $f; $f = sub { - my ($p) = @_; - $p->{itemNB} or return; - if ($p->{packages}) { - foreach (keys %{$p->{packages_item} || {}}) { - my ($a, $b) = @{$items{$_}}; - $a and pkgs::set($packages, $b, $s); - } - } else { - foreach (values %{$p->{childs}}) { - $_->{selected} = $s; - &$f($_); - } - } - }; &$f($_); -#- } elsif ($_->{base}) { -#- $o->ask_warn('', _("Sorry, i won't unselect this package. The system needs it")); -#- } elsif ($_->{installed}) { -#- $o->ask_warn('', _("Sorry, i won't select this package. A more recent version is already installed")); - } else { - pkgs::toggle($packages, $_); + if (my @l = keys %l) { + #- check for size before trying to select. + my $size = pkgs::selectedSize($packages); + foreach (@l) { + my $p = $packages->[0]{$_}; + pkgs::packageFlagSelected($p) or $size += pkgs::packageSize($p); + } + if (pkgs::correctSize($size / sqr(1024)) > install_any::getAvailableSpace($o) / sqr(1024)) { + return $o->ask_warn('', _("You can't select this package as there is not enough space left to install it")); } - } - &$update(); - }); - - my $select_add = sub { - my ($ind, $level) = @{$o->{packages_}}{"ind", "select_level"}; - $level = max(0, min(100, ($level + $_[0]))); - $o->{packages_}{select_level} = $level; - pkgs::unselect_all($packages); - foreach (pkgs::allpackages($packages)) { - pkgs::select($packages, $_) if $_->{values}[$ind] >= $level; + @l > @_ && !$auto_deps and $o->ask_okcancel('', [ $isSelection ? + _("The following packages are going to be installed") : + _("The following packages are going to be removed"), + join(", ", common::truncate_list(20, sort @l)) ], 1) || return; + $isSelection ? pkgs::selectPackage($packages, $_) : pkgs::unselectPackage($packages, $_) foreach @_; + foreach (@l) { + my $p = $packages->[0]{$_}; + my $pix = pkgs::packageFlagSelected($p) ? $pix_selected : $pix_unselect; + $tree->node_set_pixmap($_, 1, $pix->[0], $pix->[1]) foreach @{$ptree{$_}}; + } + &$update_size; + } else { + $o->ask_warn('', _("You can't select/unselect this package")); } - &$update; }; - - my $show_add = sub { - my ($ind, $level) = @{$o->{packages_}}{"ind", "show_level"}; - $level = max(0, min(90, ($level + $_[0]))); - $o->{packages_}{show_level} = $level; - - my $update_tree = sub { - my $P = shift; - my $i = 0; foreach (@_) { - my ($flag, $itemNB, $q) = @$_; - my $item = $items{$flag || $itemNB}[0] if $flag || $itemNB; - if ($flag) { - $P->{tree}->insert($item, $i) if $flag ne "1"; - $item->set_subtree($q->{tree}) if $flag ne "1" && $q->{tree}; - $i++; - } elsif ($itemNB) { - delete $items{$itemNB}; - delete $P->{packages_item}{$itemNB}; - $P->{tree}->remove_item($item) if $P->{tree}; - } - } - }; - my $f; $f = sub { - my ($p) = @_; - if ($p->{packages}) { - my %l; $l{$items{$_}[1]} = $_ foreach keys %{$p->{packages_item}}; - map { - [ $_->{values}[$ind] >= $level ? - ($l{$_} ? 1 : &$new_item($_, $_->{name}, $p)) : '', $l{$_}, $_ ]; - } sort { - $a->{name} cmp $b->{name} } @{$p->{packages}}; + my $children = sub { map { $packages->[0]{($tree->node_get_pixtext($_, 0))[0]} } gtkctree_children($_[0]) }; + my $toggle = sub { + if (ref $curr && ! $_[0]) { + $tree->toggle_expansion($curr); + } else { + if (ref $curr) { + my @l = grep { !pkgs::packageFlagBase($_) } $children->($curr) or return; + my @unsel = grep { !pkgs::packageFlagSelected($_) } @l; + my @p = @unsel ? + @unsel : # not all is selected, select all + @l; + $select->(@p); + $parent = $curr; } else { - map { - my $P = $p->{childs}{$_}; - my @L; @L = &$f($P) if !$P->{values} || $P->{values}[$ind] > ($::expert ? -1 : 0); - if (grep { $_->[0] } @L) { - my $r = $P->{tree} ? 1 : do { - my $t = $P->{tree} = new Gtk::Tree(); $t->show; - $P->{itemNB} = &$new_item($P, $_); - }; - &$update_tree($P, @L); - [ $r, $P->{itemNB}, $P ]; + my $p = $packages->[0]{$curr} or return; + if (pkgs::packageFlagBase($p)) { + return $o->ask_warn('', _("This is a mandatory package, it can't be unselected")); + } elsif (pkgs::packageFlagInstalled($p)) { + return $o->ask_warn('', _("You can't unselect this package. It is already installed")); + } elsif (pkgs::packageFlagUpgrade($p)) { + if ($::expert) { + if (pkgs::packageFlagSelected($p)) { + $o->ask_yesorno('', _("This package must be upgraded\nAre you sure you want to deselect it?")) or return; + } } else { - &$update_tree($P, @L); - delete $P->{tree}; - [ '', delete $P->{itemNB}, $P ]; + return $o->ask_warn('', _("You can't unselect this package. It must be upgraded")); } - } sort keys %{$p->{childs} || {}}; + } + $select->($p); } - }; - $ignore = 1; - &$update_tree($compss, &$f($compss)); - &$update; - $ignore = 0; + if (my @l = $children->($parent)) { + my $nb = grep { pkgs::packageFlagSelected($_) } @l; + my $pix = $nb==0 ? $pix_unselect : $nb<@l ? $pix_semisele : $pix_selected; + $tree->node_set_pixmap($parent, 1, $pix->[0], $pix->[1]); + } + } }; - gtkadd($w->{window}, gtkpack_(new Gtk::VBox(0,5), - 0, _("Choose the packages you want to install"), - 1, gtkpack(new Gtk::HBox(0,0), - createScrolledWindow($compss->{tree}), - gtkadd(gtkset_usize(new Gtk::Frame(_("Info")), 150, 0), - createScrolledWindow($info_widget = new Gtk::Text), - ), - ), - 0, gtkpack_(new Gtk::HBox(0,0), 0, $w_size = new Gtk::Label('')), - 0, gtkpack(new Gtk::HBox(0,10), - map { $go ||= $_; $_ } - map { gtksignal_connect(new Gtk::Button($_->[0]), "clicked" => $_->[1]) } - [ _("Install") => sub { $w->{retval} = 1; Gtk->main_quit } ], - #- keep show more or less [ _("Show less") => sub { &$show_add(+10) } ], - #- keep show more or less [ _("Show more") => sub { &$show_add(-10) } ], - ) - )); - $w->{window}->set_usize(map { $_ - 2 * $my_gtk::border - 4 } $windowwidth, $windowheight); - $w->show; - &$show_add(0); - &$update(); - $go->grab_focus; + $tree->signal_connect(key_press_event => sub { + my ($w, $e) = @_; + my $c = chr($e->{keyval} & 0xff); + $toggle->(0) if $e->{keyval} >= 0x100 ? $c eq "\r" || $c eq "\x8d" : $c eq ' '; + 1; + }); + $tree->signal_connect(tree_select_row => sub { + Gtk->timeout_remove($idle) if $idle; + + if ($_[1]->row->is_leaf) { + ($curr) = $tree->node_get_pixtext($_[1], 0); + $parent = $_[1]->row->parent; + $idle = Gtk->timeout_add(100, $display_info); + } else { + $curr = $_[1]; + } + $toggle->(1) if $_[2] == 1; + }); + &$update_size; $w->main; } @@ -487,15 +461,14 @@ sub choosePackagesTree { sub installPackages { my ($o, $packages) = @_; - my ($current_total_size, $last_size, $nb, $total_size, $start_time, $last_dtime); + my ($current_total_size, $last_size, $nb, $total_size, $start_time, $last_dtime, $trans_progress_total); - my $w = my_gtk->new(_("Installing"), grab => 1); - $w->{window}->set_usize($windowwidth * 0.8, $windowheight * 0.5); + my $w = my_gtk->new(_("Installing")); + $w->{window}->set_usize($::windowwidth * 0.8, 260); my $text = new Gtk::Label; - my ($msg, $msg_time_remaining, $msg_time_total) = map { new Gtk::Label } (1..3); + my ($msg, $msg_time_remaining, $msg_time_total) = map { new Gtk::Label($_) } '', (_("Estimating")) x 2; my ($progress, $progress_total) = map { new Gtk::ProgressBar } (1..2); - gtkadd($w->{window}, gtkadd(new Gtk::EventBox, - gtkpack(new Gtk::VBox(0,10), + gtkadd($w->{window}, gtkpack(new Gtk::VBox(0,10), _("Please wait, "), $msg, $progress, create_packtable({}, [_("Time remaining "), $msg_time_remaining], @@ -503,42 +476,91 @@ sub installPackages { ), $text, $progress_total, - ))); - $msg->set(_("Preparing installation")); + '', + gtkadd(create_hbox(), + my $cancel = new Gtk::Button(_("Cancel"))), + )); $w->sync; + $msg->set(_("Preparing installation")); + gtkset_mousecursor_normal($cancel->window); + $cancel->signal_connect(clicked => sub { $pkgs::cancel_install = 1 }); - my $old = \&log::ld; - local *log::ld = sub { + my $oldInstallCallback = \&pkgs::installCallback; + local *pkgs::installCallback = sub { my $m = shift; - if ($m =~ /^starting installation:/) { + if ($m =~ /^Starting installation/) { $nb = $_[0]; - $total_size = $_[2]; $current_total_size = 0; + $total_size = $_[1]; $current_total_size = 0; $start_time = time(); - $msg->set(join '', @_); + $msg->set(_("%d packages", $nb)); $w->flush; - } elsif ($m =~ /^starting installing/) { + } elsif ($m =~ /^Starting installing package/) { $progress->update(0); my $name = $_[0]; $msg->set(_("Installing package %s", $name)); $current_total_size += $last_size; - $last_size = c::headerGetEntry($o->{packages}{$name}{header}, 'size'); - $text->set((split /\n/, c::headerGetEntry($o->{packages}{$name}{header}, 'summary'))[0] || ''); + $last_size = c::headerGetEntry($o->{packages}[0]{$name}{header}, 'size'); + $text->set((split /\n/, c::headerGetEntry($o->{packages}[0]{$name}{header}, 'summary'))[0] || ''); $w->flush; - } elsif ($m =~ /^progressing installation/) { - $progress->update($_[2] ? $_[0] / $_[2] : 0); + } elsif ($m =~ /^Progressing installing package/) { + $progress->update($_[2] ? $_[1] / $_[2] : 0); my $dtime = time() - $start_time; - my $ratio = $total_size ? ($_[0] + $current_total_size) / $total_size : 0; + my $ratio = $total_size ? ($_[1] + $current_total_size) / $total_size : 0; my $total_time = $ratio ? $dtime / $ratio : time(); $progress_total->update($ratio); - if ($dtime != $last_dtime) { - $msg_time_total->set(formatTime($total_time)); - $msg_time_remaining->set(formatTime(max($total_time - $dtime, 0))); + if ($dtime != $last_dtime && $current_total_size > 10 * 1024 * 1024) { + $msg_time_total->set(formatTime(10 * round($total_time / 10) + 10)); + $msg_time_remaining->set(formatTime(10 * round(max($total_time - $dtime, 0) / 10) + 10)); $last_dtime = $dtime; } $w->flush; - } else { goto $old } + } else { unshift @_, $m; goto $oldInstallCallback } + }; + #- the modification is not local as the box should be living for other package installation. + undef *install_any::changeMedium; + *install_any::changeMedium = sub { + my ($method, $medium) = @_; + + #- if not using a cdrom medium, always abort. + $method eq 'cdrom' and do { + local $my_gtk::grab = 1; + my $name = pkgs::mediumDescr($o->{packages}, $medium); + print "\a"; + $name !~ /Application/ || ($o->{useless_thing_accepted2} ||= $o->ask_from_list_('', formatAlaTeX(_(" +Warning + +Please read carefully the terms below. If you disagree with any +portion, you are not allowed to install the next CD media. Press 'Refuse' +to continue the installation without using these media. + + +Some components contained in the next CD media are not governed +by the GPL License or similar agreements. Each such component is then +governed by the terms and conditions of its own specific license. +Please read carefully and comply with such specific licenses before +you use or redistribute the said components. +Such licenses will in general prevent the transfer, duplication +(except for backup purposes), redistribution, reverse engineering, +de-assembly, de-compilation or modification of the component. +Any breach of agreement will immediately terminate your rights under +the specific license. Unless the specific license terms grant you such +rights, you usually cannot install the programs on more than one +system, or adapt it to be used on a network. In doubt, please contact +directly the distributor or editor of the component. +Transfer to third parties or copying of such components including the +documentation is usually forbidden. + + +All rights to the components of the next CD media belong to their +respective authors and are protected by intellectual property and +copyright laws applicable to software programs. +")), [ __("Accept"), __("Refuse") ], "Accept") eq "Accept") and $o->ask_okcancel('', _("Change your Cd-Rom! + +Please insert the Cd-Rom labelled \"%s\" in your drive and press Ok when done. +If you don't have it, press Cancel to avoid installation from this Cd-Rom.", $name)); + }; }; catch_cdie { $o->install_steps::installPackages($packages); } sub { @@ -546,265 +568,28 @@ sub installPackages { $o->ask_yesorno('', [ _("There was an error ordering packages:"), $1, _("Go on anyway?") ], 1) and return 1; ${$_[0]} = "already displayed"; + } elsif ($@ =~ /^error installing package list: (.*)/) { + $o->ask_yesorno('', [ +_("There was an error installing packages:"), $1, _("Go on anyway?") ], 1) and return 1; + ${$_[0]} = "already displayed"; } 0; }; - $w->destroy; -} - - - - -#------------------------------------------------------------------------------ -sub load_rc($) { - if (my ($f) = grep { -r $_ } map { "$_/$_[0].rc" } (".", "/usr/share", dirname(__FILE__))) { - Gtk::Rc->parse($f); - foreach (cat_($f)) { - if (/style\s+"background"/ .. /^\s*$/) { - @background1 = map { $_ * 256 * 256 } split ',', $1 if /NORMAL.*\{(.*)\}/; - @background2 = map { $_ * 256 * 256 } split ',', $1 if /PRELIGHT.*\{(.*)\}/; - } - } + if ($pkgs::cancel_install) { + $pkgs::cancel_install = 0; + die "setstep choosePackages\n"; } + $w->destroy; } -sub install_theme { - my ($o, $theme) = @_; - $o->{theme} = $theme || $o->{theme} || $themes[0]; - - gtkset_mousecursor(68); - - load_rc($_) foreach "themes-$o->{theme}", "install", "themes"; - - if (my ($font, $font2) = lang::get_x_fontset($o->{lang})) { - $font2 ||= $font; - Gtk::Rc->parse_string(qq( -style "default-font" -{ - fontset = "$font" -} -style "steps" -{ - fontset = "$font2" -} -widget "*" style "default-font" -widget "*Steps*" style "steps" - -)); - } - gtkset_background(@background1);# unless $::testing; - - create_logo_window($o); - create_help_window($o); -} - -#------------------------------------------------------------------------------ -sub create_help_window { - my ($o) = @_; - -# $o->{help_window}->destroy if $o->{help_window}; - - my $w; - if ($w = $o->{help_window}) { - $_->destroy foreach $w->{window}->children; - } else { - $w = bless {}, 'my_gtk'; - $w->{rwindow} = $w->{window} = new Gtk::Window; - $w->{rwindow}->set_uposition($width - $helpwidth, $height - $helpheight); - $w->{rwindow}->set_usize($helpwidth, $helpheight); - $w->sync; - } - -#- my $b = new Gtk::Button; -#- $b->signal_connect(clicked => sub { -#- my $w = my_gtk->new('', grab => 1, force_position => [ $stepswidth, $logoheight ]); -#- $w->{rwindow}->set_usize($logowidth, $height - $logoheight); -#- gtkadd($w->{window}, -#- gtkpack_(new Gtk::VBox(0,0), -#- 1, createScrolledWindow(gtktext_insert(new Gtk::Text, -#- formatAlaTeX(translate($help::steps_long{$o->{step}})))), -#- 0, gtksignal_connect(new Gtk::Button(_("Ok")), "clicked" => sub { Gtk->main_quit }), -#- )); -#- $w->main; -#- }); -#- my @l = (@questionmark_head, -#- join('', "X c #", map { sprintf "%02X", $_ / 256 } @background1), -#- join('', "O c #", map { sprintf "%02X", $_ / 256 } @background2), -#- @questionmark_body); -#- my @pixmap = Gtk::Gdk::Pixmap->create_from_xpm_d($w->{window}->window, undef, @l); -#- gtkadd($b, new Gtk::Pixmap(@pixmap)); - - Gtk::XmHTML->init; - gtkadd($w->{window}, - gtkpack_(new Gtk::HBox(0,-2), -#- 0, $b, - 1, createScrolledWindow($w_help = new Gtk::XmHTML))); -#- 1, createScrolledWindow($w_help = new Gtk::Text))); - $w_help->source($o->{step} ? translate($o->{steps}{$o->{step}}{help}) : ''); -#- gtktext_insert($w_help, $o->{step} ? formatAlaTeX(translate($o->{steps}{$o->{step}}{help})) : ''); - - $w->show; - $o->{help_window} = $w; -} - -#------------------------------------------------------------------------------ -sub create_steps_window { - my ($o) = @_; - - $o->{steps_window}->destroy if $o->{steps_window}; - my %reachableSteps if 0; - %reachableSteps = (); - - my $w = bless {}, 'my_gtk'; - $w->{rwindow} = $w->{window} = new Gtk::Window; - $w->{rwindow}->set_uposition(0, 0); - $w->{rwindow}->set_usize($stepswidth, $stepsheight); - $w->{rwindow}->set_name("Steps"); - $w->{rwindow}->set_events('button_press_mask'); - $w->{rwindow}->signal_connect(button_press_event => sub { - $::setstep or return; - my $Y = $_[1]{'y'}; - map_each { - my (undef, $y, undef, $height) = @{$::b->allocation}; - $y <= $Y && $Y < $y + $height and die "setstep $::a\n"; - } %reachableSteps; - }); - $w->show; +sub set_help { + my ($o, @l) = @_; - gtkadd($w->{window}, - gtkpack_(new Gtk::VBox(0,0), - (map { 1, $_ } map { - my $step = $o->{steps}{$_}; - my $circle = - $step->{done} && \@green_circle || - $step->{entered} && \@orange_circle || - \@red_circle; - my @pixmap = Gtk::Gdk::Pixmap->create_from_xpm_d($w->{window}->window, undef, @$circle); - - my $w = new Gtk::Label(translate($step->{text})); - - $w->set_name("Steps" . ($step->{reachable} && "Reachable")); - my $b = new Gtk::HBox(0,5); - gtkpack_($b, 0, new Gtk::Pixmap(@pixmap), 0, $w); - - $reachableSteps{$_} = $b if $step->{reachable}; - $b; - } grep { !(($::beginner || !$o->{installClass}) && $o->{steps}{$_}{beginnerHidden}) } @{$o->{orderedSteps}}), - 0, gtkpack(new Gtk::HBox(0,0), map { - my $t = $_; - my $w = new Gtk::Button(''); - $w->set_name($t); - $w->set_usize(0, 7); - gtksignal_connect($w, clicked => sub { install_theme($o, $t); die "theme_changed\n" }); - } @themes))); - $w->show; - $o->{steps_window} = $w; + $o->{current_help} = formatAlaTeX(join "\n", map { _ deref($help::steps{$_}) } @l); + gtktext_insert($o->{help_window_text}, $o->{current_help}); + 1; } -#------------------------------------------------------------------------------ -sub create_logo_window() { - my ($o) = @_; - gtkdestroy($o->{logo_window}); - my $w = bless {}, 'my_gtk'; - $w->{rwindow} = $w->{window} = new Gtk::Window; - $w->{rwindow}->set_uposition($stepswidth, 0); - $w->{rwindow}->set_usize($logowidth, $logoheight); - $w->{rwindow}->set_name("background"); - $w->show; - my $file = "logo-mandrake.xpm"; - -r $file or $file = "/usr/share/$file"; - if (-r $file) { - my $ww = $w->{window}; - my @logo = Gtk::Gdk::Pixmap->create_from_xpm($ww->window, $ww->style->bg('normal'), $file); - gtkadd($ww, new Gtk::Pixmap(@logo)); - } - $o->{logo_window} = $w; -} - -#------------------------------------------------------------------------------ -sub createXconf($$$) { - my ($file, $mouse_type, $mouse_dev) = @_; - $mouse_type ||= "Microsoft"; - $mouse_dev = devices::make($mouse_dev || "ttyS0"); - - local *F; - open F, ">$file" or die "can't create X configuration file $file"; - print F <<END; -Section "Files" - FontPath "/usr/X11R6/lib/X11/fonts" -EndSection - -Section "Keyboard" - Protocol "Standard" - AutoRepeat 500 5 - - LeftAlt Meta - RightAlt Meta - ScrollLock Compose - RightCtl Control -EndSection - -Section "Pointer" - Protocol "$mouse_type" - Device "$mouse_dev" - Emulate3Buttons - Emulate3Timeout 50 -EndSection - - -Section "Monitor" - Identifier "My Monitor" - VendorName "Unknown" - ModelName "Unknown" - HorizSync 31.5-35.5 - VertRefresh 50-70 - Modeline "640x480" 25.175 640 664 760 800 480 491 493 525 - Modeline "640x480" 28.3 640 664 760 800 480 491 493 525 -EndSection - - -Section "Device" - Identifier "Generic VGA" - VendorName "Unknown" - BoardName "Unknown" - Chipset "generic" -EndSection - - -Section "Screen" - Driver "svga" - Device "Generic VGA" - Monitor "My Monitor" - Subsection "Display" - Modes "640x480" - ViewPort 0 0 - EndSubsection -EndSection - -Section "Screen" - Driver "vga16" - Device "Generic VGA" - Monitor "My Monitor" - Subsection "Display" - Modes "640x480" - ViewPort 0 0 - EndSubsection -EndSection - -Section "Screen" - Driver "fbdev" - Device "Generic VGA" - Monitor "My Monitor" - Subsection "Display" - Depth 16 - Modes "default" - ViewPort 0 0 - EndSubsection -EndSection -END - -} -#- ModeLine "640x480" 28 640 672 768 800 480 490 492 525 #-###################################################################################### #- Wonderful perl :( #-###################################################################################### |