summaryrefslogtreecommitdiff
path: root/Master/texmf/scripts/texlive/tlmgrgui/gui-arch.pl
blob: d0ab708dbffd5aca1b804d3e4422dbd5354f6179 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# gui-arch.pl
# $Id$
#
# Copyright 2009 Tomasz Luczak, Norbert Preining
#
# GUI for tlmgr
#


our $back_arch = $back->add("arch",-label => "Architectures");
$screens{"arch"} = $back_arch;

# this will be loaded only on unix systems!
#

my @archsavail;
my @archsinstalled;
my %archs;

init_archs();

$back_arch->Label(-text => "Select architectures to be added (removal not possible)")->pack(-padx => "5m", -pady => "5m");
foreach my $a (@archsavail) {
  $back_arch->Checkbutton(-command => sub { check_on_removal($a); },
                          -variable => \$archs{$a}, 
                          -text => platform_desc($a)
                         )->pack(-anchor => 'w');
}

my $f = $back_arch->Frame;
$f->pack(-padx => "10m", -pady => "5m");
$f->Button(-text => "Apply changes", -command => sub { apply_changes(); })->pack(-side => 'left', -padx => "3m");
$f->Button(-text => "Reset changes", -command => sub { init_archs(); })->pack(-side => 'left', -padx => "3m");

sub init_archs {
  @archsavail = $tlmediatlpdb->available_architectures;
  @archsinstalled = $localtlpdb->available_architectures;
  foreach my $a (@archsavail) {
    $archs{$a} = 0;
    if (grep(/^$a$/,@archsinstalled)) {
      $archs{$a} = 1;
    }
  }
}

sub check_on_removal {
  my $a = shift;
  if (!$archs{$a} && grep(/^$a$/,@archsinstalled)) {
    # removal not supported
    $archs{$a} = 1;
    $f->Dialog(-title => "info",
               -text => "Removals of archs currently not supported!",
               -buttons => [ "Ok" ])->Show;
  }
}


sub apply_changes {
  my @todo;
  foreach my $a (@archsavail) {
    next if grep(/^$a$/,@archsinstalled);
    push @todo, $a if $archs{$a};
  }
  if (@todo) {
    run_program_show_output("tlmgr", "--location", "$location", "arch", "add", @todo);
    reinit_local_tlpdb();
    init_archs();
  }
}

1;

### Local Variables:
### perl-indent-level: 2
### tab-width: 2
### indent-tabs-mode: nil
### End:
# vim:set tabstop=2 expandtab: #