NAME

Tk::FileBrowser - Multi column file system explorer

SYNOPSIS

require Tk::FileBrowser;
my $b = $window->FileBrowser(@options)->pack;
$b->load($folder);

DESCRIPTION

A multicolumn file browser widget. Columns are configurable, sortable and resizable.

CONFIG VARIABLES

Switch: -casedependantsort

Default value 0;

If you change the value you have to call refresh to see your changes.

Switch: -columns

Specify a list of column names to display. Only available at create time. Allowed values are 'Accessed', 'Created', 'Modified', 'Size' and any you have defined through the -columntypes option.

Default value ['Size', 'Modified'].

The 'Name' column is always present and always first.

Switch: -columntypes

Specify a list of column types you ish to define. Here is an example we use in our test file. I adds the colun 'Big', which marks every entry that is geater than 2048 with an 'X', and sorts on size.

my $fb = $app->FileBrowser(
   -columns => [qw[Size Modified Big]],
   -columntypes => [
      Big => {
         display => sub {
            my ($data) = @_;
            my $s = $fb->getSize($data);
            return 'X' if $s > 2048;
            return '';
         },
         test => sub {
            my ($data1, $data2) = @_;
            return $fb->testSize($data1, $data2);
         },
      },
   ],
)->pack(
   -expand => 1,
  -fill => 'both',
);
Switch -dateformat

Defaultvalue: "%Y-%m-%d %H:%M". Specifies how time stamps should be represented.

Switch: -directoriesfirst

Default value 1.

If you change the value you have to call refresh to see your changes.

Switch: -diriconcall

Callback for obtaining the dir icon. By default it is set to a call that returns the default folder.xpm in the Perl/Tk distribution.

Switch: -fileiconcall

Callback for obtaining the file icon. By default it is set to a call that returns the default file.xpm in the Perl/Tk distribution.

Switch: -invokefile

This callback is executed when a user double clicks a file.

Switch: -showhidden

Default value 0;

If you change the value you have to call load again to see your changes.

Switch: -sorton

Can be any valid column name. Default value 'Name'.

If you change the value you have to call refresh to see your changes.

Switch: -sortorder

Can be 'ascending' or 'descending'. Default value 'ascending'.

If you change the value you have to call refresh to see your changes.

ADVERTISED SUBWIDGETS

Entry

Class Tk::ListEntry.

Tree

Class Tk::ITree.

METHODS

getDateString($type, $data)

Returns the formatted date string of one of the date items in $data; $type can be 'atime', 'ctime' or 'mtime'

getNameString($data)

Returns the name to be displayed for $data.

getSize($data)

Returns the size of the item represented in $data. If $data contains a folder, it returns the number of items. If not if returns the size in bytes.

getSizeString($data)

Returns the formatted size string to be displayed for $data.

getStat($item)

Returns a reference to an info hash for $item. $item if the full name of an existing file or folder. This data structure is used throughout this package. Whenever you seee $data in this document it refers to one of these. If looks like this:

$stat = {
   name => $item,
   size => $some_size,
   atime => $some_time_stamp_1,
   ctime => $some_time_stamp_2,
   mtime => $some_time_stamp_3,

   #the ones below only if $item is folder.
   children => {}, #default
   loaded => 0, #default
   open => 0, #default
}
load($folder)

loads $folder into memory and refreshes the display if succesfull.

refresh

Deletes all entries in the list and rebuilds it.

testDate($type, $data1, $data2)

$type can be 'atime', 'ctime' or 'mtime'.

Compares the date stamps in $data1 and $data2 and returns true if $data1 wins.

testName($data1, $data2)

Compares the names of $data1 and $data2 and returns true if $data1 wins.

testSize($data1, $data2)

Compares the sizes of $data1 and $data2 and returns true if $data1 wins.

LICENSE

Same as Perl.

AUTHOR

Hans Jeuken (hanje at cpan dot org)

TODO

Allow columns to be configured on the fly.
Recognize links.

BUGS AND CAVEATS

Loading and sorting large folders takes ages.

If you find any bugs, please contact the author.

SEE ALSO

Tk::ITree
Tk::Tree