[tex-live] Patch to make gui installer usable from keyboard

Alexander Cherepanov cherepan at mccme.ru
Sun Oct 11 00:44:41 CEST 2009


Hi all!

Please consider the attached patch to gui installer. It makes 
installer (both wizard and perltk) usable from keyboard. Mainly calls 
to focus() are added but there is a couple of button swaps to fix tab 
order. And a fix to counter at the last screen in wizard as a bonus:-)

diff -ur installer.orig/install-menu-perltk.pl installer/install-menu-perltk.pl
--- installer.orig/install-menu-perltk.pl	2009-10-10 15:55:28.750000000 +0400
+++ installer/install-menu-perltk.pl	2009-10-10 22:11:37.531250000 +0400
@@ -313,7 +313,7 @@
   $f3->Button(
     -text    => __("Install TeX Live"),
     -command => sub { installation_window(); }
-  )->pack(-side => 'left', -padx => "2m", -pady => "2m");
+  )->pack(-side => 'left', -padx => "2m", -pady => "2m")->focus();
   my $quitbutton = $f3->Button(
     -text    => __("Quit"),
     -command => sub { $return = $MENU_ABORT; $mainwindow->destroy }
@@ -367,7 +367,7 @@
   my $b = $f->Button(-text => __("Cancel"),
                      -command => sub { $::sww->destroy; $mainwindow->destroy;
                                        do_cleanup(); exit(1); }
-                    )->pack(-pady => "2m");
+                    )->pack(-pady => "2m")->focus();
   $f->pack;
   do_installation();
   $return = $MENU_ALREADYDONE;
@@ -468,7 +468,7 @@
   }
   $sw->Label(-text => __("Enter path for %s (use ~ for %s)", $key, $hint_var))->pack(-padx => "2m", -pady => "2m");
   my $entry = $sw->Entry(-textvariable => $val, -width => 60);
-  $entry->pack(-padx => "2m", -pady => "2m");
+  $entry->pack(-padx => "2m", -pady => "2m")->focus();
   my $f = $sw->Frame;
   my $okbutton = $f->Button(-text => __("Ok"),
      -command => sub { $val = $entry->get; callback_edit_directories($key,$val) ; $sw->destroy })->pack(-side => 'left', -padx => "2m", -pady => "2m");
@@ -493,7 +493,7 @@
     $opt->insert("end", $::fileassocdesc[$i]);
   }
 
