Changeset 12406


Ignore:
Timestamp:
08/30/10 09:35:04 (18 months ago)
Author:
adamk
Message:

browse_message calls now (sort of) overlay existing directory listing... but not very well, and it often breaks

Location:
trunk/Padre
Files:
3 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Wx/Directory.pm

    r12400 r12406  
    261261    my @stack  = (); 
    262262    my $lock   = $self->main->lock('UPDATE'); 
    263     foreach my $i ( 1 .. $#$files ) { 
    264         my $path  = $files->[$i]; 
    265         my $image = $path->type ? 'folder' : 'package'; 
     263    shift @$files; 
     264    foreach my $path ( @$files ) { 
    266265        while (@stack) { 
    267266 
     
    283282        # Add the next item to that parent 
    284283        my $item = $tree->AppendItem( 
    285             $parent,                      # Parent node 
    286             $path->name,                  # Label 
    287             $tree->{images}->{$image},    # Icon 
    288             -1,                           # Wx Identifier 
    289             Wx::TreeItemData->new($path), # Embedded data 
     284            $parent,                           # Parent 
     285            $path->name,                       # Label 
     286            $tree->{images}->{ $path->image }, # Icon 
     287            -1,                                # Icon (Selected) 
     288            Wx::TreeItemData->new($path),      # Embedded data 
    290289        ); 
    291290 
     
    429428    } 
    430429 
    431     # Temporarily skip if we've already filled this node. 
    432     # TODO: Upgrade this to make it update the list instead. 
    433     if ( $tree->GetChildrenCount($cursor) ) { 
    434         return; 
    435     } 
    436  
    437     # Add the files to the cursor 
     430    # Mix the returned files into the existing entries. 
     431    # If there aren't any existing entries, this shortcuts quite nicely. 
     432    my ($child, $cookie) = $tree->GetFirstChild($cursor); 
     433    my $position = 0; 
    438434    while ( @_ ) { 
    439         my $path  = shift; 
    440         my $image = $path->type ? 'folder' : 'package'; 
    441  
    442         # Add the child to the parent 
    443         $tree->AppendItem( 
    444             $cursor,                      # Parent node 
    445             $path->name,                  # Label 
    446             $tree->{images}->{$image},    # Icon 
    447             -1,                           # Wx Identifier 
    448             Wx::TreeItemData->new($path), # Embedded data 
    449         ); 
     435        if ( $child->IsOk ) { 
     436 
     437            # We are not past the last entry 
     438            my $current = $tree->GetPlData($child); 
     439            if ( $current->name eq $_[0]->name ) { 
     440                # Already exists, discard the duplicate 
     441                shift; 
     442            } elsif ( 
     443                $current->is_directory < $_[0]->is_directory 
     444                and 
     445                lc($current->name) gt lc($_[0]->name) 
     446            ) { 
     447                my $path = shift; 
     448                $tree->InsertItem( 
     449                    $cursor,                           # Parent 
     450                    $position,                         # Before 
     451                    $path->name,                       # Label 
     452                    $tree->{images}->{ $path->image }, # Icon 
     453                    -1,                                # Icon (Selected) 
     454                    Wx::TreeItemData->new($path),      # Embedded data 
     455                ); 
     456                $position += 1; 
     457            } else { 
     458                ($child, $cookie) = $tree->GetNextChild($cursor, $cookie); 
     459                $position += 1; 
     460            } 
     461 
     462        } else { 
     463 
     464            # We are past the last entry 
     465            my $path = shift; 
     466            $tree->AppendItem( 
     467                $cursor,                           # Parent 
     468                $path->name,                       # Label 
     469                $tree->{images}->{ $path->image }, # Icon 
     470                -1,                                # Icon (Selected) 
     471                Wx::TreeItemData->new($path),      # Embedded data 
     472            ); 
     473        } 
    450474    } 
    451475 
     
    548572        my $path = Padre::Wx::Directory::Path->directory( @base, $name ); 
    549573        my $item = $tree->AppendItem( 
    550             $cursor,                      # Parent node 
     574            $cursor,                      # Parent 
    551575            $path->name,                  # Label 
    552576            $tree->{images}->{folder},    # Icon 
  • trunk/Padre/lib/Padre/Wx/Directory/Path.pm

    r12378 r12406  
    4949} 
    5050 
     51sub image { 
     52    $_[0]->[0] ? 'folder' : 'package'; 
     53} 
     54 
    5155sub name { 
    5256    $_[0]->[-1]; 
Note: See TracChangeset for help on using the changeset viewer.