line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# show final status of a job as a MessageUntilKey or something |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Copyright 2008, 2009, 2010, 2011, 2012 Kevin Ryde |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# This file is part of Chart. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Chart is free software; you can redistribute it and/or modify it under the |
11
|
|
|
|
|
|
|
# terms of the GNU General Public License as published by the Free Software |
12
|
|
|
|
|
|
|
# Foundation; either version 3, or (at your option) any later version. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Chart is distributed in the hope that it will be useful, but WITHOUT ANY |
15
|
|
|
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
16
|
|
|
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
17
|
|
|
|
|
|
|
# details. |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
20
|
|
|
|
|
|
|
# with Chart. If not, see <http://www.gnu.org/licenses/>. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package App::Chart::Gtk2::JobStatusbarMessage; |
23
|
1
|
|
|
1
|
|
341
|
use 5.008; |
|
1
|
|
|
|
|
3
|
|
24
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
25
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
26
|
1
|
|
|
1
|
|
133
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
29
|
|
|
|
|
|
|
#use Smart::Comments; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use App::Chart::Glib::Ex::MoreUtils; |
32
|
|
|
|
|
|
|
use Gtk2::Ex::Statusbar::Message; |
33
|
|
|
|
|
|
|
use App::Chart::Gtk2::Job; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Glib::Object::Subclass |
36
|
|
|
|
|
|
|
'Gtk2::Ex::Statusbar::Message', |
37
|
|
|
|
|
|
|
properties => [ Glib::ParamSpec->scalar |
38
|
|
|
|
|
|
|
('jobs', |
39
|
|
|
|
|
|
|
'jobs', |
40
|
|
|
|
|
|
|
'Arrayref of App::Chart::Gtk2::Job objects to display.', |
41
|
|
|
|
|
|
|
Glib::G_PARAM_READWRITE) |
42
|
|
|
|
|
|
|
]; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# ENHANCE-ME: ConnectProperties onto the first in @$jobs, plus noticing when |
45
|
|
|
|
|
|
|
# it and other jobs are done to remove from list |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub INIT_INSTANCE { |
48
|
|
|
|
|
|
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
# disconnected in _do_job_status_changed() below when notice weakened away |
50
|
|
|
|
|
|
|
# App::Chart::Gtk2::Job->signal_add_emission_hook |
51
|
|
|
|
|
|
|
# ('status_changed', |
52
|
|
|
|
|
|
|
# \&_do_job_status_changed, |
53
|
|
|
|
|
|
|
# App::Chart::Glib::Ex::MoreUtils::ref_weak($self)); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
require App::Chart::Glib::Ex::EmissionHook; |
56
|
|
|
|
|
|
|
$self->{'hook'} = App::Chart::Glib::Ex::EmissionHook->new |
57
|
|
|
|
|
|
|
('App::Chart::Gtk2::Job', |
58
|
|
|
|
|
|
|
status_changed => \&_do_job_status_changed, |
59
|
|
|
|
|
|
|
App::Chart::Glib::Ex::MoreUtils::ref_weak($self)); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub SET_PROPERTY { |
63
|
|
|
|
|
|
|
my ($self, $pspec, $newval) = @_; |
64
|
|
|
|
|
|
|
my $pname = $pspec->get_name; |
65
|
|
|
|
|
|
|
$self->{$pname} = $newval; |
66
|
|
|
|
|
|
|
if ($pname eq 'jobs') { |
67
|
|
|
|
|
|
|
_update_status ($self); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub add_job { |
72
|
|
|
|
|
|
|
my ($self, $job) = @_; |
73
|
|
|
|
|
|
|
my $jobs = $self->{'jobs'}; |
74
|
|
|
|
|
|
|
push @$jobs, $job; |
75
|
|
|
|
|
|
|
if (@$jobs == 1) { |
76
|
|
|
|
|
|
|
_update_status ($self); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
$self->notify('jobs'); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _do_job_status_changed { |
82
|
|
|
|
|
|
|
my ($invocation_hint, $param_list, $ref_weak_self) = @_; |
83
|
|
|
|
|
|
|
### JobStatusbarMessage _do_job_status_changed() |
84
|
|
|
|
|
|
|
my ($job) = @$param_list; |
85
|
|
|
|
|
|
|
my $self = $$ref_weak_self || return 0; # destroyed, disconnect |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $jobs = $self->{'jobs'}; |
88
|
|
|
|
|
|
|
if (defined $jobs->[0] && $job == $jobs->[0]) { |
89
|
|
|
|
|
|
|
@$jobs = grep {! $_->is_done} @$jobs; |
90
|
|
|
|
|
|
|
# FIXME: |
91
|
|
|
|
|
|
|
# $self->notify('jobs'); |
92
|
|
|
|
|
|
|
_update_status ($self); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
return 1; # stay connected |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _update_status { |
98
|
|
|
|
|
|
|
my ($self) = @_; |
99
|
|
|
|
|
|
|
### JobStatusbarMessage _update_status() |
100
|
|
|
|
|
|
|
my $job = $self->{'jobs'}->[0]; |
101
|
|
|
|
|
|
|
$self->set_message ($job ? $job->status : undef); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
__END__ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
App::Chart::Gtk2::JobStatusbarMessage -- display Job status in a Gtk2::Statusbar |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=for test_synopsis my ($statusbar, $job) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SYNOPSIS |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
use App::Chart::Gtk2::JobStatusbarMessage; |
116
|
|
|
|
|
|
|
my $msg = App::Chart::Gtk2::JobStatusbarMessage->new (statusbar => $statusbar); |
117
|
|
|
|
|
|
|
$msg->add_job ($job); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 OBJECT HIERARCHY |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
C<App::Chart::Gtk2::JobStatusbarMessage> is a subclass of |
122
|
|
|
|
|
|
|
C<Gtk2::Ex::Statusbar::Message>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Glib::Object |
125
|
|
|
|
|
|
|
Gtk2::Ex::Statusbar::Message |
126
|
|
|
|
|
|
|
App::Chart::Gtk2::JobStatusbarMessage |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 DESCRIPTION |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
... |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 PROPERTIES |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over 4 |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item C<jobs> ... |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SEE ALSO |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<App::Chart::Gtk2::Job>, L<App::Chart::Gtk2::JobQueue> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L<Gtk2::Statusbar>, L<Gtk2::Ex::Statusbar::Message> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|