Code Comments
Programming Forum and web based access to our favorite programming groups.Currently, getOpenFile and getSaveFile do not apply any
filter to directory names. This can be a problem in the
user's home directory on Unix/Linux where there can be many
hidden directories cluttering the selection box.
The patch below adds a -hiddendirs attribute in FBox.pm.
The default value is true = show hiddendirs, which is backward
compatible. Setting it to false will hide directories whose
name starts with '.'.
Hidden directories are generally less of a problem on
Windows, although testing the ^O value and checking the
file attribute could be done with a little work.
Try it out and post back here whether you think it would be useful
or not.
*** FBox.pm.orig Sat Mar 22 18:28:03 2008
--- FBox.pm Sat Mar 22 18:38:50 2008
***************
*** 221,226 ****
--- 221,227 ----
-filter => ['PASSIVE', undef, undef,
'*'],
-force => ['PASSIVE', undef, undef, 0],
-multiple => ['PASSIVE', undef, undef, 0],
+ -hiddendirs => ['PASSIVE', undef, undef, 1],
'DEFAULT' => [$icons],
);
# So-far-failed attempt to break reference loops ...
***************
*** 428,433 ****
--- 429,435 ----
$icons->DeleteAll;
# Make the dir & file list
+ my $showhidden = $w->cget(-hiddendirs);
my $cwd = _cwd();
local *FDIR;
if (opendir(FDIR, $cwd)) {
***************
*** 451,457 ****
next if -f $f && $f !~ m!$flt!;
}
if (-d $f) {
! $icons->Add($folder, $f);
} else {
push @files, $f;
}
--- 453,459 ----
next if -f $f && $f !~ m!$flt!;
}
if (-d $f) {
! $icons->Add($folder, $f) if ($showhidden || substr($f,
0,1) ne '.');
} else {
push @files, $f;
}
*** getOpenFile.pod.orig Sat Mar 22 18:43:41 2008
--- getOpenFile.pod Sat Mar 22 18:48:15 2008
***************
*** 70,75 ****
--- 70,81 ----
Rather, the I<General Controls> control panel on the Mac allows the
end user to override the application default directory.
+ =item B<-hiddendir> =E<gt> I<value>
+
+ Setting this to false prevents directory names starting with '.'
from
+ being displayed. Note that filetype filters are not applied to
+ directory names. Default value is true.
+
=item B<-initialfile> =E<gt> I<filename>
Specifies a filename to be displayed in the dialog when it pops
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.