From d9d754c635a627700daccf7290cb4c5ab0cba821 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 9 May 2012 00:15:38 +0000 Subject: more work on tlmgr gui location handling git-svn-id: svn://tug.org/texlive/trunk@26265 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf/scripts/texlive/tlmgr.pl | 13 ++++++- Master/texmf/scripts/texlive/tlmgrgui.pl | 65 +++++++++++++++++++------------- 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index f2e1d9e1649..647eb29510d 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -3493,6 +3493,11 @@ sub show_list_of_packages { sub array_to_repository { my %r = @_; my @ret; + my @k = keys %r; + if ($#k == 0) { + # only one repo, don't write any tag + return $r{$k[0]}; + } for my $k (keys %r) { my $v = $r{$k}; if ($k eq $v) { @@ -3506,7 +3511,13 @@ sub array_to_repository { sub repository_to_array { my $r = shift; my %r; - for my $rr (split ' ', $r) { + my @repos = split ' ', $r; + if ($#repos == 0) { + # only one repo, this is the main one! + $r{'main'} = $repos[0]; + return %r; + } + for my $rr (@repos) { if ($rr =~ m/^([^#]+)#(.*)$/) { $r{$2} = $1; } else { diff --git a/Master/texmf/scripts/texlive/tlmgrgui.pl b/Master/texmf/scripts/texlive/tlmgrgui.pl index 565624af11c..8ccd655253e 100644 --- a/Master/texmf/scripts/texlive/tlmgrgui.pl +++ b/Master/texmf/scripts/texlive/tlmgrgui.pl @@ -1118,22 +1118,20 @@ sub do_general_settings { push @config_set_l, $back_config_set->Label(-text => __("Default package repository"), -anchor => "w"); + + + $location_button = $back_config_set->Button(-relief => 'flat', + -textvariable => \$changeddefaults{"location"}{'display'}); + + push @config_set_m, $location_button; + push @config_set_r, + $back_config_set->Button(-text => __("Change"), + -command => sub { menu_multi_location($sw); }); + if ($#tlpdb_tags > 0) { my @vals = map { "$_:$tlpdb_repos{$_}" } sort sort_main_first @tlpdb_tags; - $location_button = $back_config_set->Button(-relief => 'flat', - -textvariable => \$changeddefaults{"location"}{'display'}); $location_button->configure( -command => sub { transient_show_multiple_repos($location_button, @vals); }); - push @config_set_m, $location_button; - push @config_set_r, - $back_config_set->Button(-text => __("Change"), - -command => sub { menu_multi_location($sw); }); - } else { - push @config_set_m, - $back_config_set->Label(-textvariable => \$changeddefaults{"location"}{'display'}); - push @config_set_r, - $back_config_set->Button(-text => __("Change"), - -command => sub { menu_default_location($sw); }); } @@ -1262,8 +1260,17 @@ sub apply_settings_changes { # change interface to program, too # set default tlpdb location $tlpdb_location = $changeddefaults{'location'}{'value'}; - # change the menu entry in File->Load defualt... - $menu_file->entryconfigure(1, -label => __("Load default repository:") . " $tlpdb_location"); + # update tlpdb_repos and tlpdb_tags accordingly + %tlpdb_repos = repository_to_array($tlpdb_location); + @tlpdb_tags = keys %tlpdb_repos; + # change the menu entry in File->Load default... + if ($#tlpdb_tags > 0) { + my @vals = map { "$_:$tlpdb_repos{$_}" } + sort sort_main_first keys %tlpdb_repos; + $menu_file->entryconfigure(1, -label => __("Load default repository:") . " " . __("multiple repositories")); + } else { + $menu_file->entryconfigure(1, -label => __("Load default repository:") . " $tlpdb_location"); + } } } } @@ -1510,15 +1517,15 @@ sub ask_one_repository { return $val; } -sub menu_default_location { - my $mw = shift; - my $ret = ask_one_repository($mw, __("Change default package repository"), - __("New default package repository")); - if (defined($ret)) { - $changeddefaults{'location'}{'value'} = - $changeddefaults{'location'}{'display'} = $ret; - } -} +#sub menu_default_location { +# my $mw = shift; +# my $ret = ask_one_repository($mw, __("Change default package repository"), +# __("New default package repository")); +# if (defined($ret)) { +# $changeddefaults{'location'}{'value'} = +# $changeddefaults{'location'}{'display'} = $ret; +# } +#} sub sort_main_first { if ($a eq 'main') { @@ -1658,11 +1665,17 @@ sub menu_multi_location { # print "act = $ref->{'status'}\n"; # } $changeddefaults{'location'}{'value'} = array_to_repository(%new_repos); - $changeddefaults{'location'}{'display'} = __("multiple repositories"); my @vals = map { "$_:$new_repos{$_}" } sort sort_main_first keys %new_repos; - $location_button->configure( - -command => sub { transient_show_multiple_repos($location_button, @vals); }); + if ($#vals > 0) { + $location_button->configure( + -command => sub { transient_show_multiple_repos($location_button, @vals); }); + $changeddefaults{'location'}{'display'} = __("multiple repositories"); + } else { + $changeddefaults{'location'}{'display'} = $changeddefaults{'location'}{'value'}; + $location_button->configure( + -command => undef); + } } else { # print "Nothing happend!\n"; } -- cgit v1.2.3