NAME

Tk::MacCopy - simulate a Macintosh copy dialog.

SYNOPSIS

$cd = $parent->MacCopy(-option => value);

DESCRIPTION

This widget simulates a Macintosh Classic copy dialog using a MacProgressBar and a CollapsableFrame.

OPTIONS

The following option/value pairs are supported:

-bufsize

The copy buffer size in bytes (default is 2,097,152 bytes). The value of this option can only be set during widget creation.

METHODS

copy(to, from)

Copies 'to' to 'from'.

ADVERTISED WIDGETS

Component subwidgets can be accessed via the Subwidget method. Valid subwidget names are listed below.

Name: progressbar, Class: MacProgressBar
MacProgressBar widget reference.
Name: collapsableframe, Class: CollapsableFrame
CollapsableFrame widget reference.

EXAMPLE

#!/usr/local/bin/perl -w
use Tk;
use Tk::widgets qw/MacCopy/;
use strict;

die "Usage: maccopy.pl from to" unless $#ARGV == 1;

my $mw = MainWindow->new;

my $mc = $mw->MacCopy(-bufsize => 4 * 1_048_576);

my $b = $mw->Button(
    -text    => "Push me to copy all files in '$ARGV[0]' to '$ARGV[1]'.",
    -command => sub {$mc->copy($ARGV[0],  $ARGV[1])},
)->pack;
$mw->Button(-text => 'Quit', -command => \&exit)->pack;

$mc->Subwidget('collapsableframe')->open;

MainLoop;

BUGS

There are two phases to a MacCopy operation. First, we do a pre-scan to compute a file count and total byte count using File::Find, followed by the actual copy using File::NCopy. The pre-scan phase is blocking - we haven't made any changes to that core module. On the other hand, the actual copy can be rather lengthy, and File::NCopy needed attention anyway, so callback hooks with Tk in mind were addded.

We don't verify that there is sufficient room in the destination for the copy to succeed.

AUTHOR and COPYRIGHT

sol0@Lehigh.EDU

Copyright (C) 2000 - 2002, Stephen O.Lidie

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

KEYWORDS

Apple, CollapsableFrame, MacCopy, MacProgressBar