diff options
author | Norbert Preining <preining@logic.at> | 2008-11-17 08:29:06 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2008-11-17 08:29:06 +0000 |
commit | 639f245ee7565e2ccb5d261ea1b382c502ac277e (patch) | |
tree | 64a57a5d08a1bd51e3cbeeb0104bc5871675d733 /Master/tlpkg/installer | |
parent | 9d6afc59622c9ae2797be582216b34b80dd8b5f0 (diff) |
new installer features: est. remaining time, GUI progress bar
git-svn-id: svn://tug.org/texlive/trunk@11328 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/installer')
-rw-r--r-- | Master/tlpkg/installer/install-menu-perltk.pl | 105 |
1 files changed, 65 insertions, 40 deletions
diff --git a/Master/tlpkg/installer/install-menu-perltk.pl b/Master/tlpkg/installer/install-menu-perltk.pl index 5d6f101b58d..1cfd987f9ee 100644 --- a/Master/tlpkg/installer/install-menu-perltk.pl +++ b/Master/tlpkg/installer/install-menu-perltk.pl @@ -36,6 +36,9 @@ require Tk; require Tk::Dialog; require Tk::DialogBox; require Tk::PNG; +require Tk::ROText; +require Tk::ProgressBar; + if ($::alternative_selector) { require Tk::DirTree; } @@ -100,28 +103,25 @@ my $optfmtstate; my $optsrcstate; my $optdocstate; -push @::start_install_hook, - sub { - update_statusbar("Starting installation"); - $mainwindow->update; - }; -push @::start_postinst_hook, - sub { - update_statusbar("Starting post-installation Jobs"); - $mainwindow->update; - }; -push @::end_install_hook, - sub { - update_statusbar("Installation finished"); +push @::info_hook, + sub { + update_status(join(" ",@_)); $mainwindow->update; }; - -push @::install_packages_hook, \&update_statusbar; -push @::install_packages_hook, sub { $mainwindow->update; }; - -sub update_statusbar { - my $p = shift; - $::statusbar->configure(-text => "$p"); +push @::install_packages_hook, \&update_progressbar; +push @::install_packages_hook, + sub { $mainwindow->update; $::sww->update; }; + +sub update_status { + my ($p) = @_; + $::progressw->insert("end", "$p\n"); + $::progressw->see("end"); +} +sub update_progressbar { + my ($n,$total) = @_; + if (defined($n) && defined($total)) { + $::progress->value(int($n*100/$total)); + } } my %text = ( title => 'TeX Live 2008 Installation', @@ -369,32 +369,15 @@ sub run_menu { my $f3 = $fr->Frame; $f3->Button( -text => $text{'install'}, - -command => sub { do_installation(); - $return = $MENU_ALREADYDONE; - my $t = $text{'finished'}; - if (!win32()) { - $t .= "\n\n$text{'finishedpath'}"; - } - $t .= "\n\n$text{'welcome'}"; - $t =~ s/TEXDIR/$::vars{'TEXDIR'}/g; - $t =~ s/PLATFORM/$::vars{'this_platform'}/g; - $t =~ s/\\n/\n/g; - my $sw = $mainwindow->DialogBox(-title => $text{'finbut'}, -buttons => [ $text{'finbut'} ]); - $sw->add("Label", -text => $t)->pack; - $sw->Show; - #$fr->Dialog(-text => $t, -buttons => [ $text{'finbut'} ])->Show; - $mainwindow->destroy }, - )->pack(-side => 'left'); + -command => sub { installation_window(); } + )->pack(-side => 'left', -padx => "2m", -pady => "2m"); my $quitbutton = $f3->Button( -text => $text{'quit'}, -command => sub { $return = $MENU_ABORT; $mainwindow->destroy } - )->pack(-side => 'right'); + )->pack(-side => 'right', -padx => "2m", -pady => "2m"); $mw->bind('<Escape>', [ $quitbutton, 'Invoke' ]); $row++; $f3->grid(-row => $row, -column => 1, -columnspan => 3); - $::statusbar = $fr->Label(-text => $text{'status'}); - $row++; - $::statusbar->grid(-row => $row, -column => 1, -columnspan => 3); menu_update_texts(); $fr->gridColumnconfigure(2, -minsize => 300); $mw->pack(-expand => 1, -fill => "both"); @@ -415,6 +398,48 @@ sub run_menu { return($return); } +sub installation_window { + # create a progress bar window + $::sww = $mainwindow->Toplevel(-title => "installation process", + -width => 400); + $::sww->transient($mainwindow); + $::sww->grab(); + $::sww->Label(-text => "Installation process")->pack; + $::progressw = $::sww->Scrolled("ROText", -scrollbars => "e", -height => 16); + $::progressw->pack(-expand => 1, -fill => "both"); + my $percent_done = 0; + $::progress = $::sww->ProgressBar(-variable => \$percent_done, + -width => 20, -length => 400, -from => 0, -to => 100, -blocks => 10, + -colors => [ 0, '#0078b8' ]); + $::progress->pack(-fill => "x"); + my $f = $::sww->Frame; + my $b = $f->Button(-text => $text{'cancel'}, + -command => sub { $::sww->destroy; $mainwindow->destroy; + do_cleanup(); exit(1); } + )->pack(-pady => "2m"); + $f->pack; + do_installation(); + $return = $MENU_ALREADYDONE; + my $t = $text{'finished'}; + if (!win32()) { + $t .= "\n\n$text{'finishedpath'}"; + } + $t .= "\n\n$text{'welcome'}"; + $t =~ s/TEXDIR/$::vars{'TEXDIR'}/g; + $t =~ s/PLATFORM/$::vars{'this_platform'}/g; + $t =~ s/\\n/\n/g; + $::progressw->insert("end", "\n"); + my $linechar = $::progressw->index("end"); + $::progressw->markSet("finaltext", $linechar); + $::progressw->markGravity("finaltext", "left"); + $::progressw->insert("end", "\n$t"); + $::progressw->see("end"); + $::progressw->tagAdd("centered", $linechar, "end"); + $::progressw->tagConfigure("centered", -justify => "center"); + $b->configure(-text => $text{'finbut'}, + -command => sub { $mainwindow->destroy; }); +} + sub menu_edit_texdir { my $key = shift; our $addyear = 1; |