summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2009-12-06 10:06:07 +0000
committerNorbert Preining <preining@logic.at>2009-12-06 10:06:07 +0000
commit29608ac64d869c47f1a710c6a894d51005f6e6dd (patch)
treeb7ce5661ef47145bc06705cacfc0eb9cdbb4d804 /Master
parent3e7c149cb710de5da9770873df4c1be5301c3791 (diff)
fixing tlmgrgui2
git-svn-id: svn://tug.org/texlive/trunk@16312 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/tlpkg/dev/tlmgrgui2.pl316
1 files changed, 178 insertions, 138 deletions
diff --git a/Master/tlpkg/dev/tlmgrgui2.pl b/Master/tlpkg/dev/tlmgrgui2.pl
index 237325654c5..f666ca22f50 100644
--- a/Master/tlpkg/dev/tlmgrgui2.pl
+++ b/Master/tlpkg/dev/tlmgrgui2.pl
@@ -10,15 +10,10 @@
#
# TODO: move the check for critical updates from old create_update_list
# to here!!
-# TODO: center checkbuttons vertically
-# TODO: double click on one line should pop up a window with tlmgr show info
-# TODO: if repo is changed on Options->General, the File->Load default shoul
-# change, too
+# TODO: details window for a package should have a "Details" button
+# to show the list of files etc (like --list on tlmgr cmd line)
# TODO: warning window from execute_action_gui if something failed, and also
# from some other commands that have been run
-# TODO: remove the "all <-> matching" and activate it as soon as the
-# match string is not empty.
-# TODO: should we allow the "with filter [] applied [] not applied" thing?
$^W = 1;
use strict;
@@ -27,8 +22,9 @@ use Tk;
use Tk::Dialog;
use Tk::BrowseEntry;
use Tk::ROText;
-use Tk::TixGrid;
-use TeXLive::Splashscreen;
+use Tk::HList;
+use Tk::ItemStyle;
+#use TeXLive::Splashscreen;
use TeXLive::TLUtils qw(setup_programs platform_desc win32 debug);
use TeXLive::TLConfig;
@@ -134,6 +130,8 @@ if (defined($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
#
@@ -170,7 +168,8 @@ $menu->add('command', -label => "Loaded repository: none",
#
# FILE MENU
#
-$menu_file->add('command', -label => "Load default repository: $tlpdb_location",
+$menu_file->add('command',
+ -label => __("Load default repository:") . " $tlpdb_location",
-command => sub {
$location = $tlpdb_location;
update_loaded_location_string();
@@ -314,6 +313,14 @@ $back_f1->pack(@x_xy);
#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 $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");
+
# install screen
my $top_frame = $back_f1->Labelframe(-text => "Display configuration");
$top_frame->pack(@x_x, @p_ii);
@@ -329,13 +336,13 @@ 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",
+$filter_status->Radiobutton(-text => "all", -command => \&update_grid,
-variable => \$status_value, -value => $status_all)->pack(@a_w);
-$filter_status->Radiobutton(-text => "only installed",
+$filter_status->Radiobutton(-text => "only installed", -command => \&update_grid,
-variable => \$status_value, -value => $status_only_installed)->pack(@a_w);
-$filter_status->Radiobutton(-text => "only uninstalled",
+$filter_status->Radiobutton(-text => "only uninstalled", -command => \&update_grid,
-variable => \$status_value, -value => $status_only_not_installed)->pack(@a_w);
-$filter_status->Radiobutton(-text => "only updated",
+$filter_status->Radiobutton(-text => "only updated", -command => \&update_grid,
-variable => \$status_value, -value => $status_only_updated)->pack(@a_w);
my $filter_category = $filter_frame->Labelframe(-text => "Category");
@@ -343,38 +350,42 @@ $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",
+$filter_category->Checkbutton(-text => "packages", -command => \&update_grid,
-variable => \$show_packages)->pack(@a_w);
-$filter_category->Checkbutton(-text => "collections",
+$filter_category->Checkbutton(-text => "collections", -command => \&update_grid,
-variable => \$show_collections)->pack(@a_w);
-$filter_category->Checkbutton(-text => "schemes",
+$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_all = 1;
-$filter_match->Radiobutton(-text => "all",
+$filter_match->Radiobutton(-text => "all", -command => \&update_grid,
-variable => \$match_all, -value => 1)->pack(@a_w);
$filter_match->Radiobutton(-text => "matching:",
-variable => \$match_all, -value => 0)->pack(@a_w);
my $match_entry =
- $filter_match->Entry(-width => 15)->pack(@a_w, -padx => '2m', @x_x);
+ $filter_match->Entry(-width => 15, -validate => 'key',
+ )->pack(@a_w, -padx => '2m', @x_x);
+
+$match_entry->configure(-validate => 'key',
+ -validatecommand => sub { $match_all = 0; update_grid(); return 1; });
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",
+$filter_selection->Radiobutton(-text => "all", -command => \&update_grid,
-variable => \$selection_value, -value => 0)->pack(@a_w);
-$filter_selection->Radiobutton(-text => "only selected",
+$filter_selection->Radiobutton(-text => "only selected", -command => \&update_grid,
-variable => \$selection_value, -value => 1)->pack(@a_w);
-$filter_selection->Radiobutton(-text => "only not selected",
+$filter_selection->Radiobutton(-text => "only not selected", -command => \&update_grid,
-variable => \$selection_value, -value => 2)->pack(@a_w);
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 => "Apply filters",
+# -command => sub { update_grid(); })->pack(@a_c, @p_ii);
$filter_button->Button(-text => "Reset filters",
-command => sub { $status_value = $status_all;
$show_packages = 1; $show_collections = 1;
@@ -382,46 +393,98 @@ $filter_button->Button(-text => "Reset filters",
$selection_value = 0;
$match_all = 1;
update_grid();
- })->pack(@a_c, @p_ii);
+ })->pack(@left, @a_c, @p_ii);
########## Packages #######################
-my $list_frame = $back_f1->Labelframe(-text => "Packages");
+#my $list_frame = $back_f1->Labelframe(-text => "Packages");
$list_frame->pack(@x_xy, @p_ii);
-my $g = $list_frame->Scrolled('TixGrid', -scrollbars => "se", -bd => 0,
- -floatingrows => 0, -floatingcols => 0,
- -leftmargin => 2, # selection and label
- -topmargin => 1, # top labels
- -command => \&show_extended_info, # does not work, double click!
- -selectmode => "none",
- -selectunit => "row");
-
-# that does not work, I have no idea what has to be done
-#$g->ItemStyle('window', -anchor => "c");
-
+#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->configure(-formatcmd=>[\&AlternatingLineColoring, $g]);
-$g->size(qw/col 4 -size 10char/);
-$g->size(qw/col 5 -size 10char/);
-$g->size(qw/col default -size auto/);
-$g->size(qw/row default -size 1.1char -pad0 3/);
+
+my $lighttext = $g->ItemStyle('text', -background => 'gray90',
+ -selectbackground => 'gray90', -selectforeground => 'blue');
+my $darktext = $g->ItemStyle('text', -background => 'gray70',
+ -selectbackground => 'gray70', -selectforeground => 'blue');
+
+my $f = $g->Frame();
+my $bi = $f->Button(-padx => 1, -pady => 3,
+ -text => 'all', -command => \&grid_select_all_shown);
+my $bii= $f->Button(-padx => 1, -pady => 3,
+ -text => 'none', -command => \&grid_deselect_all_shown);
+$bi->pack(@left);
+$bii->pack(@right);
+my @htype = qw/-relief ridge/;
+$g->headerCreate(0, @htype, -itemtype => 'window', -widget => $f);
+$g->headerCreate(1, @htype, -itemtype => 'text', -text => "Package");
+$g->headerCreate(2, @htype, -itemtype => 'text', -text => "Local\nRevision");
+$g->headerCreate(3, @htype, -itemtype => 'text', -text => "Remote\nRevision");
+$g->headerCreate(4, @htype, -itemtype => 'text', -text => "Local\nVersion");
+$g->headerCreate(5, @htype, -itemtype => 'text', -text => "Remote\nVersion");
+$g->headerCreate(6, @htype, -itemtype => 'text', -text => "Short Desc");
+
+$g->columnWidth(4, -char => 10);
+$g->columnWidth(5, -char => 10);
setup_list();
update_grid();
sub show_extended_info {
- my ($x, $y) = @_;
- print "double click on $x - $y\n";
+ my $p = shift;
+ $g->selectionClear;
+ $g->anchorClear;
+ my $sw = $mw->Toplevel(-title => __("Details on:") . $p);
+ $sw->transient($mw);
+
+ $sw->Label(-text => "Package:")->grid(
+ $sw->Label(-text => $p), -sticky => "nw");
+ $sw->Label(-text => "Category:")->grid(
+ $sw->Label(-text => $Packages{$p}{'tlp'}->category),
+ -sticky => "nw");
+ $sw->Label(-text => "Short Desc:")->grid(
+ $sw->Label(-wraplength => '500', -justify => 'left',
+ -text => $Packages{$p}{'tlp'}->shortdesc),
+ -sticky => "nw");
+ # old version with ROText
+ #my $t = $sw->Scrolled('ROText', -scrollbars => "oe", -height => 10,
+ # -width => 50, -wrap => 'word', -relief => 'flat');
+ #$t->insert("1.0", $Packages{$p}{'tlp'}->longdesc);
+ #$sw->Label(-text => "Long Desc:")->grid($t, -sticky => 'nw');
+ $sw->Label(-text => "Long Desc:")->grid(
+ $sw->Label(-wraplength => '500', -justify => 'left',
+ -text => $Packages{$p}{'tlp'}->longdesc),
+ -sticky => "nw");
+ $sw->Label(-text => "Installed:")->grid(
+ $sw->Label(-text => ($Packages{$p}{'installed'} ? "Yes" : "No")),
+ -sticky => "nw");
+ $sw->Label(-text => "Local Revision:")->grid(
+ $sw->Label(-text => $Packages{$p}{'localrevision'}),
+ -sticky => "nw");
+ $sw->Label(-text => "Remote Revision:")->grid(
+ $sw->Label(-text => $Packages{$p}{'remoterevision'}),
+ -sticky => "nw");
+
+ $sw->Button(-text => __("Ok"), -width => 10,
+ -command => sub { $sw->destroy; })->grid(-columnspan => 2);
+}
+
+sub grid_select_all_shown {
+ update_grid(1);
+}
+
+sub grid_deselect_all_shown {
+ update_grid(2);
}
sub update_grid {
- # fill the header
- #$g->set(0,0, -itemtype => 'window', -widget => $g->Checkbutton());
- $g->set(1,0, -itemtype => 'text', -text => "Package");
- $g->set(2,0, -itemtype => 'text', -text => "Local Rev");
- $g->set(3,0, -itemtype => 'text', -text => "Remote Rev");
- $g->set(4,0, -itemtype => 'text', -text => "Local Ver");
- $g->set(5,0, -itemtype => 'text', -text => "Remote Ver");
- $g->set(6,0, -itemtype => 'text', -text => "Short Desc");
+ # select code
+ # if not given just do nothing
+ # if == 1 select all packages that will be shown
+ # if == 2 deselect all packages that will be shown
+ my $selectcode = shift;
my @schemes;
my @colls;
@@ -435,45 +498,39 @@ sub update_grid {
push @packs, $p;
}
}
- my $i = 1;
- # the number of current lines:
- my (undef, $curlines) = $g->index(0, 'max');
+ $g->delete('all');
+ my $i = 0;
for my $p (@schemes, @colls, @packs) {
if (MatchesFilters($p)) {
- # unset first so that the checkbutton is unmapped, otherwise crashes
- $g->unset(0,$i) if $g->infoExists(0,$i);
- $g->set(0,$i, -itemtype => 'window',
- -widget => $Packages{$p}{'cb'});
- #
- $g->set(1,$i, -itemtype => 'text', -text => $Packages{$p}{'displayname'});
- if (defined($Packages{$p}{'localrevision'})) {
- $g->set(2,$i, -itemtype => 'text', -text => $Packages{$p}{'localrevision'});
- } else {
- $g->unset(2,$i);
- }
- if (defined($Packages{$p}{'remoterevision'})) {
- $g->set(3,$i, -itemtype => 'text', -text => $Packages{$p}{'remoterevision'})
- } else {
- $g->unset(3,$i);
- }
- if (defined($Packages{$p}{'localcatalogueversion'})) {
- $g->set(4,$i, -itemtype => 'text', -text => $Packages{$p}{'localcatalogueversion'})
- } else {
- $g->unset(4,$i);
- }
- if (defined($Packages{$p}{'remotecatalogueversion'})) {
- $g->set(5,$i, -itemtype => 'text', -text => $Packages{$p}{'remotecatalogueversion'})
- } else {
- $g->unset(5,$i);
+ if (defined($selectcode)) {
+ if ($selectcode == 1) {
+ $Packages{$p}{'selected'} = 1;
+ } elsif ($selectcode == 2) {
+ $Packages{$p}{'selected'} = 0;
+ } else {
+ tlwarn("selectcode $selectcode not known, strange.\n");
+ }
}
- $g->set(6,$i, -itemtype => 'text', -text => $Packages{$p}{'shortdesc'});
+ $g->add($p);
+ my $st = ($i%2 ? $lighttext : $darktext);
+ $g->itemCreate($p, 0, -itemtype => 'window',
+ -widget => $Packages{$p}{'cb'});
+ $Packages{$p}{'cb'}->configure(-background => ($i%2?'gray90':'gray70'));
+ $g->itemCreate($p, 1, -itemtype => 'text', -style => $st,
+ -text => $Packages{$p}{'displayname'});
+ $g->itemCreate($p, 2, -itemtype => 'text', -style => $st,
+ -text => ($Packages{$p}{'localrevision'} || ''));
+ $g->itemCreate($p, 3, -itemtype => 'text', -style => $st,
+ -text => ($Packages{$p}{'remoterevision'} || ''));
+ $g->itemCreate($p, 4, -itemtype => 'text', -style => $st,
+ -text => ($Packages{$p}{'localcatalogueversion'} || ''));
+ $g->itemCreate($p, 5, -itemtype => 'text', -style => $st,
+ -text => ($Packages{$p}{'remotecatalogueversion'} || ''));
+ $g->itemCreate($p, 6, -itemtype => 'text', -style => $st,
+ -text => $Packages{$p}{'tlp'}->shortdesc);
$i++;
}
}
- if ($i <= $curlines) {
- # remove the rest of the lines
- $g->deleteRow($i, $curlines);
- }
}
sub MatchesFilters {
@@ -506,9 +563,9 @@ sub MatchesFilters {
if (!$match_all) {
my $r = $match_entry->get;
# check for match on string
- my $t = $Packages{$p}{'shortdesc'};
+ my $t = $Packages{$p}{'tlp'}->shortdesc;
$t |= "";
- my $lt = $Packages{$p}{'longdesc'};
+ my $lt = $Packages{$p}{'tlp'}->longdesc;
$lt |= "";
if (($p =~ m/$r/) || ($t =~ m/$r/) || ($lt =~ m/$r/)) {
# do nothing, more checks have to be done
@@ -540,40 +597,6 @@ sub MatchesFilters {
}
-sub AlternatingLineColoring {
- my ($w, $area, @entbox) = @_;
- if ($area eq 'main') {
- # first format all cells
- # no select background -selectbackground => 'lightblue',
- $w->formatGrid( @entbox, -selectbackground => 'gray70',
- -xon => 1, -xoff => 0, -yon => 1, -yoff => 0,
- -relief => 'raised', -bd => 0, -filled => 1, -bg => 'gray70');
- # format odd lines 1,3,5,7, ... (counting starts at 0!!!)
- $w->formatGrid( @entbox, -selectbackground => 'gray90',
- -xon => 1, -xoff => 0, -yon => 1, -yoff => 1,
- -relief => 'raised', -bd => 0, -filled => 1, -bg => 'gray90');
- }
- if ($area eq 'y_margin') {
- my ($ulx, $uly, $lrx, $lry) = @entbox;
- # format the checkbuttons backgrounds
- for my $i ($uly..$lry) {
- if ($w->infoExists(0,$i)) {
- my $cb = $w->entrycget(0, $i, "-window");
- $cb->configure(-background => (($i-$uly)%2 ? 'gray70' : 'gray90'));
- }
- }
- # first format all cells
- # no select background -selectbackground => 'lightblue',
- $w->formatBorder( @entbox, -selectbackground => 'gray70',
- -xon => 1, -xoff => 0, -yon => 1, -yoff => 0,
- -relief => 'raised', -bd => 0, -filled => 1, -bg => 'gray70');
- # format odd lines 1,3,5,7, ... (counting starts at 0!!!)
- $w->formatBorder( @entbox, -selectbackground => 'gray90',
- -xon => 1, -xoff => 0, -yon => 1, -yoff => 1,
- -relief => 'raised', -bd => 0, -filled => 1, -bg => 'gray90');
- }
-}
-
####### actions frame
my $bot_frame = $back_f1->Labelframe(-text => "Actions");
@@ -584,13 +607,22 @@ $actions_frame->pack();
my $with_sel_frame = $actions_frame->Labelframe(-text => "with selected");
$with_sel_frame->pack(@left, @p_ii);
+
+
+#
+# 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->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->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 => 'Install',
-state => $::action_button_state,
-command => sub { install_selected_packages(); }
@@ -895,6 +927,13 @@ sub apply_settings_changes {
for my $k (keys %defaults) {
if ($defaults{$k} ne $changeddefaults{$k}{'value'}) {
$localtlpdb->option($k, $changeddefaults{$k}{'value'});
+ if ($k eq "location") {
+ # 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");
+ }
}
}
$localtlpdb->save;
@@ -997,6 +1036,9 @@ sub do_paper_settings {
}
+#
+# this function is used to edit/change the default tlpdb repository
+# we also want to change the menu entry if we change that
sub menu_default_location {
my $mw = shift;
my $val;
@@ -1028,10 +1070,12 @@ sub menu_default_location {
my $f = $sw->Frame;
my $okbutton = $f->Button(-text => __("Ok"),
- -command => sub { $changeddefaults{'location'}{'value'} =
- $changeddefaults{'location'}{'display'} =
- $entry->get;
- $sw->destroy })->pack(-side => 'left',-padx => "2m", -pady => "2m");
+ -command =>
+ sub {
+ $changeddefaults{'location'}{'value'} =
+ $changeddefaults{'location'}{'display'} = $entry->get;
+ $sw->destroy;
+ })->pack(-side => 'left',-padx => "2m", -pady => "2m");
my $cancelbutton = $f->Button(-text => __("Cancel"),
-command => sub { $sw->destroy })->pack(-side => 'right',-padx => "2m", -pady => "2m");
$f->pack(-expand => 'x');
@@ -1345,10 +1389,9 @@ sub setup_list {
# collect information about that package we will show
$Packages{$p}{'displayname'} = $p;
$Packages{$p}{'localrevision'} = $tlp->revision;
- $Packages{$p}{'shortdesc'} = $tlp->shortdesc;
- $Packages{$p}{'longdesc' } = $tlp->longdesc;
$Packages{$p}{'installed'} = 1;
$Packages{$p}{'selected'} = 0;
+ $Packages{$p}{'tlp'} = $tlp;
$Packages{$p}{'cb'} = $g->Checkbutton(-variable => \$Packages{$p}{'selected'});
if (($tlp->category eq "Collection") ||
($tlp->category eq "Scheme")) {
@@ -1368,10 +1411,9 @@ sub setup_list {
# collect information about that package we will show
$Packages{$p}{'displayname'} = $p;
$Packages{$p}{'localrevision'} = $tlp->revision;
- $Packages{$p}{'shortdesc'} = $tlp->shortdesc;
- $Packages{$p}{'longdesc' } = $tlp->longdesc;
$Packages{$p}{'installed'} = 1;
$Packages{$p}{'selected'} = 0;
+ $Packages{$p}{'tlp'} = $tlp;
$Packages{$p}{'cb'} = $g->Checkbutton(-variable => \$Packages{$p}{'selected'});
if (($tlp->category eq "Collection") ||
($tlp->category eq "Scheme")) {
@@ -1409,8 +1451,7 @@ sub update_list_remote {
$Packages{$p}{'displayname'} = $p;
$Packages{$p}{'remoterevision'} = $tlp->revision;
# overwrite, we assume that the remove version is better ;-)
- $Packages{$p}{'shortdesc'} = $tlp->shortdesc;
- $Packages{$p}{'longdesc' } = $tlp->longdesc;
+ $Packages{$p}{'tlp'} = $tlp;
$Packages{$p}{'selected'} = 0
unless defined $Packages{$p}{'selected'};
$Packages{$p}{'cb'} = $g->Checkbutton(-variable => \$Packages{$p}{'selected'})
@@ -1434,8 +1475,7 @@ sub update_list_remote {
# collect information about that package we will show
$Packages{$p}{'displayname'} = $p;
$Packages{$p}{'remoterevision'} = $tlp->revision;
- $Packages{$p}{'shortdesc'} = $tlp->shortdesc;
- $Packages{$p}{'longdesc' } = $tlp->longdesc;
+ $Packages{$p}{'tlp'} = $tlp;
$Packages{$p}{'selected'} = 0
unless defined $Packages{$p}{'selected'};
$Packages{$p}{'cb'} = $g->Checkbutton(-variable => \$Packages{$p}{'selected'})