summaryrefslogtreecommitdiff
path: root/Master/tlpkg
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2009-01-30 19:54:55 +0000
committerNorbert Preining <preining@logic.at>2009-01-30 19:54:55 +0000
commit9ed0613d8c7efda754589bc5eac54d7193651494 (patch)
treeb911fee145786d508ccea65f3f6fb72cd6c945b4 /Master/tlpkg
parentc7fce06ce57b4043ffbbedea57c4637295da9a10 (diff)
make wizard more wizard like ...
git-svn-id: svn://tug.org/texlive/trunk@12020 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg')
-rw-r--r--Master/tlpkg/installer/install-menu-wizard.pl396
1 files changed, 276 insertions, 120 deletions
diff --git a/Master/tlpkg/installer/install-menu-wizard.pl b/Master/tlpkg/installer/install-menu-wizard.pl
index 12386d2d375..b43653c5e2d 100644
--- a/Master/tlpkg/installer/install-menu-wizard.pl
+++ b/Master/tlpkg/installer/install-menu-wizard.pl
@@ -35,9 +35,38 @@ require Tk::ProgressBar;
use utf8;
no utf8;
-my $lab;
-my $val;
-my $but;
+#
+# LAYOUT of the wizard
+#
+# /-----------------------------------------\
+# |
+# | /------------ Frame $ftitle -------\ |
+# | | Lab $tit | |
+# | \----------------------------------/ |
+# | |
+# | /------------ Frame $fmain --------\ |
+# | | | |
+# | \----------------------------------/ |
+# | |
+# | /------------ Frame $fbuttons -----\ |
+# | | But $can <$spi> But $prv <$spii> But $nxt | |
+# | \----------------------------------/ |
+# | |
+# \-----------------------------------------/
+#
+my $ftitle;
+my $tit;
+
+my $fmain;
+
+my $fbuttons;
+my $can;
+my $spi;
+my $prv;
+my $spii;
+my $nxt;
+
+my $img;
if (defined($::opt_lang)) {
$::lang = $::opt_lang;
@@ -82,30 +111,6 @@ my $dest = "/usr/local/texlive/2008";
my $mw;
-sub ask_path {
- $lab->configure(-text => "Destination Folder:");
- $val->configure(-textvar => \$dest);
- $but->configure(-text => "Change", -command => \&change_path);
- my $nx = $mw->Button(-text => "Next", -command => \&installation_window);
- $nx->pack;
-}
-
-sub change_path {
- my $val = $dest;
- my $sw = $mw->Toplevel(-title => "Changing TEXDIR");
- $sw->transient($mw);
- $sw->grab();
- $sw->Label(-text => "Please enter path for TEXDIR")->pack;
- my $entry = $sw->Entry(-textvariable => $val, -width => 60);
- $entry->pack;
- my $f = $sw->Frame;
- my $okbutton = $f->Button(-text => "Ok",
- -command => sub { $val = $entry->get; $dest = $val ; $sw->destroy })->pack(-side => 'left', -padx => "2m", -pady => "2m");
- my $cancelbutton = $f->Button(-text => "Cancel",
- -command => sub { $sw->destroy })->pack(-side => 'right', -padx => "2m", -pady => "2m");
- $f->pack(-expand => 'x');
-}
-
######################################################################
@@ -224,23 +229,192 @@ if (($::lang ne "en") && ($::lang ne "C")) {
}
}
+sub unpack_buttons {
+ $can->packForget;
+ $spi->packForget;
+ $prv->packForget;
+ $spii->packForget;
+ $nxt->packForget;
+}
+
+sub pack_buttons {
+ if (member("cancel", @_)) {
+ $can->pack(-side => "left");
+ $spi->pack(-side => "left");
+ }
+ if (member("next", @_)) {
+ $nxt->pack(-side => "right");
+ $spii->pack(-side => "right");
+ }
+ if (member("prev", @_)) {
+ $prv->pack(-side => "right");
+ }
+}
+
sub run_menu {
calc_depends();
$mw = Tk::MainWindow->new;
- $lab = $mw->Label(-text => "TeX Live 2008");
- $val = $mw->Label();
- $but = $mw->Button(-text => "Next", -command => \&ask_path);
- $lab->pack(-side => "left");
- $val->pack(-side => "left");
- $but->pack(-side => "left");
+
+ $ftitle = $mw->Frame;
+ $tit = $ftitle->Label(-text => "TeX Live 2008 Installation");
+ $tit->pack(-side => "top", -expand => 1, -fill => "both");
+
+ $fmain = $mw->Frame(); ## DEBUG: -relief => "ridge", -borderwidth => 2);
+
+ $fbuttons = $mw->Frame;
+ $can = $fbuttons->Button(-width => 10, -relief => "ridge");
+ $spi = $fbuttons->Label(-width => 6);
+ $nxt = $fbuttons->Button(-width => 10, -relief => "ridge");
+ $spii= $fbuttons->Label(-width => 2);
+ $prv = $fbuttons->Button(-width => 10, -relief => "ridge");
+
+ reset_start();
+
+
+ $ftitle->pack(-side => "top", -expand => 1, -fill => "both", -padx => "8m", -pady => "8m");
+ $fmain->pack(-side => "top", -expand => 1, -fill => "both", -padx => "8m", -pady => "8m");
+ $fbuttons->pack(-side => "bottom", -expand => 1, -fill => "both", -padx => "8m", -pady => "8m");
+
+ $mw->configure(-width => 600, -height => 400);
+ $mw->packPropagate(0);
Tk::MainLoop();
return($return);
}
+sub reset_start {
+ for ($fmain->children) {
+ $_->destroy;
+ }
+
+ my $inf = $fmain->Label(-text => "Welcome to the installation of TeX Live 2008\nThis wizard will guide you through the installation.");
+ $inf->pack(-padx => "3m", -pady => "3m");
+
+ $fmain->configure(-height => $fmain->reqheight, -width => $fmain->reqwidth);
+
+ unpack_buttons();
+ $can->configure(-text => "Cancel",
+ -command => sub { $mw->destroy; do_cleanup(); exit(1); });
+ $prv->configure(-text => "Previous", -command => \&run_menu);
+ $nxt->configure(-text => "Next", -command => \&ask_scheme);
+ pack_buttons("cancel", "next");
+}
+
+sub ask_scheme {
+ for ($fmain->children) {
+ $_->destroy;
+ }
+
+ my $af = $fmain->Frame;
+ my $bf = $fmain->Frame;
+ my $lab = $af->Label(-text => "Currently selected scheme:");
+ $lab->pack(-side => "left");
+ my $val = $af->Label(-textvar => \$vars{'selected_scheme'});
+ $val->pack(-side => "left", -padx => "3m");
+ my $but = $af->Button(-text => "Change", -command => \&change_scheme, -relief => "ridge", -width => 10);
+ $but->pack(-side => "right");
+
+ my $inf = $bf->Label(-text => "A scheme defines what will be installed.\nThe predefined scheme-full installs all of TeX Live (recommended).");
+ $inf->pack(-padx => "3m", -pady => "3m");
+ $af->pack(-expand => 1, -fill => "both");
+ $bf->pack(-expand => 1, -fill => "both");
+
+ unpack_buttons();
+ $nxt->configure(-command => \&ask_path, -text => "Next");
+ $prv->configure(-text => "Previous", -command => \&reset_start);
+ pack_buttons("cancel", "prev", "next");
+}
+
+sub ask_path {
+ for ($fmain->children) {
+ $_->destroy;
+ }
+
+ my $af = $fmain->Frame;
+ my $bf = $fmain->Frame;
+ $af->pack(-expand => 1, -fill => "both");
+ $bf->pack(-expand => 1, -fill => "both");
+
+ my $lab = $af->Label(-text => "Destination Folder:");
+ $lab->pack(-side => "left");
+ my $val = $af->Label(-textvar => \$dest);
+ $val->pack(-side => "left", -padx => "3m");
+ my $but = $af->Button(-text => "Change", -command => \&change_path, -relief => "ridge", -width => 10);
+ $but->pack(-side => "right");
+
+ my $inf = $bf->Label(-text => "The destination folder will contain the installation.\nIt is recommended to keep the year as last component.");
+ $inf->pack(-padx => "3m", -pady => "3m");
+
+ unpack_buttons();
+ $nxt->configure(-command => \&ask_go);
+ $prv->configure(-text => "Previous", -command => \&ask_scheme);
+ pack_buttons("cancel", "prev", "next");
+}
+
+sub ask_go {
+ for ($fmain->children) {
+ $_->destroy;
+ }
+
+ my $inf = $fmain->Label(-justify => "left", -text => "We are ready to install TeX Live 2008.\nThe following settings will be used.\nIf you want to change something please go back,\notherwise press the \"Install\" button.\n\nDestination folder: $dest\nSelected scheme: $vars{'selected_scheme'}");
+ $inf->pack(-padx => "3m");
+
+ unpack_buttons();
+ $nxt->configure(-command => \&installation_window, -text => "Install");
+ $prv->configure(-text => "Previous", -command => \&ask_path);
+ pack_buttons("cancel", "prev", "next");
+}
+
+sub change_path {
+ my $val = $dest;
+ my $sw = $mw->Toplevel(-title => "Changing TEXDIR");
+ $sw->transient($mw);
+ $sw->grab();
+ $sw->Label(-text => $text{'enterpath'} . " TEXDIR: ")->pack(-padx => "2m", -pady => "2m");
+ my $entry = $sw->Entry(-textvariable => $val, -width => 60);
+ $entry->pack(-padx => "2m", -pady => "2m");
+ my $f = $sw->Frame;
+ my $okbutton = $f->Button(-text => $text{'ok'}, -relief => "ridge",
+ -command => sub { $val = $entry->get; callback_change_texdir($val) ; $sw->destroy })->pack(-side => 'left', -padx => "2m", -pady => "2m");
+ my $cancelbutton = $f->Button(-text => $text{'cancel'}, -relief => "ridge",
+ -command => sub { $sw->destroy })->pack(-side => 'right', -padx => "2m", -pady => "2m");
+ $f->pack(-expand => 'x');
+ # bindings
+ $sw->bind('<Return>' => [ $okbutton, 'Invoke']);
+ $sw->bind('<Escape>' => [ $cancelbutton, 'Invoke']);
+}
+
+sub callback_change_texdir {
+ my ($val) = @_;
+ my $home = getenv('HOME');
+ if (win32()) {
+ $home = getenv('USERPROFILE');
+ $home =~ s!\\!/!g;
+ }
+ $home ||= '~';
+ $val =~ s!\\!/!g;
+ $vars{'TEXDIR'} = $val;
+ $vars{'TEXDIR'} =~ s/^~/$home/;
+ $vars{'TEXMFLOCAL'} =~ s/^~/$home/;
+ $vars{'TEXMFSYSVAR'} =~ s/^~/$home/;
+ $vars{'TEXMFSYSCONFIG'} =~ s/^~/$home/;
+ # only if we set TEXDIR we set the others in parallel
+ if ($vars{'TEXDIR'}=~/^(.*)\/$texlive_release$/) {
+ $vars{'TEXMFLOCAL'}="$1/texmf-local";
+ $vars{'TEXMFSYSVAR'}="$1/$texlive_release/texmf-var";
+ $vars{'TEXMFSYSCONFIG'}="$1/$texlive_release/texmf-config";
+ } elsif ($vars{'TEXDIR'}=~/^(.*)$/) {
+ $vars{'TEXMFLOCAL'}="$1/texmf-local";
+ $vars{'TEXMFSYSVAR'}="$1/texmf-var";
+ $vars{'TEXMFSYSCONFIG'}="$1/texmf-config";
+ }
+ $vars{'TEXDIRW'}=$vars{'TEXDIR'};
+ $dest = $vars{'TEXDIR'};
+}
+
sub installation_window {
- # create a progress bar window
+# create a progress bar window
$::sww = $mw->Toplevel(-title => "installation process",
- -width => 400);
+ -width => 400);
$::sww->transient($mw);
$::sww->grab();
$::sww->Label(-text => "Installation process")->pack;
@@ -248,23 +422,21 @@ sub installation_window {
$::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' ]);
+ -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; $mw->destroy;
- do_cleanup(); exit(1); }
- )->pack(-pady => "2m");
+ my $b = $f->Button(-text => $text{'cancel'}, -relief => "ridge",
+ -command => sub { $::sww->destroy; $mw->destroy;
+ do_cleanup(); exit(1); }
+ )->pack(-pady => "2m");
$f->pack;
- # set the vars
- $vars{'TEXDIR'} = $dest;
- $vars{'TEXDIRW'} = $dest;
- $vars{'TEXMFHOME'} = "~/texmf";
- $vars{'TEXMFSYSVAR'} = "$dest/texmf-var";
- $vars{'TEXMFSYSCONFIG'} = "$dest/texmf-config";
- $vars{'TEXMFLOCAL'} = dirname($dest) . "/texmf-local";
+# set the vars
+ calc_depends();
+ $mw->Busy(-recurse => 1);
do_installation();
+ $mw->Unbusy;
+ $::sww->destroy;
$return = $MENU_ALREADYDONE;
my $t = $text{'finished'};
if (!win32()) {
@@ -274,85 +446,69 @@ sub installation_window {
$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'},
+ for ($fmain->children) {
+ $_->destroy;
+ }
+ $can->packForget;
+ $prv->packForget;
+ my $lab = $fmain->ROText(-height => 16);
+ my $linechar = $lab->index("end");
+ $lab->markSet("finaltext", $linechar);
+ $lab->markGravity("finaltext", "left");
+ $lab->insert("end", "\n$t");
+ $lab->see("end");
+ $lab->tagAdd("centered", $linechar, "end");
+ $lab->tagConfigure("centered", -justify => "center");
+ $lab->pack;
+ $nxt->configure(-text => $text{'finbut'},
-command => sub { $mw->destroy; });
}
-sub menu_edit_texdir {
- my $key = shift;
- our $addyear = 1;
- our $addtexlive = 1;
- my $val = $vars{$key};
- our $currsel;
- our $entry;
- sub update_label {
- my $t = $currsel;
- $t .= "/texlive" if ($addtexlive);
- $t .= "/$texlive_release" if ($addyear);
- $entry->configure(-text => "$t");
- }
- my $hint_var;
- if ($key ne 'TEXMFHOME') {
- $hint_var = win32() ? $ENV{'USERPROFILE'} : $ENV{'HOME'};
- } else {
- $hint_var = win32() ? '%USERPROFILE%' : '$HOME';
- }
- my $hint_text = $text{'hinthome'};
- $hint_text =~ s/%%%/$hint_var/;
- if ($val =~ m!^(.*)/texlive/$texlive_release$!) {
- $currsel = "$1";
- $addyear = 1;
- $addtexlive = 1;
- } elsif ($val =~ m!^(.*)/$texlive_release$!) {
- $currsel = "$1";
- $addyear = 1;
- $addtexlive = 0;
- } elsif ($val =~ m!^(.*)/texlive$!) {
- $currsel = "$1";
- $addyear = 0;
- $addtexlive = 1;
- } else {
- $addyear = 0;
- $addtexlive = 0;
- $currsel = $val;
- }
- my $sw = $mw->Toplevel(-title => $text{'changevar'});
+sub change_scheme {
+ my $sw = $mw->Toplevel(-title => $labels{'scheme'});
$sw->transient($mw);
$sw->grab();
- $sw->Label(-text => $text{'enterpath'} . " $key: " . $hint_text)->pack(-padx => "2m", -pady => "2m");
- $entry = $sw->Entry(-width => 60)->pack(-padx => "2m", -pady => "2m");
- my $f = $sw->Frame;
- my $c1 = $f->Checkbutton(-text => 'Add "texlive"', -variable => \$addtexlive,
- -command => \&update_label);
- my $c2 = $f->Checkbutton(-text => "Add \"$texlive_release\"", -variable => \$addyear,
- -command => \&update_label);
- my $foo = $sw->Scrolled("DirTree", -scrollbars => "osoe",
- -browsecmd => sub { my ($d) = @_; $currsel = $d; update_label(); },
- -directory => "$currsel");
- my $ff = $sw->Frame;
- my $ok = $ff->Button(-text => $text{'ok'}, -command => sub { $val = $entry->get; callback_edit_directories($key,$val); $sw->destroy; });
- my $cancel = $ff->Button(-text => $text{'cancel'}, -command => sub { $sw->destroy; });
- update_label();
- $c1->pack(-side => 'left', -padx => "2m", -pady => "2m");
- $c2->pack(-side => 'right', -padx => "2m", -pady => "2m");
- $f->pack;
- $foo->pack(-fill => "both", -expand => 1);
- $ok->pack(-side => 'left' , -padx => "2m", -pady => "2m");
- $cancel->pack(-side => 'right', -padx => "2m", -pady => "2m");
- $ff->pack;
- # bindings
- $sw->bind('<Return>' => [ $ok, 'Invoke']);
- $sw->bind('<Escape>' => [ $cancel, 'Invoke']);
+ my @schemes;
+ foreach my $pkg ($tlpdb->list_packages) {
+ my $tlpobj = $tlpdb->{'tlps'}{$pkg};
+ if ($tlpobj->category eq "Scheme") {
+ push @schemes, $pkg;
+ $vars{"$pkg"}=($vars{'selected_scheme'} eq $pkg)? 1:0;
+ }
+ }
+ @schemes=sort @schemes;
+ my $selected = $vars{'selected_scheme'};
+ $sw->Label(-text => $text{'selectscheme'})->pack(-padx => "2m", -pady => "2m");
+ my $f2 = $sw->Frame;
+ my $f2l = $f2->Frame;
+ my $f2r = $f2->Frame;
+ my $nrfh = $#schemes / 2;
+ my $i = 0;
+ foreach my $scheme (@schemes) {
+ my $tlpobj = $tlpdb->get_package("$scheme");
+ if ($i < $nrfh) {
+ $f2l->Radiobutton(-variable => \$selected, -value => $scheme,
+ -text => $tlpobj->shortdesc)->pack(-anchor => 'w');
+ } else {
+ $f2r->Radiobutton(-variable => \$selected, -value => $scheme,
+ -text => $tlpobj->shortdesc)->pack(-anchor => 'w');
+ }
+ $i++;
+ }
+ $f2l->pack(-side => 'left', -padx => "2m", -pady => "2m");
+ $f2r->pack(-side => 'right', -padx => "2m", -pady => "2m");
+ $f2->pack;
+ my $f3 = $sw->Frame;
+ my $okbutton = $f3->Button(-text => $text{'ok'}, -relief => "ridge",
+ -command => sub { my $s = shift; print "s=$selected\n"; select_scheme($selected) ; $sw->destroy })->pack(-side => 'left', -padx => "2m", -pady => "2m");
+ my $cancelbutton = $f3->Button(-text => $text{'cancel'}, -relief => "ridge",
+ -command => sub { $sw->destroy })->pack(-side => 'left', -padx => "2m", -pady => "2m");
+ $f3->pack(-expand => 'x');
+ $sw->bind('<Return>' => [ $okbutton, 'Invoke']);
+ $sw->bind('<Escape>' => [ $cancelbutton, 'Invoke']);
}
+
1;
__END__