[tex-live] [PATCH] tlmgr perltk gui: change order of filtering

Ahmad Syukri bin Abdollah syockit at gmail.com
Sat Nov 30 13:19:19 CET 2013


Greetings,

Currently in tlmgr perltk gui, the selection filter doesn't have any
effect, because the text match does not pass through when the filter text
is empty (it has return 1 instead).
I've attached the patch for fixing the bug.
In the patch, I've also:
1. Changed the order of filtering such that selection filter is checked
first, as it is deemed "lighter" than text matching.
2. Refactored the text match conditionals, so that empty string skips other
checks.

Ahmad Syukri bin Abdollah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/tex-live/attachments/20131130/8dd52b99/attachment.html>
-------------- next part --------------
--- tlmgrgui.pl.old	2013-11-30 20:25:06.709577748 +0900
+++ tlmgrgui.pl	2013-11-30 21:16:52.629418202 +0900
@@ -127,6 +127,9 @@ my $match_descriptions = 1;
 my $match_filenames = 1;
 my $match_taxonomies = 1;
 my $match_text = "";
+my $selection_all = 0;
+my $selection_only_selected = 1;
+my $selection_only_not_selected = 2;
 my $selection_value = 0;
 
 
@@ -357,13 +360,11 @@ sub do_rest_of_gui {
   my $filter_selection = $filter_frame->Labelframe(-text => __("Selection"));
   if ($mode_expert) { $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);
+    -variable => \$selection_value, -value => $selection_all)->pack(@a_w);
+  $filter_selection->Radiobutton(-text => __("selected"), -command => \&update_grid,
+    -variable => \$selection_value, -value => $selection_only_selected)->pack(@a_w);
+  $filter_selection->Radiobutton(-text => __("not selected"), -command => \&update_grid,
+    -variable => \$selection_value, -value => $selection_only_not_selected)->pack(@a_w);
 
 
   my $filter_button = $filter_frame->Frame;
@@ -921,6 +922,24 @@ sub MatchesFilters {
   } else {
     return 0;
   }
+  # selection
+  if ($selection_value == $selection_all) {
+    # all -> maybe more checks
+  } elsif ($selection_value == $selection_only_selected) {
+    # only selected
+    if ($Packages{$p}{'selected'}) {
+      # do nothing, maybe more checks
+    } else {
+      # not selected package and only selected packages shown
+      return 0;
+    }
+  } else {
+    # only not selected
+    if ($Packages{$p}{'selected'}) {
+      # selected, but only not selected should be shown
+      return 0;
+    } # else do nothing
+  }
   #
   # match dealing
   #
@@ -932,12 +951,11 @@ sub MatchesFilters {
   #   + no search target selected
   #     -> show empty list (maybe show warning "select something")
   #
-  if ($match_descriptions || $match_taxonomies || $match_filenames) {
+  my $r = $match_text;
+  if ($r eq "") {
+    # do nothing, more checks have to be done
+  } elsif ($match_descriptions || $match_taxonomies || $match_filenames) {
     my $found = 0;
-    my $r = $match_text;
-    if ($r eq "") {
-      return 1;
-    }
     # check first for the default search type, the descriptions
     # also match the remoterevisionstring to get search for repositories
     if ($match_descriptions) {
@@ -948,6 +966,7 @@ sub MatchesFilters {
         $found = 1;
       }
     }
+    # if we already found, don't check the next condition!
     if (!$found) {
       if (defined($taxonomy) && $match_taxonomies) {
         if ($Packages{$p}{'taxonomy'} =~ m/$r/i) {
@@ -955,7 +974,6 @@ sub MatchesFilters {
         }
       }
     }
-    # if we already dound, don't check the next condition!
     if (!$found) {
       if ($match_filenames) {
         if ($Packages{$p}{'match_files'} =~ m/$r/i) {
@@ -969,30 +987,9 @@ sub MatchesFilters {
     }
     # otherwise more checks have to be done
   } else {
-    if ($match_text eq "") {
-      return 1;
-    } else {
-      # we could give a warning "select something" but HOW???
-      return 0;
-    }
-  }
-  # selection
-  if ($selection_value == 0) {
-    # all -> maybe more checks
-  } elsif ($selection_value == 1) {
-    # only selected
-    if ($Packages{$p}{'selected'}) {
-      # do nothing, maybe more checks
-    } else {
-      # not selected package and only selected packages shown
-      return 0;
-    }
-  } else {
-    # only not selected
-    if ($Packages{$p}{'selected'}) {
-      # selected, but only not selected should be shown
-      return 0;
-    } # else do nothing
+    # non-empty string, but no search target selected
+    # FIXME: we could give a warning "select something" but HOW???
+    return 0;
   }
   # if we come down to here the package matches
   return 1;


More information about the tex-live mailing list