diff options
author | Norbert Preining <preining@logic.at> | 2008-05-05 20:19:21 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2008-05-05 20:19:21 +0000 |
commit | e9458f0ec3406ae7d3455728d87c5a8545f22a1f (patch) | |
tree | a5c63cf4941cfbf575c81004629db041fe598381 | |
parent | 1bbce2b0cb5a3f7cc12c400a27b10a5492c4878f (diff) |
configuration dialog for tlmgrgui
git-svn-id: svn://tug.org/texlive/trunk@7875 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl | 198 | ||||
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl | 16 |
2 files changed, 214 insertions, 0 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl b/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl new file mode 100644 index 00000000000..65e0751762f --- /dev/null +++ b/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl @@ -0,0 +1,198 @@ +# gui-config.pl +# $Id$ +# +# Copyright 2009 Tomasz Luczak, Norbert Preining +# +# GUI for tlmgr +# + + +my $default_location = $localtlpdb->option_location; +my $default_formats = ($localtlpdb->option_formats ? "Yes" : "No"); +my $default_docfiles = ($localtlpdb->option_docfiles ? "Yes" : "No"); +my $default_srcfiles = ($localtlpdb->option_srcfiles ? "Yes" : "No"); + +# frame .back.f1 +$back_config = $back->Frame; + +# this will be loaded only on unix systems! +# + +my $back_config_set = $back_config->Labelframe(-text => "Default settings"); +$back_config_set->pack; + +my $back_config_set_l1 = $back_config_set->Label(-text => "Default installation source", -anchor => "w"); +my $back_config_set_m1 = $back_config_set->Label(-textvariable => \$default_location); +my $back_config_set_r1 = $back_config_set->Button(-text => "Change", + -command => sub { menu_default_location(); }); + +my $back_config_set_l2 = $back_config_set->Label(-text => "Create formats on installation", -anchor => "w"); +my $back_config_set_m2 = $back_config_set->Label(-textvariable => \$default_formats); +my $back_config_set_r2 = $back_config_set->Button(-text => "Toggle", + -command => sub { toggle_setting("formats"); }); + +my $back_config_set_l3 = $back_config_set->Label(-text => "Install macro/font docs", -anchor => "w"); +my $back_config_set_m3 = $back_config_set->Label(-textvariable => \$default_docfiles); +my $back_config_set_r3 = $back_config_set->Button(-text => "Toggle", + -command => sub { toggle_setting("docfiles"); }); + +my $back_config_set_l4 = $back_config_set->Label(-text => "Install macro/font sources", -anchor => "w"); +my $back_config_set_m4 = $back_config_set->Label(-textvariable => \$default_srcfiles); +my $back_config_set_r4 = $back_config_set->Button(-text => "Toggle", + -command => sub { toggle_setting("srcfiles"); }); + + +$back_config_set_l1->grid(-row => 1, -column => 1, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_m1->grid(-row => 1, -column => 2, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_r1->grid(-row => 1, -column => 3, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_l2->grid(-row => 2, -column => 1, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_m2->grid(-row => 2, -column => 2, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_r2->grid(-row => 2, -column => 3, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_l3->grid(-row => 3, -column => 1, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_m3->grid(-row => 3, -column => 2, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_r3->grid(-row => 3, -column => 3, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_l4->grid(-row => 4, -column => 1, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_m4->grid(-row => 4, -column => 2, + -padx => "2m", -pady => "2m", -sticky => "nwe"); +$back_config_set_r4->grid(-row => 4, -column => 3, + -padx => "2m", -pady => "2m", -sticky => "nwe"); + +############# + +my $back_config_pap = $back_config->Labelframe(-text => "Paper settings"); + + +my $back_config_pap_l1 = $back_config_pap->Label(-text => "Default paper for all", -anchor => "w"); +my $back_config_pap_m1 = $back_config_pap->Button(-text => "A4", + -command => sub { change_paper("all", "a4"); }); +my $back_config_pap_r1 = $back_config_pap->Button(-text => "letter", + -command => sub { change_paper("all", "letter"); }); + +$back_config_pap_l1->grid(-row => 1, -column => 1, + -padx => "2m", -pady => "2m", -sticky => "nswe"); +$back_config_pap_m1->grid(-row => 1, -column => 2, + -padx => "2m", -pady => "2m", -sticky => "nswe"); +$back_config_pap_r1->grid(-row => 1, -column => 3, + -padx => "2m", -pady => "2m", -sticky => "nswe"); + +my %papers; +@{$papers{"xdvi"}} = `tlmgr xdvi paper --list`; +chomp(@{$papers{"xdvi"}}); +@{$papers{"pdftex"}} = `tlmgr pdftex paper --list`; +chomp(@{$papers{"pdftex"}}); +@{$papers{"dvipdfm"}} = `tlmgr dvipdfm paper --list`; +chomp(@{$papers{"dvipdfm"}}); +@{$papers{"dvipdfmx"}} = `tlmgr dvipdfmx paper --list`; +chomp(@{$papers{"dvipdfmx"}}); +@{$papers{"dvips"}} = `tlmgr dvips paper --list`; +chomp(@{$papers{"dvips"}}); + +my %defaultpaper; +my $row = 2; +my (%l,%m,%r); +foreach my $p (sort keys %papers) { + my @pap = @{$papers{$p}}; + $defaultpaper{$p} = $pap[0]; + $l{$p} = $back_config_pap->Label(-text => "default paper for $p", -anchor => "w"); + $m{$p} = $back_config_pap->Label(-textvariable => \$defaultpaper{$p}, -anchor => "w"); + $r{$p} = $back_config_pap->Button(-text => "Change", + -command => sub { select_paper($p); }, -anchor => "w"); + $l{$p}->grid(-row => $row, -column => 1, + -padx => "2m", -pady => "2m", -sticky => "nsw"); + $m{$p}->grid(-row => $row, -column => 2, + -padx => "2m", -pady => "2m", -sticky => "nsw"); + $r{$p}->grid(-row => $row, -column => 3, + -padx => "2m", -pady => "2m", -sticky => "nsw"); + $row++; +} + +$back_config_pap->pack; + +sub menu_default_location { + my $val = $default_location; + my $sw = $mw->Toplevel(-title => "Change default installation source"); + $sw->Label(-text => "New default installation source: ")->pack; + my $entry = $sw->Entry(-text => $location, -width => 30); + $entry->pack; + my $f = $sw->Frame; + $f->Button(-text => 'ok', + -command => sub { $default_location = $entry->get; + $localtlpdb->option_location($default_location); + $localtlpdb->save; + $sw->destroy })->pack(-side => 'left'); + $f->Button(-text => 'cancel', + -command => sub { $sw->destroy })->pack(-side => 'right'); + $f->pack(-expand => 'x'); +} + + +sub toggle_setting() { + my ($key) = @_; + if ($key eq "formats") { + my $new = not($localtlpdb->option_formats); + $localtlpdb->option_formats($new); + $default_formats = ($new ? "Yes" : "No"); + } elsif ($key eq "srcfiles") { + my $new = not($localtlpdb->option_srcfiles); + $localtlpdb->option_srcfiles($new); + $default_srcfiles = ($new ? "Yes" : "No"); + } elsif ($key eq "docfiles") { + my $new = not($localtlpdb->option_docfiles); + $localtlpdb->option_docfiles($new); + $default_docfiles = ($new ? "Yes" : "No"); + } + $localtlpdb->save; +} + + +sub change_paper { + my ($prog, $pap) = @_; + if ($prog eq "all") { + run_program_show_output("tlmgr", "paper", $pap); + foreach my $p (keys %papers) { + $defaultpaper{$p} = $pap; + } + } else { + run_program_show_output("tlmgr", $prog, "paper", $pap); + $defaultpaper{$prog} = $pap; + } +} + +sub select_paper { + my $prog = shift; + my $foo = $back_config->Toplevel(-title => "paper select for $prog"); + my $var = $defaultpaper{$prog}; + my @lop = @{$papers{$prog}}; + my $nrpercols = 15; + my $row = 1; + my $col = 1; + foreach my $p (sort @{$papers{$prog}}) { + $foo->Radiobutton(-variable => \$var, -value => $p, -text => $p, -anchor => "w")->grid(-row => $row, -column => $col, -padx => "2m", -pady => "2m", -sticky => "nsw"); + $row++; + if ($row > $nrpercols) { + $col++; + $row = 1; + } + } + $foo->Button(-text => "Ok", -command => sub { change_paper($prog,$var); $foo->destroy; })->grid(-row => $nrpercols+1, -column => 1); + $foo->Button(-text => "Cancel", -command => sub { $foo->destroy; })->grid(-row => $nrpercols+1, -column => 2); +} + +1; + +### Local Variables: +### perl-indent-level: 2 +### tab-width: 2 +### indent-tabs-mode: nil +### End: +# vim:set tabstop=2 expandtab: # diff --git a/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl b/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl index 3044bf7450f..05252044007 100755 --- a/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl +++ b/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl @@ -43,6 +43,7 @@ our $back_f1; our $back_f2; our $back_f3; our $back_arch; +our $back_config; our $localtlpdb = TeXLive::TLPDB->new ("root" => "$Master"); die("cannot find tlpdb!") unless (defined($localtlpdb)); @@ -82,6 +83,7 @@ our $b1 = $top->Button(-text => "Adding packages", $back_f2->packForget; $back_f3->packForget; $back_arch->packForget; + $back_config->packForget; $back_f1->pack; }); @@ -94,6 +96,7 @@ our $b2 = $top->Button(-text => "Removing packages", $back_f1->packForget; $back_f3->packForget; $back_arch->packForget; + $back_config->packForget; $back_f2->pack; }); @@ -102,6 +105,7 @@ our $b3 = $top->Button(-text => "Uninstallation", $back_f1->packForget; $back_f2->packForget; $back_arch->packForget; + $back_config->packForget; $back_f3->pack; }); @@ -110,8 +114,18 @@ our $b4 = $top->Button(-text => "Architectures", $back_f1->packForget; $back_f2->packForget; $back_f3->packForget; + $back_config->packForget; $back_arch->pack; }); +our $b5 = $top->Button(-text => "Configuration", + -command => sub { + $back_f1->packForget; + $back_f2->packForget; + $back_f3->packForget; + $back_arch->packForget; + $back_config->pack; + }); + our $quit = $top->Button(-text => "Quit", -command => sub { $mw->destroy; exit(0); }); @@ -121,6 +135,7 @@ $b1->pack(-side => 'left'); $b2->pack(-side => 'left'); $b3->pack(-side => 'left'); $b4->pack(-side => 'left'); +$b5->pack(-side => 'left'); $quit->pack(-side => 'right'); @@ -135,6 +150,7 @@ require("gui-install.pl"); require("gui-remove.pl"); require("gui-uninstall.pl"); require("gui-arch.pl"); +require("gui-config.pl"); # pack .back.f1 $back_f1->pack; |