JAL-3394 improvements to the file association progress bar
[jalview.git] / utils / install4j / auto_file_associations-i4j8.pl
index c418aad..bf24b11 100755 (executable)
@@ -120,25 +120,16 @@ close(IN);
 
 my %all_associations = (%$file_associations, %$add_associations);
 
-my $num = 0;
-my $i4jcount = 0;
 my @ordered = (@put_first, @non_primary);
 for my $key (sort keys %all_associations) {
   next if grep($_ eq $key, @ordered);
   push(@ordered, $key);
 }
-for my $key (@ordered) {
-  my $a = $all_associations{$key};
-  next if (ref($a) ne "HASH");
-
-  my $extensions = $a->{extensions};
-  my @extensions = @$extensions;
-
-  $num++
-}
+my $num = $#ordered + 1;
 
 warn("--\n");
 
+my $i4jcount = 0;
 for my $shortname (@ordered) {
   my $a = $all_associations{$shortname};
   next if (ref($a) ne "HASH");
@@ -192,9 +183,9 @@ for my $shortname (@ordered) {
 
   my $ext = join(",",sort(@extensions));
   my $xdisplayext = xml_escape(join(", ", map(".$_",sort(@extensions))));
-  $i4jcount++;
   my $progresspercent = int(($i4jcount/$num)*100);
   $progresspercent = 100 if $progresspercent > 100;
+  $i4jcount++;
   my $xext = xml_escape($ext);
   my $addunixextension = "true";
 
@@ -217,24 +208,6 @@ for my $shortname (@ordered) {
 
 close(IA);
 print MA "</array>\n";
-# 
-# print MA "
-# <!-- BEGIN FROM PERL SCRIPT -->
-# <key>CFBundleURLTypes</key>
-# <array>
-# <dict>
-# <key>CFBundleURLName</key>
-# <string>org.jalview.jalview-desktop.url.jalview</string>
-# <key>CFBundleTypeRole</key>
-# <string>Editor</string>
-# <key>CFBundleURLSchemes</key>
-# <array>
-# <string>jalview</string>
-# </array>
-# </dict>
-# </array>
-# <!-- END FROM PERL SCRIPT -->
-# ";
 close(MA);
 
 sub xml_escape {