Tk-FileBrowser

 view release on metacpan or  search on metacpan

lib/Tk/FileManager.pm  view on Meta::CPAN

=head1 SYNOPSIS

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

=head1 DESCRIPTION

Inherits L<Tk::FileBrowser>.

Adds some file manager functionality. A clipboard function.

=head1 ADVERTISED SUBWIDGETS

=over 4

=item B<Notifier>

=item B<DeleteDialog>

=item B<DeleteList>

=back

=head1 KEYBINDINGS

=over 4

=item B<CTRL+C>

Copies selected files and folders to the clipboard.

=item B<CTRL+V>

Pastes files and folders in the clipboard to the current location.

=item B<CTRL+X>

Copies selected files and folders to the clipboard. Files are deleted after a paste.

=item B<Delete>

Move selected files and folders to the trash bin. (Not yet functional)

=item B<Shift+Delete>

Permanently delete selected files and folders. Pops a confirm dialog first.

=back

lib/Tk/FileManager.pm  view on Meta::CPAN

sub Populate {
	my ($self,$args) = @_;

	my $mode = delete $args->{'-selectmode'};
	$mode = 'extended' unless defined $mode;
	$args->{'-selectmode'} = $mode;
	$args->{'-createfolderbutton'} = 1;

	$self->SUPER::Populate($args);
	
	$self->clipboardClear;
	$self->cutOperation(0);

	my $tree = $self->Subwidget('LB');
	my $c = $tree->Subwidget('Canvas');
	$c->Tk::bind('<Control-c>', [$self, 'clipboardCopy']);
	$c->Tk::bind('<Control-x>', [$self, 'clipboardCut']);
	$c->Tk::bind('<Control-v>', [$self, 'clipboardPaste']);
	$c->Tk::bind('<Delete>', [$self, 'trash']);
	$c->Tk::bind('<Shift-Delete>', [$self, 'delete']);
	
	my $not = $self->Label(
		-anchor => 'w',
	);
	$self->Advertise('Notifier', $not);
	my $fg = $not->cget('-foreground');

	my $deldialog = $self->YADialog(

lib/Tk/FileManager.pm  view on Meta::CPAN

		-separator => '`',
		-width => 75,
	)->pack(-expand => 1, -fill =>'both', @padding);
	$self->Advertise('DeleteDialog', $deldialog);
	$self->Advertise('DeleteList', $dellist);

#	$self->ConfigSpecs(
#	);
}

sub clipboard {
	my $self = shift;
	$self->{CLIPBOARD} = \@_ if @_;
	my $c = $self->{CLIPBOARD};
	return @$c
}

sub clipboardClear {
	my $self = shift;
	$self->{CLIPBOARD} = [];
}

sub clipboardCopy {
	my $self = shift;
	$self->clipboardClear;
	$self->cutOperation(0);
	$self->clipboard($self->collect);
}

sub clipboardCut {
	my $self = shift;
	$self->clipboardClear;
	$self->cutOperation(1);
	$self->clipboard($self->collect);
}

sub clipboardPaste {
	my $self = shift;
	my @files = $self->clipboard;
	for (@files ) {
		return 0 unless $self->fileCopy($_);
	}
	if ($self->cutOperation) {
		for (@files ) {
			return 0 unless $self->fileDelete($_);
		}
	}
	$self->clipboardClear;
	$self->reload;
	return 1
}

sub confirmOverwrite {
	my ($self, $destination) = @_;
	my $write = 'Overwrite';
	$write = 'Write into' if -d $destination;
	my $action = $self->popDialog(
		-image => 'warning',



( run in 1.424 second using v1.01-cache-2.11-cpan-84e82930d8c )