From fdfb1ff9a50249aa81781f5f117ae3f628bcc41e Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 6 Apr 2010 08:52:13 +0000 Subject: GUI: add support for the three command line options: --no-auto-install, --no-auto-remove (under Menu->Options), and --reinstall-forcibly-removed (just below the "Update all installed" button) at the same time simplify some code flow, remove duplication, and make sure that pressing "update all" without loading the remote db first does not break tlmgrgui, but loads the database and updates all. git-svn-id: svn://tug.org/texlive/trunk@17732 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf/scripts/texlive/NEWS | 3 + Master/texmf/scripts/texlive/tlmgrgui.pl | 98 ++++++++++++++++++++++---------- 2 files changed, 70 insertions(+), 31 deletions(-) (limited to 'Master') diff --git a/Master/texmf/scripts/texlive/NEWS b/Master/texmf/scripts/texlive/NEWS index 4677f19ff3e..64b3132028a 100644 --- a/Master/texmf/scripts/texlive/NEWS +++ b/Master/texmf/scripts/texlive/NEWS @@ -6,6 +6,9 @@ tlmgr rev next * tlmgr restore --all: restoring the latest, using all available backups. * GUI: add support for restore action. * do not auto-install packages contained in forcibly removed collections. + * GUI: add support for the three command line options: --no-auto-install, + --no-auto-remove (under Menu->Options), and --reinstall-forcibly-removed + (just below the "Update all installed" button) tlmgr rev 17611 (2010-03-30) diff --git a/Master/texmf/scripts/texlive/tlmgrgui.pl b/Master/texmf/scripts/texlive/tlmgrgui.pl index 09b5f79cba0..e3a7d939e88 100644 --- a/Master/texmf/scripts/texlive/tlmgrgui.pl +++ b/Master/texmf/scripts/texlive/tlmgrgui.pl @@ -35,6 +35,10 @@ use Tk::BrowseEntry; use Tk::ROText; use Tk::HList; use Tk::ItemStyle; + +# not ready yet +# use Pod::Text; + #use TeXLive::Splashscreen; #use Devel::Leak; @@ -143,11 +147,20 @@ sub guimain { info(__("Loading local TeX Live Database\nThis may take some time, please wait!") . "\n"); - $localtlmedia = TeXLive::TLMedia->new ( $Master ); - die("cannot setup TLMedia in $Master") unless (defined($localtlmedia)); - $localtlpdb = $localtlmedia->tlpdb; - die("cannot find tlpdb!") unless (defined($localtlpdb)); + # call the init function from tlmgr.pl + # with 0 as argument, so that it does not call die on errors. + init_local_db(0); + # before this code was used, which is a duplication, and in addition + # it does not handle auto-loading of $location + #$localtlmedia = TeXLive::TLMedia->new ( $Master ); + #die("cannot setup TLMedia in $Master") unless (defined($localtlmedia)); + #$localtlpdb = $localtlmedia->tlpdb; + #die("cannot find tlpdb!") unless (defined($localtlpdb)); + # + # init_local_db sets up $location to the winning one: + # cmd line > tlpdb + # save the two possible location for the menu $tlpdb_location = $localtlpdb->option("location"); if (defined($opts{"location"})) { $cmdline_location = $opts{"location"}; @@ -157,7 +170,8 @@ sub guimain { push @update_function_list, \&check_location_on_ctan; push @update_function_list, \&init_install_media; - setup_programs("$Master/tlpkg/installer", $localtlmedia->platform); + # already done by init_local_db above + # setup_programs("$Master/tlpkg/installer", $localtlmedia->platform); # # check that we can actually save the database @@ -180,9 +194,7 @@ sub guimain { if ($opts{"load"}) { - $location = $tlpdb_location; - update_loaded_location_string(); - run_update_functions(); + setup_location($tlpdb_location); } @@ -240,10 +252,7 @@ sub do_rest_of_gui { $loaded_button = $mw->Button(-text => __("Loaded repository:") . " " . __("none"), -relief => 'flat', - -command => sub { $location = $tlpdb_location; - update_loaded_location_string(); - run_update_functions(); - }); + -command => sub { setup_location($tlpdb_location); }); $loaded_button->pack(-anchor => 'e', -padx => 0, -pady => 0, -ipadx => 0, -ipady => 0); @@ -351,7 +360,10 @@ $g->headerCreate(4, @htype, -itemtype => 'text', -text => __("Short description" $with_all_frame->Button(-text => __('Update all installed'), -state => $::action_button_state, -command => sub { update_all_packages(); } - )->pack(@a_c,@left,@p_ii); + )->pack(@p_ii); + $with_all_frame->Checkbutton(-text => __("Reinstall previously removed packages"), + -variable => \$opts{"reinstall-forcibly-removed"})->pack(); + my $with_sel_frame = $actions_frame->Frame; $with_sel_frame->pack(@left, -padx => '5m'); @@ -430,25 +442,13 @@ sub setup_menu_system { # $menu_file->add('command', -label => __("Load default repository:") . " $tlpdb_location", - -command => sub { - $location = $tlpdb_location; - update_loaded_location_string(); - run_update_functions(); - }); + -command => sub { setup_location($tlpdb_location); }); if (defined($cmdline_location)) { $menu_file->add('command', -label => __("Load cmd line repository:") . " $cmdline_location", - -command => sub { - $location = $cmdline_location; - update_loaded_location_string(); - run_update_functions(); - }); + -command => sub { setup_location($cmdline_location); }); } $menu_file->add('command', -label => __("Load default net repository:") . " $TeXLiveURL", - -command => sub { - $location = $TeXLiveURL; - update_loaded_location_string(); - run_update_functions(); - }); + -command => sub { setup_location($TeXLiveURL); }); $menu_file->add('command', -label => __("Load other repository ..."), -command => \&cb_edit_location); $menu_file->add('separator'); @@ -467,9 +467,15 @@ sub setup_menu_system { -command => sub { do_arch_settings(); }); } $menu_options->add('separator'); - $menu_options->add('checkbutton', -label => __("Debug"), + $menu_options->add('checkbutton', -label => __("Enable debugging output"), -onvalue => ($::opt_verbosity == 0 ? 1 : $::opt_verbosity), -variable => \$::opt_verbosity); + $menu_options->add('checkbutton', + -label => __("Disable auto-install of new packages"), + -variable => \$opts{"no-auto-install"}); + $menu_options->add('checkbutton', + -label => __("Disable auto-removal of server-deleted packages"), + -variable => \$opts{"no-auto-remove"}); # # Actions menu @@ -542,6 +548,9 @@ sub setup_menu_system { # # HELP MENU + # + # not ready yet + # $menu_help->add('command', -label => __("Docs"), -command => \&pod_to_text); $menu_help->add('command', -label => __("About"), -command => sub { my $sw = $mw->DialogBox(-title => __("About"), @@ -1351,6 +1360,13 @@ sub select_file_assocs { ############################ +sub setup_location { + my $loc = shift; + $location = $loc; + update_loaded_location_string(); + run_update_functions(); +} + sub init_install_media { my $newroot = $location; if (defined($tlmediatlpdb) && ($tlmediatlpdb->root eq $newroot)) { @@ -1375,6 +1391,7 @@ sub init_install_media { $tlmediatlpdb = $tlmediasrc->tlpdb; update_list_remote(); update_grid(); + update_loaded_location_string($location); } } } @@ -1389,6 +1406,8 @@ sub set_text_win { sub install_selected_packages { my @foo = SelectedPackages(); if (@foo) { + # that doesn't hurt if it is already loaded + init_install_media(); my @args = qw/install/; push @args, @foo; execute_action_gui(@args); @@ -1425,6 +1444,8 @@ sub update_all_packages { } else { $opts{"all"} = 1; } + # that doesn't hurt if it is already loaded + init_install_media(); execute_action_gui(qw/update/); if (@critical_updates) { # terminate here immediately so that we are sure the auto-updater @@ -1439,6 +1460,8 @@ sub update_all_packages { sub update_selected_packages { my @foo = SelectedPackages(); if (@foo) { + # that doesn't hurt if it is already loaded + init_install_media(); my @args = qw/update/; # argument processing # in case we have critical updates present we do put the list of @@ -1899,8 +1922,7 @@ sub cb_edit_location { my $okbutton = $f->Button(-text => __("Ok"), -command => sub { $location = $entry->get; $sw->destroy; - update_loaded_location_string(); - run_update_functions(); + setup_location($location); })->pack(@left, @p_ii); my $cancelbutton = $f->Button(-text => __("Cancel"), -command => sub { $sw->destroy })->pack(@right, @p_ii); @@ -1948,6 +1970,20 @@ sub give_warning_window { $sw->Show; } +# pod help thing + +sub pod_to_text { + my $txt; + my $parser = Pod::Simple->new (sentence => 0, width => 78); + $parser->output_string( \$txt ); + $parser->parse_file("$Master/texmf/scripts/texlive/tlmgr.pl"); + my $sw = $mw->Toplevel(-title => __("Help")); + $sw->transient($mw); + my $t = $sw->ROText(-height => 40, -width => 80); + $t->Contents($txt); + $t->pack; +} + 1; __END__ -- cgit v1.2.3