-  $opt->pack(-padx => "2m", -pady => "2m");
+  $opt->pack(-padx => "2m", -pady => "2m")->focus();
   my $f = $sw->Frame;
   my $okbutton = $f->Button(-text => __("Ok"),
     -command => sub { 
@@ -539,13 +539,17 @@
   my $i = 0;
   foreach my $scheme (@schemes) {
     my $tlpobj = $tlpdb->get_package("$scheme");
+    my $b;
     if ($i < $nrfh) {
-      $f2l->Radiobutton(-variable => \$selected, -value => $scheme,
+      $b = $f2l->Radiobutton(-variable => \$selected, -value => $scheme,
         -text => $tlpobj->shortdesc)->pack(-anchor => 'w');
     } else {
-      $f2r->Radiobutton(-variable => \$selected, -value => $scheme,
+      $b = $f2r->Radiobutton(-variable => \$selected, -value => $scheme,
         -text => $tlpobj->shortdesc)->pack(-anchor => 'w');
     }
+    if ($selected eq $scheme) {
+      $b->focus();
+    }
     $i++;
   }
   $f2l->pack(-side => 'left', -padx => "2m", -pady => "2m");
@@ -586,15 +590,15 @@
   $f1->pack(-side => 'left', -padx => "2m", -pady => "2m");
   $f2->pack(-side => 'right', -padx => "2m", -pady => "2m");
   $fb->pack(-padx => "2m", -pady => "2m");
-  $fd->pack();
-  $fd->Button(-text => __("Select All"),
-    -command => sub { select_collections(\%lvars, @collections_std) })->pack(-side => 'left', -padx => "2m", -pady => "2m");
-  $fd->Button(-text => __("Deselect All"),
+  $fc->pack();
+  $fc->Button(-text => __("Select All"),
+    -command => sub { select_collections(\%lvars, @collections_std) })->pack(-side => 'left', -padx => "2m", -pady => "2m")->focus();
+  $fc->Button(-text => __("Deselect All"),
     -command => sub { deselect_collections(\%lvars, @collections_std) })->pack(-side => 'right', -padx => "2m", -pady => "2m");
-  $fc->pack(-expand => 'x', -padx => "2m", -pady => "2m");
-  my $okbutton = $fc->Button(-text => __("Ok"),
+  $fd->pack(-expand => 'x', -padx => "2m", -pady => "2m");
+  my $okbutton = $fd->Button(-text => __("Ok"),
      -command => sub { %vars = %lvars; callback_select_collection() ; $sw->destroy })->pack(-side => 'left', -padx => "2m", -pady => "2m");
-  my $cancelbutton = $fc->Button(-text => __("Cancel"),
+  my $cancelbutton = $fd->Button(-text => __("Cancel"),
      -command => sub { $sw->destroy })->pack(-side => 'right', -padx => "2m", -pady => "2m");
   $sw->bind('<Return>' => [ $okbutton, 'Invoke']);
   $sw->bind('<Escape>' => [ $cancelbutton, 'Invoke']);
@@ -629,7 +633,7 @@
   my $f1langB = $f1lang->Frame;
   $f1langB->pack(-expand => 'x');
   $f1langB->Button(-text => __("Select All"),
-    -command => sub { select_collections(\%lvars, @collections_lang) })->pack(-side => 'left', -padx => "2m", -pady => "2m");
+    -command => sub { select_collections(\%lvars, @collections_lang) })->pack(-side => 'left', -padx => "2m", -pady => "2m")->focus();
   $f1langB->Button(-text => __("Deselect All"),
     -command => sub { deselect_collections(\%lvars, @collections_lang) })->pack(-side => 'right', -padx => "2m", -pady => "2m");
 
diff -ur installer.orig/install-menu-wizard.pl installer/install-menu-wizard.pl
--- installer.orig/install-menu-wizard.pl	2009-10-10 15:55:28.750000000 +0400
+++ installer/install-menu-wizard.pl	2009-10-10 22:12:25.937500000 +0400
@@ -157,14 +157,14 @@
 
   $can = $mw->Button(-width => 10, -relief => "ridge", -text => __('Cancel'),
                -command => sub { $return = $MENU_ABORT; $mw->destroy; });
-  $nxt = $mw->Button(-width => 10, -relief => "ridge", -text => __('Next >'));
   $prv = $mw->Button(-width => 10, -relief => "ridge", -text => __('< Back'));
+  $nxt = $mw->Button(-width => 10, -relief => "ridge", -text => __('Next >'));
 
   $can->place(-x => $LEFT, -y => ($MHEIGHT - $BOTTOM), -anchor => "sw");
 
   my $rb = $MWIDTH - $RIGHT;
   $nxt->place(-x => ($MWIDTH - $RIGHT) , 
-              -y => ($MHEIGHT - $BOTTOM), -anchor => "se");
+              -y => ($MHEIGHT - $BOTTOM), -anchor => "se")->focus();
 
   reset_start();
 
@@ -270,7 +270,7 @@
   $sw->grab();
   $sw->Label(-text => __('Enter path for') . " TEXDIR: ")->pack(-padx => "2m", -pady => "2m");
   my $entry = $sw->Entry(-textvariable => $val, -width => 60);
-  $entry->pack(-padx => "2m", -pady => "2m");
+  $entry->pack(-padx => "2m", -pady => "2m")->focus();
   my $f = $sw->Frame;
   my $okbutton = $f->Button(-text => __('Ok'), -width => 10, 
      -relief => "ridge",
@@ -411,7 +411,7 @@
   for ($fmain->children) {
     $_->destroy;
   }
-  $counter->configure(-text => "4/4");
+  $counter->configure(-text => "5/5");
   # create a progress bar window
   # compute the height of the Text by the given font
 
(last line of the patch consists of just a space).

There is much room for improvements and I'm not sure whether optimal 
defaults were choosen for focus or not. But I hope it's progress.

Tested on Windows only.

Alexander Cherepanov




More information about the tex-live mailing list