diff options
author | Norbert Preining <preining@logic.at> | 2009-12-15 14:55:06 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2009-12-15 14:55:06 +0000 |
commit | 6616b6780cff53f09ab22d95d3c266230f0c8d31 (patch) | |
tree | 6bca98fcd08be03c2c4857ab84401e201633760f /Master/tlpkg | |
parent | 9065c184404fe21540ec59074d350a86593bd427 (diff) |
many changes
git-svn-id: svn://tug.org/texlive/trunk@16414 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg')
-rw-r--r-- | Master/tlpkg/dev/tlmgrgui2.pl | 955 |
1 files changed, 471 insertions, 484 deletions
diff --git a/Master/tlpkg/dev/tlmgrgui2.pl b/Master/tlpkg/dev/tlmgrgui2.pl index fcc71932255..c21882d9fab 100644 --- a/Master/tlpkg/dev/tlmgrgui2.pl +++ b/Master/tlpkg/dev/tlmgrgui2.pl @@ -28,427 +28,507 @@ use Tk::ItemStyle; use TeXLive::TLUtils qw(setup_programs platform_desc win32 debug); use TeXLive::TLConfig; +# +# stuff defined in tlmgr.pl that needs to be our-ed our $Master; our $tlmediatlpdb; our $tlmediasrc; +our $localtlmedia; our $localtlpdb; - -# defined in tlmgr.pl our $location; +our %opts; +our @update_function_list; my $tlpdb_location; my $cmdline_location; +my @critical_updates = (); # -our %opts; +# shortcuts for padding, expand/fill, and pack sides, anchors +my @p_ii = qw/-padx 2m -pady 2m/; +my @p_iii= qw/-padx 3m -pady 3m/; +my @x_x = qw/-expand 1 -fill x/; +my @x_y = qw/-expand 1 -fill y/; +my @x_xy= qw/-expand 1 -fill both/; +my @left = qw/-side left/; +my @right= qw/-side right/; +my @bot = qw/-side bottom/; +my @a_w = qw/-anchor w/; +my @a_c = qw/-anchor c/; +my @htype = qw/-relief ridge/; + # # the list of packages as shown by TixGrid # my %Packages; -our $mw; +my $mw; +my $tlmgrrev; +my $menu; +my $menu_file; +my $menu_options; +my $menu_actions; +my $menu_help; -sub update_status_box { - update_status(join(" ", @_)); - $mw->update; -} - -sub init_hooks { - push @::info_hook, \&update_status_box; - push @::warn_hook, \&update_status_box; - push @::debug_hook, \&update_status_box; - push @::ddebug_hook, \&update_status_box; - push @::dddebug_hook, \&update_status_box; -} +# +# GUI elements +# +my $g; # the scrolled list of packages +my $lighttext; +my $darktext; +my $match_entry; +my $loaded_button; -sub update_status { - my ($p) = @_; - $::progressw->insert("end", "$p"); - $::progressw->see("end"); -} +# +# communication between filters and the rest +my $status_all = 0; +my $status_only_installed = 1; +my $status_only_not_installed = 2; +my $status_only_updated = 3; +my $status_value = 0; +my $show_packages = 1; +my $show_collections = 1; +my $show_schemes = 1; +my $match_string = 0; +my $selection_value = 0; # prepare for loading of lang.pl which expects $::lang and $::opt_lang $::opt_lang = $opts{"gui-lang"} if (defined($opts{"gui-lang"})); - require("TeXLive/trans.pl"); -our @update_function_list; -$mw = MainWindow->new; -$mw->title("TeX Live Manager $TeXLive::TLConfig::ReleaseYear"); -$mw->withdraw; +my @archsavail; +my @archsinstalled; +my %archs; +my $currentarch; -# -# default layout definitions -# -# priority 20 = widgetDefault -# see Mastering Perl/Tk, 16.2. Using the Option Database -$mw->optionAdd("*Button.Relief", "ridge", 20); -# -# does not work, makes all buttons exactely 10, which is not a good idea -# I would like to have something like MinWidth 10... -#$mw->optionAdd("*Button.Width", "10", 20); -# -# shortcuts for padding, expand/fill, and pack sides, anchors -my @p_ii = qw/-padx 2m -pady 2m/; -my @p_iii= qw/-padx 3m -pady 3m/; -my @x_x = qw/-expand 1 -fill x/; -my @x_y = qw/-expand 1 -fill y/; -my @x_xy= qw/-expand 1 -fill both/; -my @left = qw/-side left/; -my @right= qw/-side right/; -my @bot = qw/-side bottom/; -my @a_w = qw/-anchor w/; -my @a_c = qw/-anchor c/; +my @fileassocdesc; +$fileassocdesc[0] = __("None"); +$fileassocdesc[1] = __("Only new"); +$fileassocdesc[2] = __("All"); +my %defaults; +my %changeddefaults; + +my %papers; +my %currentpaper; +my %changedpaper; +my %init_paper_subs; +$init_paper_subs{"xdvi"} = \&init_paper_xdvi; +$init_paper_subs{"pdftex"} = \&init_paper_pdftex; +$init_paper_subs{"dvips"} = \&init_paper_dvips; +$init_paper_subs{"context"} = \&init_paper_context; +$init_paper_subs{"dvipdfm"} = \&init_paper_dvipdfm; +$init_paper_subs{"dvipdfmx"} = \&init_paper_dvipdfmx; -# create a progress bar window -$::progressw = $mw->Scrolled("ROText", -scrollbars => "e", -height => 4); -$::progressw->pack(-fill => "x", @bot); +guimain(); +############# MAIN FUNCTION ########################## -my @critical_updates = (); +sub guimain { + build_initial_gui(); + init_hooks(); + + 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)); + + $tlpdb_location = $localtlpdb->option("location"); + if (defined($opts{"location"})) { + $cmdline_location = $opts{"location"}; + } + + + push @update_function_list, \&check_location_on_ctan; + push @update_function_list, \&init_install_media; + + setup_programs("$Master/tlpkg/installer", $localtlmedia->platform); + + # + # check that we can actually save the database + # + if (check_on_writable()) { + $::we_can_save = 1; + } else { + $::we_can_save = 0; + # here we should pop up a warning window!!! + } + $::action_button_state = ($::we_can_save ? "normal" : "disabled"); + + $tlmgrrev = give_version(); + chomp($tlmgrrev); + + setup_menu_system(); + do_rest_of_gui(); + setup_list(); + update_grid(); -init_hooks(); + if ($opts{"load"}) { + $location = $tlpdb_location; + update_loaded_location_string(); + run_update_functions(); + } -info(__("Loading local TeX Live Database\nThis may take some time, please wait!") . "\n"); -our $localtlmedia = TeXLive::TLMedia->new ( $Master ); -die("cannot setup TLMedia in $Master") unless (defined($localtlmedia)); -$localtlpdb = $localtlmedia->tlpdb; -die("cannot find tlpdb!") unless (defined($localtlpdb)); + info(__("Completed") . ".\n"); + $mw->deiconify; -our @main_list; -$tlpdb_location = $localtlpdb->option("location"); -if (defined($opts{"location"})) { - $cmdline_location = $opts{"location"}; + if (!$::we_can_save) { + my $no_write_warn = $mw->Dialog(-title => "warning", + -text => __("You don't have permissions to change the installation in any way,\nspecifically, the directory %s is not writable.\nPlease run this program as administrator, or contact your local admin.\n\nMost buttons will be disabled.", "$Master/tlpkg/"), + -buttons => [ __("Ok") ])->Show(); + } + + Tk::MainLoop(); } -push @update_function_list, \&check_location_on_ctan; -push @update_function_list, \&init_install_media; +############## GUI ######################## -setup_programs("$Master/tlpkg/installer", $localtlmedia->platform); +sub build_initial_gui { + $mw = MainWindow->new; + $mw->title("TeX Live Manager $TeXLive::TLConfig::ReleaseYear"); + $mw->withdraw; -# -# check that we can actually save the database -# -if (check_on_writable()) { - $::we_can_save = 1; -} else { - $::we_can_save = 0; - # here we should pop up a warning window!!! + # + # default layout definitions + # + # priority 20 = widgetDefault + # see Mastering Perl/Tk, 16.2. Using the Option Database + $mw->optionAdd("*Button.Relief", "ridge", 20); + # + # does not work, makes all buttons exactely 10, which is not a good idea + # I would like to have something like MinWidth 10... + #$mw->optionAdd("*Button.Width", "10", 20); + + # create a progress bar window + $::progressw = $mw->Scrolled("ROText", -scrollbars => "e", -height => 4); + $::progressw->pack(-fill => "x", @bot); } -$::action_button_state = ($::we_can_save ? "normal" : "disabled"); - -my $tlmgrrev = give_version(); -chomp($tlmgrrev); - -#our $top = $mw->Frame; - -my $menu = $mw->Menu(); -my $menu_file = $menu->Menu(); -my $menu_options = $menu->Menu(); -my $menu_actions = $menu->Menu(); -my $menu_help = $menu->Menu(); -$menu->add('cascade', -label => __("File"), -menu => $menu_file); -$menu->add('cascade', -label => __("Options"), -menu => $menu_options); -$menu->add('cascade', -label => __("Actions"), -menu => $menu_actions); -# on win32 people expect to have the Help button on the right side -if (win32()) { $menu->add('separator'); } -$menu->add('cascade', -label => __("Help"), -menu => $menu_help); -#$menu->add('separator'); -#$menu->add('command', -label => __("Loaded repository:") . __("none"), -# -command => sub { $location = $tlpdb_location; -# update_loaded_location_string(); -# run_update_functions(); -# }); -# -activebackground => $menu->cget(-background)); -# -# FILE MENU -# -$menu_file->add('command', - -label => __("Load default repository:") . " $tlpdb_location", - -command => sub { - $location = $tlpdb_location; - update_loaded_location_string(); - run_update_functions(); - }); -if (defined($cmdline_location)) { - $menu_file->add('command', -label => __("Load cmd line repository:") . " $cmdline_location", - -command => sub { - $location = $cmdline_location; +sub do_rest_of_gui { + # This needs to come first as we call update_grid rather early + #my $list_frame = $mw->Labelframe(-text => "Packages"); + my $list_frame = $mw->Frame; + $g = $list_frame->Scrolled('HList', -scrollbars => "se", -bd => 0, + -command => \&show_extended_info, # does not work, double click! + -columns => 5, -header => 1, + -borderwidth => 1, #-padx => 0, -pady => 0, + -separator => "/", + -selectmode => "none"); + + $loaded_button = $mw->Button(-text => __("Loaded repository:") . __(" none"), + -relief => 'flat', + -command => sub { $location = $tlpdb_location; update_loaded_location_string(); - run_update_functions(); + run_update_functions(); }); -} -$menu_file->add('command', -label => __("Load default net repository:") . " $TeXLiveURL", - -command => sub { - $location = $TeXLiveURL; - update_loaded_location_string(); - run_update_functions(); - }); -$menu_file->add('command', -label => __("Load other repository ..."), - -command => \&cb_edit_location); -$menu_file->add('separator'); -$menu_file->add('command', -label => __("Quit"), - -command => sub { $mw->destroy; exit(0); }); + $loaded_button->pack(-anchor => 'e', -padx => 0, -pady => 0, + -ipadx => 0, -ipady => 0); + + my $top_frame = $mw->Labelframe(-text => __("Display configuration")); + $top_frame->pack(-fill => 'x', -padx => '2m'); + + my $filter_frame = $top_frame->Frame(); + $filter_frame->pack; + + my $filter_status = $filter_frame->Labelframe(-text => __("Status")); + $filter_status->pack(@left, @p_ii); + + $filter_status->Radiobutton(-text => __("all"), -command => \&update_grid, + -variable => \$status_value, -value => $status_all)->pack(@a_w); + $filter_status->Radiobutton(-text => __("installed"), -command => \&update_grid, + -variable => \$status_value, -value => $status_only_installed)->pack(@a_w); + $filter_status->Radiobutton(-text => __("not installed"), -command => \&update_grid, + -variable => \$status_value, -value => $status_only_not_installed)->pack(@a_w); + $filter_status->Radiobutton(-text => __("updates"), -command => \&update_grid, + -variable => \$status_value, -value => $status_only_updated)->pack(@a_w); + + my $filter_category = $filter_frame->Labelframe(-text => __("Category")); + $filter_category->pack(@left, @x_y, @p_ii); + $filter_category->Checkbutton(-text => __("packages"), -command => \&update_grid, + -variable => \$show_packages)->pack(@a_w); + $filter_category->Checkbutton(-text => __("collections"), -command => \&update_grid, + -variable => \$show_collections)->pack(@a_w); + $filter_category->Checkbutton(-text => __("schemes"), -command => \&update_grid, + -variable => \$show_schemes)->pack(@a_w); + + my $filter_match = $filter_frame->Labelframe(-text => __("Match")); + $filter_match->pack(@left, @x_y, @p_ii); + $filter_match->Checkbutton(-text => __("pattern:"), + -command => \&update_grid, + -variable => \$match_string)->pack(@a_w); + $match_entry = + $filter_match->Entry(-width => 15, -validate => 'key', + )->pack(@a_w, -padx => '2m', @x_x); + + $match_entry->configure(-validate => 'key', + -validatecommand => sub { my $new_val = shift; + if (!$new_val) { + $match_string = 0; + } else { + $match_string = 1; + } + update_grid(); return 1; }); + + my $filter_selection = $filter_frame->Labelframe(-text => __("Selection")); + $filter_selection->pack(@left, @x_y, @p_ii); + $filter_selection->Radiobutton(-text => "all", -command => \&update_grid, + -variable => \$selection_value, -value => 0)->pack(@a_w); + $filter_selection->Radiobutton(-text => __("selected"), + -command => \&update_grid, -variable => \$selection_value, -value => 1) + ->pack(@a_w); + $filter_selection->Radiobutton(-text => __("not selected"), + -command => \&update_grid, -variable => \$selection_value, -value => 2) + ->pack(@a_w); + + + my $filter_button = $filter_frame->Frame; + $filter_button->pack(@left, @x_y, @p_ii); + $filter_button->Button(-text => __("Select all"), + -command => [ \&update_grid, 1 ])->pack(@x_x, @a_c); + $filter_button->Button(-text => __("Select none"), + -command => [ \&update_grid, 0 ])->pack(@x_x, @a_c); + + $filter_button->Button(-text => __("Reset filters"), + -command => sub { $status_value = $status_all; + $show_packages = 1; $show_collections = 1; + $show_schemes = 1; + $selection_value = 0; + $match_string = 0; + update_grid(); + })->pack(@x_x, @a_c); + + ########## Packages ####################### + $list_frame->pack(@x_xy, @p_ii); + $g->pack(qw/-expand 1 -fill both -padx 3 -pady 3/); + $g->focus; + + $lighttext = $g->ItemStyle('text', -background => 'gray90', + -selectbackground => 'gray90', -selectforeground => 'blue'); + $darktext = $g->ItemStyle('text', -background => 'gray70', + -selectbackground => 'gray70', -selectforeground => 'blue'); + + + $g->headerCreate(0, @htype, -itemtype => 'text', -text => ""); + $g->headerCreate(1, @htype, -itemtype => 'text', -text => __("Package name")); + $g->headerCreate(2, @htype, -itemtype => 'text', -text => __("Local rev. (ver.)")); + $g->headerCreate(3, @htype, -itemtype => 'text', -text => __("Remote rev. (ver.)")); +$g->headerCreate(4, @htype, -itemtype => 'text', -text => __("Short description")); -# -# OPTIONS MENU -# -$menu_options->add('command', -label => __("General ..."), - -command => sub { do_general_settings(); }); -$menu_options->add('command', -label => __("Paper ..."), - -command => sub { do_paper_settings(); }); -if (!win32()) { - $menu_options->add('command', -label => __("Architectures ..."), - -command => sub { do_arch_settings(); }); -} -$menu_options->add('separator'); -$menu_options->add('checkbutton', -label => __("Debug"), - -onvalue => ($::opt_verbosity == 0 ? 1 : $::opt_verbosity), - -variable => \$::opt_verbosity); + $g->columnWidth(0, 40); + $g->columnWidth(2, -char => 20); + $g->columnWidth(3, -char => 20); -# -# Actions menu -# -$menu_actions->add('command', -label => __("Update filename database"), - -state => $::action_button_state, - -command => sub { - $mw->Busy(-recurse => 1); - info("Running mktexlsr, this may take some time ...\n"); - info(`mktexlsr 2>&1`); - $mw->Unbusy; - }); -$menu_actions->add('command', -label => __("Rebuild all formats"), - -state => $::action_button_state, - -command => sub { - $mw->Busy(-recurse => 1); - info("Running fmtutil-sys --all, this may take some time ...\n"); - for my $l (`fmtutil-sys --all 2>&1`) { - info($l); - $mw->update; - } - $mw->Unbusy; - }); -$menu_actions->add('command', -label => __("Update font map database"), - -state => $::action_button_state, - -command => sub { - $mw->Busy(-recurse => 1); - info("Running updmap-sys, this may take some time ...\n"); - for my $l (`updmap-sys 2>&1`) { - info($l); - $mw->update; - } - $mw->Unbusy; - }); - -if (!win32()) { - $menu_actions->add('command', - -label => __("Handle symlinks in system dirs") . " ...", - -state => $::action_button_state, - -command => \&cb_handle_symlinks); -} -if (!win32()) { - $menu_actions->add('separator'); - $menu_actions->add('command', -label => __("Remove TeX Live %s ...", $TeXLive::TLConfig::ReleaseYear), - -state => $::action_button_state, - -command => sub { - my $sw = $mw->DialogBox(-title => __("Remove TeX Live %s", $TeXLive::TLConfig::ReleaseYear), - -buttons => [ __("Ok"), __("Cancel") ], - -cancel_button => __("Cancel"), - -command => sub { - my $b = shift; - if ($b eq __("Ok")) { - system("tlmgr", "uninstall", "--force"); - $mw->Dialog(-text => __("Complete removal completed"), -buttons => [ __("Ok") ])->Show; - $mw->destroy; - exit(0); - } - }); - $sw->add("Label", -text => __("Really remove (uninstall) the COMPLETE TeX Live %s installation?\nYour last chance to change your mind!", $TeXLive::TLConfig::ReleaseYear))->pack(@p_iii); - $sw->Show; - }); -} - + my $bot_frame = $mw->Frame; + $bot_frame->pack(-fill => 'x', @p_ii); + my $actions_frame = $bot_frame->Frame; + $actions_frame->pack(); -# -# HELP MENU -$menu_help->add('command', -label => __("About"), - -command => sub { - my $sw = $mw->DialogBox(-title => __("About"), - -buttons => [ __("Ok") ]); - $sw->add("Label", -text => "TeX Live Manager (GUIv2) -$tlmgrrev -Copyright 2009 Norbert Preining + my $with_all_frame = $actions_frame->Frame; + $with_all_frame->pack(@left, -padx => '5m'); + $with_all_frame->Button(-text => __('Update all installed'), + -state => $::action_button_state, + -command => sub { update_all_packages(); } + )->pack(@a_c,@left,@p_ii); -Licensed under the GNU General Public License version 2 or higher -In case of problems, please contact: texlive\@tug.org" - )->pack(@p_iii); - $sw->Show; - }); - + my $with_sel_frame = $actions_frame->Frame; + $with_sel_frame->pack(@left, -padx => '5m'); -$mw->configure(-menu => $menu); -our $back_f1 = $mw->Frame(); + # + # disable the with filter applied or not applied, it is too complicated, or? + # -# pack .top .back -side top -fill both -expand 1 -#$top->pack(-fill => 'x', @p_ii); -$back_f1->pack(@x_xy); + $with_sel_frame->Button(-text => __('Update'), + -state => $::action_button_state, + -command => sub { update_selected_packages(); } + )->pack(@left, @p_ii); + $with_sel_frame->Button(-text => __('Install'), + -state => $::action_button_state, + -command => sub { install_selected_packages(); } + )->pack(@left, @p_ii); + $with_sel_frame->Button(-text => __('Remove'), + -state => $::action_button_state, + -command => sub { remove_selected_packages(); } + )->pack(@left, @p_ii); + $with_sel_frame->Button(-text => __('Backup'), + -state => $::action_button_state, + -command => sub { backup_selected_packages(); } + )->pack(@left, @p_ii); +} -#require ("do_listframe.pl"); -######### SHOULD GO INTO A SEPARTE FILE ######################## -# This needs to come first as we call update_grid rather early -#my $list_frame = $back_f1->Labelframe(-text => "Packages"); -my $list_frame = $back_f1->Frame; -my $g = $list_frame->Scrolled('HList', -scrollbars => "se", -bd => 0, - -command => \&show_extended_info, # does not work, double click! - -columns => 7, -header => 1, - -borderwidth => 1, #-padx => 0, -pady => 0, - -separator => "/", - -selectmode => "none"); +########### LOGGING ETC FUNCTIONS ############# -my $loaded_button = $back_f1->Button(-text => __("Loaded repository:") . __(" none"), - -relief => 'flat', - -command => sub { $location = $tlpdb_location; - update_loaded_location_string(); - run_update_functions(); - }); -$loaded_button->pack(-anchor => 'e', -padx => 0, -pady => 0, -ipadx => 0, -ipady => 0); -# install screen -my $top_frame = $back_f1->Labelframe(-text => __("Display configuration")); -$top_frame->pack(@x_x, -padx => '2m'); +sub update_status_box { + update_status(join(" ", @_)); + $mw->update; +} -my $filter_frame = $top_frame->Frame(); -$filter_frame->pack; +sub init_hooks { + push @::info_hook, \&update_status_box; + push @::warn_hook, \&update_status_box; + push @::debug_hook, \&update_status_box; + push @::ddebug_hook, \&update_status_box; + push @::dddebug_hook, \&update_status_box; +} -my $filter_status = $filter_frame->Labelframe(-text => __("Status")); -$filter_status->pack(@left, @p_ii); +sub update_status { + my ($p) = @_; + $::progressw->insert("end", "$p"); + $::progressw->see("end"); +} -my $status_all = 0; -my $status_only_installed = 1; -my $status_only_not_installed = 2; -my $status_only_updated = 3; -my $status_value = 0; -$filter_status->Radiobutton(-text => __("all"), -command => \&update_grid, - -variable => \$status_value, -value => $status_all)->pack(@a_w); -$filter_status->Radiobutton(-text => __("installed"), -command => \&update_grid, - -variable => \$status_value, -value => $status_only_installed)->pack(@a_w); -$filter_status->Radiobutton(-text => __("not installed"), -command => \&update_grid, - -variable => \$status_value, -value => $status_only_not_installed)->pack(@a_w); -$filter_status->Radiobutton(-text => __("updates"), -command => \&update_grid, - -variable => \$status_value, -value => $status_only_updated)->pack(@a_w); - -my $filter_category = $filter_frame->Labelframe(-text => __("Category")); -$filter_category->pack(@left, @x_y, @p_ii); -my $show_packages = 1; -my $show_collections = 1; -my $show_schemes = 1; -$filter_category->Checkbutton(-text => __("packages"), -command => \&update_grid, - -variable => \$show_packages)->pack(@a_w); -$filter_category->Checkbutton(-text => __("collections"), -command => \&update_grid, - -variable => \$show_collections)->pack(@a_w); -$filter_category->Checkbutton(-text => __("schemes"), -command => \&update_grid, - -variable => \$show_schemes)->pack(@a_w); - -my $filter_match = $filter_frame->Labelframe(-text => __("Match")); -$filter_match->pack(@left, @x_y, @p_ii); -my $match_string = 0; -$filter_match->Checkbutton(-text => __("pattern:"), - -command => \&update_grid, - -variable => \$match_string)->pack(@a_w); -my $match_entry = - $filter_match->Entry(-width => 15, -validate => 'key', - )->pack(@a_w, -padx => '2m', @x_x); - -$match_entry->configure(-validate => 'key', - -validatecommand => sub { my $new_val = shift; - if (!$new_val) { - $match_string = 0; - } else { - $match_string = 1; - } - update_grid(); return 1; }); +############# GUI CALLBACKS ################## + +sub setup_menu_system { + $menu = $mw->Menu(); + $menu_file = $menu->Menu(); + $menu_options = $menu->Menu(); + $menu_actions = $menu->Menu(); + $menu_help = $menu->Menu(); + $menu->add('cascade', -label => __("File"), -menu => $menu_file); + $menu->add('cascade', -label => __("Options"), -menu => $menu_options); + $menu->add('cascade', -label => __("Actions"), -menu => $menu_actions); + # on win32 people expect to have the Help button on the right side + if (win32()) { $menu->add('separator'); } + $menu->add('cascade', -label => __("Help"), -menu => $menu_help); -my $filter_selection = $filter_frame->Labelframe(-text => __("Selection")); -$filter_selection->pack(@left, @x_y, @p_ii); -my $selection_value = 0; -$filter_selection->Radiobutton(-text => "all", -command => \&update_grid, - -variable => \$selection_value, -value => 0)->pack(@a_w); -$filter_selection->Radiobutton(-text => __("selected"), - -command => \&update_grid, -variable => \$selection_value, -value => 1) - ->pack(@a_w); -$filter_selection->Radiobutton(-text => __("not selected"), - -command => \&update_grid, -variable => \$selection_value, -value => 2) - ->pack(@a_w); - - -my $filter_button = $filter_frame->Frame; -#my $filter_button = $filter_frame->Labelframe(-text => __("Action")); -$filter_button->pack(@left, @x_y, @p_ii); -#$filter_button->Button(-text => __("Apply filters"), -# -command => sub { update_grid(); })->pack(@a_c, @p_ii); -$filter_button->Button(-text => __("Select all"), - -command => [ \&update_grid, 1 ])->pack(@x_x, @a_c); -$filter_button->Button(-text => __("Select none"), - -command => [ \&update_grid, 0 ])->pack(@x_x, @a_c); - -$filter_button->Button(-text => __("Reset filters"), - -command => sub { $status_value = $status_all; - $show_packages = 1; $show_collections = 1; - $show_schemes = 1; - $selection_value = 0; - $match_string = 0; - update_grid(); - })->pack(@x_x, @a_c); - -########## Packages ####################### -#my $list_frame = $back_f1->Labelframe(-text => __("Packages"); -$list_frame->pack(@x_xy, @p_ii); -#my $g = $list_frame->Scrolled('HList', -scrollbars => "se", -bd => 0, -# -command => \&show_extended_info, # does not work, double click! -# -columns => 7, -header => 1, -# -separator => "/", -# -selectmode => "none"); -$g->pack(qw/-expand 1 -fill both -padx 3 -pady 3/); -$g->focus; - -my $lighttext = $g->ItemStyle('text', -background => 'gray90', - -selectbackground => 'gray90', -selectforeground => 'blue'); -my $darktext = $g->ItemStyle('text', -background => 'gray70', - -selectbackground => 'gray70', -selectforeground => 'blue'); + # + # FILE MENU + # + $menu_file->add('command', + -label => __("Load default repository:") . " $tlpdb_location", + -command => sub { + $location = $tlpdb_location; + update_loaded_location_string(); + run_update_functions(); + }); + 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(); + }); + } + $menu_file->add('command', -label => __("Load default net repository:") . " $TeXLiveURL", + -command => sub { + $location = $TeXLiveURL; + update_loaded_location_string(); + run_update_functions(); + }); + $menu_file->add('command', -label => __("Load other repository ..."), + -command => \&cb_edit_location); + $menu_file->add('separator'); + $menu_file->add('command', -label => __("Quit"), + -command => sub { $mw->destroy; exit(0); }); -my @htype = qw/-relief ridge/; + # + # OPTIONS MENU + # + $menu_options->add('command', -label => __("General ..."), + -command => sub { do_general_settings(); }); + $menu_options->add('command', -label => __("Paper ..."), + -command => sub { do_paper_settings(); }); + if (!win32()) { + $menu_options->add('command', -label => __("Architectures ..."), + -command => sub { do_arch_settings(); }); + } + $menu_options->add('separator'); + $menu_options->add('checkbutton', -label => __("Debug"), + -onvalue => ($::opt_verbosity == 0 ? 1 : $::opt_verbosity), + -variable => \$::opt_verbosity); -#my $all_none; -#$all_none = $g->Checkbutton(-command => [\&update_grid, $all_none->{'Value'} ]); -#$g->headerCreate(0, @htype, -itemtype => 'window', -widget => $all_none); -#my $f = $g->Frame(); -#my $bi = $f->Button(-padx => 1, -pady => 3, -# -text => 'all', -command => [ \&update_grid, 1 ]); -#my $bii= $f->Button(-padx => 1, -pady => 3, -# -text => 'none', -command => [ \&update_grid, 0 ]); -#$bi->pack(@left); -#$bii->pack(@right); -#$g->headerCreate(0, @htype, -itemtype => 'window', -widget => $f); -$g->headerCreate(0, @htype, -itemtype => 'text', -text => ""); -$g->headerCreate(1, @htype, -itemtype => 'text', -text => __("Package name")); -$g->headerCreate(2, @htype, -itemtype => 'text', -text => __("Local rev. (ver.)")); -$g->headerCreate(3, @htype, -itemtype => 'text', -text => __("Remote rev. (ver.)")); -$g->headerCreate(4, @htype, -itemtype => 'text', -text => __("Short description")); + # + # Actions menu + # + $menu_actions->add('command', -label => __("Update filename database"), + -state => $::action_button_state, + -command => sub { + $mw->Busy(-recurse => 1); + info("Running mktexlsr, this may take some time ...\n"); + info(`mktexlsr 2>&1`); + $mw->Unbusy; + }); + $menu_actions->add('command', -label => __("Rebuild all formats"), + -state => $::action_button_state, + -command => sub { + $mw->Busy(-recurse => 1); + info("Running fmtutil-sys --all, this may take some time ...\n"); + for my $l (`fmtutil-sys --all 2>&1`) { + info($l); + $mw->update; + } + $mw->Unbusy; + }); + $menu_actions->add('command', -label => __("Update font map database"), + -state => $::action_button_state, + -command => sub { + $mw->Busy(-recurse => 1); + info("Running updmap-sys, this may take some time ...\n"); + for my $l (`updmap-sys 2>&1`) { + info($l); + $mw->update; + } + $mw->Unbusy; + }); -$g->columnWidth(0, 40); -$g->columnWidth(2, -char => 20); -$g->columnWidth(3, -char => 20); + if (!win32()) { + $menu_actions->add('command', + -label => __("Handle symlinks in system dirs") . " ...", + -state => $::action_button_state, + -command => \&cb_handle_symlinks); + } + if (!win32()) { + $menu_actions->add('separator'); + $menu_actions->add('command', -label => __("Remove TeX Live %s ...", $TeXLive::TLConfig::ReleaseYear), + -state => $::action_button_state, + -command => sub { + my $sw = $mw->DialogBox(-title => __("Remove TeX Live %s", $TeXLive::TLConfig::ReleaseYear), + -buttons => [ __("Ok"), __("Cancel") ], + -cancel_button => __("Cancel"), + -command => sub { + my $b = shift; + if ($b eq __("Ok")) { + system("tlmgr", "uninstall", "--force"); + $mw->Dialog(-text => __("Complete removal completed"), -buttons => [ __("Ok") ])->Show; + $mw->destroy; + exit(0); + } + }); + $sw->add("Label", -text => __("Really remove (uninstall) the COMPLETE TeX Live %s installation?\nYour last chance to change your mind!", $TeXLive::TLConfig::ReleaseYear))->pack(@p_iii); + $sw->Show; + }); + } + + + + # + # HELP MENU + $menu_help->add('command', -label => __("About"), + -command => sub { + my $sw = $mw->DialogBox(-title => __("About"), + -buttons => [ __("Ok") ]); + $sw->add("Label", -text => "TeX Live Manager (GUIv2) +$tlmgrrev +Copyright 2009 Norbert Preining -setup_list(); -update_grid(); +Licensed under the GNU General Public License version 2 or higher +In case of problems, please contact: texlive\@tug.org" + )->pack(@p_iii); + $sw->Show; + }); + + + $mw->configure(-menu => $menu); +} sub show_extended_info { my $p = shift; @@ -511,24 +591,28 @@ sub show_extended_info { } $tf->Label(-text => __("Warning: Catalogue versions might be lagging behind or be simply wrong."))->grid(-stick => "nw", -columnspan => 2); - our @further_a = (); - our @further_b = (); + our %further_a; + our %further_b; + + @{$further_a{$p}} = (); + @{$further_b{$p}} = (); sub add_filelist_text { + my $p = shift; my $text = shift; my @files = @_; if (@files) { my $t = ""; for my $f (@files) { $t .= "$f\n"; } $t =~ s/\n$//; - push @further_a, $tf->Label(-text => $text); + push @{$further_a{$p}}, $tf->Label(-text => $text); if ($#files >= 4) { my $foo = $tf->Scrolled('ROText', -scrollbars => "oe", -height => 5, -width => 50, -wrap => 'word', -relief => 'flat'); $foo->insert("1.0", $t); - push @further_b, $foo; + push @{$further_b{$p}}, $foo; } else { - push @further_b, + push @{$further_b{$p}}, $tf->Label(-wraplength => '500', -justify => 'left', -text => $t); } } @@ -543,16 +627,16 @@ sub show_extended_info { push @deps, $d; } } - add_filelist_text(__("Depends:"), @deps); + add_filelist_text($p, __("Depends:"), @deps); if ($do_arch) { my @archs = $localtlpdb->available_architectures; @arch_deps = map { "$p.$_"; } @archs; - push @further_a, $tf->Label(-text => __("Binaries' dependencies:")); - push @further_b, $tf->Label(-text => join('\n',@arch_deps)); + push @{$further_a{$p}}, $tf->Label(-text => __("Binaries' dependencies:")); + push @{$further_b{$p}}, $tf->Label(-text => join('\n',@arch_deps)); } - add_filelist_text(__("Runfiles:"), $tlp->runfiles); - add_filelist_text(__("Docfiles:"), $tlp->docfiles); - add_filelist_text(__("Srcfiles:"), $tlp->srcfiles); + add_filelist_text($p, __("Runfiles:"), $tlp->runfiles); + add_filelist_text($p, __("Docfiles:"), $tlp->docfiles); + add_filelist_text($p, __("Srcfiles:"), $tlp->srcfiles); my @binf = $tlp->allbinfiles; if ($do_arch) { for my $bp (@arch_deps) { @@ -564,7 +648,7 @@ sub show_extended_info { } } } - add_filelist_text(__("Binfiles:"), @binf); + add_filelist_text($p, __("Binfiles:"), @binf); my $f = $tf->Frame; my $fb = $f->Button(-padx => 0, -pady => 0, @@ -578,20 +662,20 @@ sub show_extended_info { sub { $showdetails = not($showdetails); if ($showdetails) { - for my $i (0..$#further_a) { - $further_a[$i]->grid($further_b[$i], -sticky => "nw"); + for my $i (0..$#{$further_a{$p}}) { + ${$further_a{$p}}[$i]->grid(${$further_b{$p}}[$i], -sticky => "nw"); } } else { - for my $i (0..$#further_a) { - $further_a[$i]->gridForget($further_b[$i]); + for my $i (0..$#{$further_a{$p}}) { + ${$further_a{$p}}[$i]->gridForget(${$further_b{$p}}[$i]); } } }); $bf->Button(-text => __("Ok"), -width => 10, - -command => sub { for (@further_a) { $_->destroy; }; - for (@further_b) { $_->destroy; }; + -command => sub { for (@{$further_a{$p}}) { $_->destroy; }; + for (@{$further_b{$p}}) { $_->destroy; }; $sw->destroy; })->pack; } @@ -718,66 +802,7 @@ sub MatchesFilters { return 1; } - -####### actions frame - -#my $bot_frame = $back_f1->Labelframe(-text => "Actions"); -my $bot_frame = $back_f1->Frame; -$bot_frame->pack(@x_x, @p_ii); - -my $actions_frame = $bot_frame->Frame; -$actions_frame->pack(); - -#my $with_all_frame = $actions_frame->Labelframe(-text => __("with all")); -my $with_all_frame = $actions_frame->Frame; -$with_all_frame->pack(@left, -padx => '5m'); -$with_all_frame->Button(-text => __('Update all installed'), - -state => $::action_button_state, - -command => sub { update_all_packages(); } - )->pack(@a_c,@left,@p_ii); - -#my $with_sel_frame = $actions_frame->Labelframe(-text => __("with selected")); -my $with_sel_frame = $actions_frame->Frame; -$with_sel_frame->pack(@left, -padx => '5m'); - - -# -# disable the with filter applied or not applied, it is too complicated, or? -# -# THIS VARIABLE HAS TO BE KEPT == 1 because the apply action checks -# for that value!!! -my $action_apply_filter = 1; -#$with_sel_frame->Label(-text => "with filters")->pack(@left, @p_ii); -# -#$with_sel_frame->Radiobutton(-text => "applied", -# -variable => \$action_apply_filter, -value => 1)->pack(@left, @p_ii); -#$with_sel_frame->Radiobutton(-text => "not applied", -# -variable => \$action_apply_filter, -value => 0)->pack(@left, @p_ii); -# - -$with_sel_frame->Button(-text => __('Update'), - -state => $::action_button_state, - -command => sub { update_selected_packages(); } - )->pack(@left, @p_ii); -$with_sel_frame->Button(-text => __('Install'), - -state => $::action_button_state, - -command => sub { install_selected_packages(); } - )->pack(@left, @p_ii); -$with_sel_frame->Button(-text => __('Remove'), - -state => $::action_button_state, - -command => sub { remove_selected_packages(); } - )->pack(@left, @p_ii); -$with_sel_frame->Button(-text => __('Backup'), - -state => $::action_button_state, - -command => sub { backup_selected_packages(); } - )->pack(@left, @p_ii); - -######################## ARCH ########################### - -my @archsavail; -my @archsinstalled; -my %archs; -my $currentarch; +############# ARCH HANDLING ##################### sub init_archs { if (!defined($tlmediatlpdb)) { @@ -857,14 +882,8 @@ sub apply_arch_changes { } } -########## CONFIG ################### -# -my @fileassocdesc; -$fileassocdesc[0] = __("None"); -$fileassocdesc[1] = __("Only new"); -$fileassocdesc[2] = __("All"); -my %defaults; -my %changeddefaults; + +######### CONFIG HANDLING ############# sub init_defaults_setting { for my $key (keys %TeXLive::TLConfig::TLPDBOptions) { @@ -1043,10 +1062,9 @@ sub apply_settings_changes { $localtlpdb->save; } -######## PAPER ######### -my %papers; -my %currentpaper; -my %changedpaper; + + +########## PAPER HANDLING ################# sub init_paper_xdvi { if (!win32()) { @@ -1077,13 +1095,6 @@ sub init_paper_dvipdfmx { $currentpaper{"dvipdfmx"} = ${$papers{"dvipdfmx"}}[0]; } -my %init_paper_subs; -$init_paper_subs{"xdvi"} = \&init_paper_xdvi; -$init_paper_subs{"pdftex"} = \&init_paper_pdftex; -$init_paper_subs{"dvips"} = \&init_paper_dvips; -$init_paper_subs{"context"} = \&init_paper_context; -$init_paper_subs{"dvipdfm"} = \&init_paper_dvipdfm; -$init_paper_subs{"dvipdfmx"} = \&init_paper_dvipdfmx; sub init_all_papers { for my $p (keys %init_paper_subs) { @@ -1305,28 +1316,8 @@ sub select_file_assocs { } - -################ END FUNCTIONS - -if ($opts{"load"}) { - $location = $tlpdb_location; - update_loaded_location_string(); - run_update_functions(); -} - - -info(__("Completed") . ".\n"); -$mw->deiconify; - - -if (!$::we_can_save) { - my $no_write_warn = $mw->Dialog(-title => "warning", - -text => __("You don't have permissions to change the installation in any way,\nspecifically, the directory %s is not writable.\nPlease run this program as administrator, or contact your local admin.\n\nMost buttons will be disabled.", "$Master/tlpkg/"), - -buttons => [ __("Ok") ])->Show(); -} - -Tk::MainLoop(); - + +############################ sub init_install_media { my $newroot = $location; @@ -1388,11 +1379,7 @@ sub SelectedPackages { # first select those that are for my $p (keys %Packages) { next if !$Packages{$p}{'selected'}; - if ($action_apply_filter) { - if (MatchesFilters($p)) { - push @ret, $p; - } - } else { + if (MatchesFilters($p)) { push @ret, $p; } } |