Re: Directory/file browser as TreeView

A. Pagaltzis wrote:
> ...
> Now it uses an idle callback to read directories so the UI never
> freezes.

Thanks for posting your version of the browser. I'm learning a lot going through it--I think I almost see how it works ;-)

A couple of questions still. These are mostly Perl; feel free to answer off-list if you think it's more appropriate, but maybe others would benefit from the answer too.

31:  $process->( $pathname, sort +( no_upwards @content ) );

What's the "+" for?

Also, is it necessary to pass the $process closure as that bare code block (in populate_node) as you did, as opposed to a "sub { ...}"?

Here's what I mean:

sub process_dir_at_iter(&;@) {
    my ( $process, $tree_model, $iter ) = @_;

sub populate_node {
    process_dir_at_iter {
    } $tree_store, $node;

This syntax is unfamiliar to me, first I'm not that familiar with prototypes, then the call to process_dir_at_iter without a proper-looking argument list (no comma after the code block--I guess the prototype makes that acceptable). Perl code I can't parse is not at all unusual, so I'm not as worried about understanding the syntax as I am in knowing why you wrote it that way.

Now if I follow what you're doing, you install an idle closure for each directory, that reads one entry from that dir on each idle pass. Once all the entries are read, they're added en masse to the tree model. Once the closure is finished it returns FALSE, so Gtk drops it from the idle list and the closure goes *poof*


For me yours is a little smoother, but actually both versions handle the largest directories I have (~2k:/usr/bin..~6k:/usr/share/man/man3) quite well.

Thanks again.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]