blob: a21ee26ec44356ca08170e233321b5ce2299476e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
&docommand("/load pprogress.pm");
package DCCProgress;
@ISA = qw(PProgress);
use strict;
sub new {
my $class = shift;
my $self = $class->SUPER::new($class, @_);
$self->create();
$self->installHandler($::PUKE_KSPROGRESS_CANCEL_ACK,
sub {$self->cancelPressed(@_)});
return $self;
}
sub setRange {
my $self = shift;
my $min = shift;
my $max = shift;
$self->{'min'} = $min;
$self->{'max'} = $max;
$self->{'step'} = ($max - $min) / 100;
$self->{'step'} = 10240 if $self->{'step'} == 0; # if sized messed don't divide by 0 :)
$self->PProgress::setRange(0, 100);
}
sub setValue {
my $self = shift;
my $value = shift;
my $steps = int($value / $self->{'step'});
$self->PProgress::setValue($steps);
}
sub setCancel {
my $self = shift;
$self->{'cancelMessage'} = shift;
}
sub cancelPressed {
my $self = shift;
&::docommand($self->{'cancelMessage'});
$self->hide;
}
|