Subject: | DirTree's folder sort order is wrong on Windows (patch attached) |
Tk::DirTree sorts its folder list case-sensitively, but on Windows we
want case-INsensitive order. Here is a drop-in replacement for the
add_to_tree function. The changed lines are noted with my name in comment.
============= BEGIN SNIPPET ==============
sub add_to_tree {
my( $w, $dir, $name, $parent ) = @_;
my $iWin32 = ($^O =~ m!win32!i); # added by Martin Thurn
my $dirSortable = $iWin32 ? uc $dir : $dir; # added by Martin Thurn
my $image = $w->cget('-image');
if ( !UNIVERSAL::isa($image, 'Tk::Image') ) {
$image = $w->Getimage( $image );
}
my $mode = 'none';
$mode = 'open' if $w->has_subdir( $dir );
my @args = (-image => $image, -text => $name);
if( $parent ) { # Add in alphabetical order.
foreach my $sib ($w->infoChildren( $parent )) {
my $sibSortable = $iWin32 ? uc $sib : $sib; # added by Martin
Thurn
# if( $sib gt $dir ) { # commented out by Martin Thurn
if( $sibSortable gt $dirSortable ) { # added by Martin Thurn
push @args, (-before => $sib);
last;
}
}
}
$w->add( $dir, @args );
$w->setmode( $dir, $mode );
}
============= END SNIPPET ==============
--
- - Martin 'Kingpin' Thurn