line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ZConf::Cron::GUI::GTK; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
28227
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
854
|
use ZConf::Cron; |
|
1
|
|
|
|
|
484884
|
|
|
1
|
|
|
|
|
32
|
|
6
|
1
|
|
|
1
|
|
1110
|
use ZConf::GUI; |
|
1
|
|
|
|
|
4977
|
|
|
1
|
|
|
|
|
28
|
|
7
|
1
|
|
|
1
|
|
798
|
use String::ShellQuote; |
|
1
|
|
|
|
|
825
|
|
|
1
|
|
|
|
|
2144
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
ZConf::Cron::GUI::GTK - Implements a GTK backend for ZConf::Cron::GUI |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 1.0.0 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use ZConf::Cron::GUI::GTK; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $zcc=$ZConf::Cron->new; |
27
|
|
|
|
|
|
|
my $zccg=ZConf::Cron::GUI::GTK->new({zccron=>$zcc}); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 new |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This initializes it. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
One arguement is taken and that is a hash value. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head3 hash values |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head4 zccron |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This is a ZConf::Cron object to use. If it is not specified, |
43
|
|
|
|
|
|
|
a new one will be created. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head4 zcgui |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This is the ZConf::GUI object. If it is not passed, a new one will be created. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new{ |
52
|
0
|
|
|
0
|
1
|
|
my %args; |
53
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
54
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $self={error=>undef, errorString=>undef, gui=>{}}; |
58
|
0
|
|
|
|
|
|
bless $self; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#initiates |
61
|
0
|
0
|
|
|
|
|
if (!defined($args{zccron})) { |
62
|
0
|
|
|
|
|
|
$self->{zcc}=ZConf::Cron->new(); |
63
|
|
|
|
|
|
|
}else { |
64
|
0
|
|
|
|
|
|
$self->{zcc}=$args{zccron}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#handles it if initializing ZConf::Runner failed |
68
|
0
|
0
|
|
|
|
|
if ($self->{zcc}->{error}) { |
69
|
0
|
|
|
|
|
|
my $errorstring=$self->{zcc}->{errorString}; |
70
|
0
|
|
|
|
|
|
$errorstring=~s/\"/\\\"/g; |
71
|
0
|
|
|
|
|
|
my $error='Initializing ZConf::Cron failed. error="'.$self->{zcc}->{error} |
72
|
|
|
|
|
|
|
.'" errorString="'.$self->{zcc}->{errorString}.'"'; |
73
|
0
|
|
|
|
|
|
$self->{error}=3; |
74
|
0
|
|
|
|
|
|
$self->{errorString}=$error; |
75
|
0
|
|
|
|
|
|
warn('ZConf-Cron-GUI-GTK new:1: '.$error); |
76
|
0
|
|
|
|
|
|
return $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
$self->{zconf}=$self->{zcc}->{zconf}; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return $self; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 crontab |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Allows the crontabs to be managed. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This method is blocking. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$zccg->crontab; |
91
|
|
|
|
|
|
|
if($zccg->{error}){ |
92
|
|
|
|
|
|
|
print "Error!\n"; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub crontab{ |
98
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$self->errorblank; |
101
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
102
|
0
|
|
|
|
|
|
warn('ZConf-Cron-GUI crontab: A permanent error was set'); |
103
|
0
|
|
|
|
|
|
return undef; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
system('gtk-gzccrontab'); |
107
|
0
|
|
|
|
|
|
my $exitcode=$? >> 8; |
108
|
0
|
0
|
|
|
|
|
if ($? == -1) { |
109
|
0
|
|
|
|
|
|
$self->{error}=2; |
110
|
0
|
|
|
|
|
|
$self->{errorString}='"gtk-gzccrontab" did not run or is not in the current path'; |
111
|
0
|
|
|
|
|
|
warn('ZConf-Cron-GUI-GTK crontab:2: '.$self->{errorString}); |
112
|
0
|
|
|
|
|
|
return undef; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
if ($exitcode ne '0') { |
116
|
0
|
|
|
|
|
|
$self->{error}=3; |
117
|
0
|
|
|
|
|
|
$self->{errorString}='"gtk-gzccrontab" exited with "'.$exitcode.'"'; |
118
|
0
|
|
|
|
|
|
warn('ZConf-Cron-GUI-GTK crontab:3: '.$self->{errorString}); |
119
|
0
|
|
|
|
|
|
return undef; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return 1; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 tray |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Creates a tray icon and menu. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
use Gtk2; |
131
|
|
|
|
|
|
|
Gtk2->init; |
132
|
|
|
|
|
|
|
my $guiID=$zccg->tray; |
133
|
|
|
|
|
|
|
$trayicon->show_all; |
134
|
|
|
|
|
|
|
Gtk2->main; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub tray{ |
139
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
#inits the gui hash |
142
|
0
|
|
|
|
|
|
my %gui; |
143
|
0
|
|
|
|
|
|
$gui{id}=rand().rand(); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#inits the menu |
146
|
0
|
|
|
|
|
|
$gui{trayiconimage}=$self->xpmGtk2Image; |
147
|
0
|
|
|
|
|
|
$gui{trayiconimagepixbuf}=$gui{trayiconimage}->get_pixbuf; |
148
|
0
|
|
|
|
|
|
$gui{statusicon}=Gtk2::StatusIcon->new_from_pixbuf($gui{trayiconimagepixbuf}); |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
$gui{menu}=Gtk2::Menu->new; |
151
|
0
|
|
|
|
|
|
$gui{menu}->set_border_width('0'); |
152
|
0
|
|
|
|
|
|
$gui{menu}->show; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#connects the menu stuff |
155
|
0
|
|
|
|
|
|
$gui{statusicon}->signal_connect( |
156
|
|
|
|
|
|
|
'activate'=>\&popup, |
157
|
|
|
|
|
|
|
{ |
158
|
|
|
|
|
|
|
gui=>$gui{id}, |
159
|
|
|
|
|
|
|
self=>$self, |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
#refreshes |
164
|
0
|
|
|
|
|
|
$gui{refresh}=Gtk2::MenuItem->new('_refresh'); |
165
|
0
|
|
|
|
|
|
$gui{refresh}->show; |
166
|
0
|
|
|
|
|
|
$gui{refresh}->signal_connect(activate=>\&refreshMenuItem, |
167
|
|
|
|
|
|
|
{ |
168
|
|
|
|
|
|
|
gui=>$gui{id}, |
169
|
|
|
|
|
|
|
self=>$self, |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
); |
172
|
0
|
|
|
|
|
|
$gui{menu}->append($gui{refresh}); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
#save the GUI |
175
|
0
|
|
|
|
|
|
$self->{gui}{$gui{id}}=\%gui; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
#refreshes the GUI |
178
|
0
|
|
|
|
|
|
$self->refreshMenuItem({gui=>$gui{id}, self=>$self}); |
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
return $gui{id}; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 xpm |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This returns a XPM icon for this module. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
my $xpm=$zccg->xpm; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub xpm{ |
192
|
|
|
|
|
|
|
|
193
|
0
|
|
|
0
|
1
|
|
return '/* XPM */ |
194
|
|
|
|
|
|
|
static char * trayicon_xpm[] = { |
195
|
|
|
|
|
|
|
"32 32 77 1", |
196
|
|
|
|
|
|
|
" c #000000", |
197
|
|
|
|
|
|
|
". c #0036FF", |
198
|
|
|
|
|
|
|
"+ c #B71717", |
199
|
|
|
|
|
|
|
"@ c #0E0202", |
200
|
|
|
|
|
|
|
"# c #520A0A", |
201
|
|
|
|
|
|
|
"$ c #851111", |
202
|
|
|
|
|
|
|
"% c #A41515", |
203
|
|
|
|
|
|
|
"& c #B31717", |
204
|
|
|
|
|
|
|
"* c #B41717", |
205
|
|
|
|
|
|
|
"= c #801010", |
206
|
|
|
|
|
|
|
"- c #470909", |
207
|
|
|
|
|
|
|
"; c #060101", |
208
|
|
|
|
|
|
|
"> c #B61717", |
209
|
|
|
|
|
|
|
", c #010000", |
210
|
|
|
|
|
|
|
"\' c #530A0A", |
211
|
|
|
|
|
|
|
") c #AF1616", |
212
|
|
|
|
|
|
|
"! c #A61515", |
213
|
|
|
|
|
|
|
"~ c #400808", |
214
|
|
|
|
|
|
|
"{ c #280505", |
215
|
|
|
|
|
|
|
"] c #B11616", |
216
|
|
|
|
|
|
|
"^ c #510A0A", |
217
|
|
|
|
|
|
|
"/ c #720E0E", |
218
|
|
|
|
|
|
|
"( c #7A0F0F", |
219
|
|
|
|
|
|
|
"_ c #3B0707", |
220
|
|
|
|
|
|
|
": c #140303", |
221
|
|
|
|
|
|
|
"< c #050101", |
222
|
|
|
|
|
|
|
"[ c #220404", |
223
|
|
|
|
|
|
|
"} c #590B0B", |
224
|
|
|
|
|
|
|
"| c #180303", |
225
|
|
|
|
|
|
|
"1 c #A81515", |
226
|
|
|
|
|
|
|
"2 c #6A0D0D", |
227
|
|
|
|
|
|
|
"3 c #550B0B", |
228
|
|
|
|
|
|
|
"4 c #A91515", |
229
|
|
|
|
|
|
|
"5 c #2C0606", |
230
|
|
|
|
|
|
|
"6 c #090101", |
231
|
|
|
|
|
|
|
"7 c #700E0E", |
232
|
|
|
|
|
|
|
"8 c #0D0202", |
233
|
|
|
|
|
|
|
"9 c #9B1313", |
234
|
|
|
|
|
|
|
"0 c #811010", |
235
|
|
|
|
|
|
|
"a c #020000", |
236
|
|
|
|
|
|
|
"b c #110202", |
237
|
|
|
|
|
|
|
"c c #B01616", |
238
|
|
|
|
|
|
|
"d c #2D0606", |
239
|
|
|
|
|
|
|
"e c #5A0B0B", |
240
|
|
|
|
|
|
|
"f c #8B1111", |
241
|
|
|
|
|
|
|
"g c #941313", |
242
|
|
|
|
|
|
|
"h c #7B1010", |
243
|
|
|
|
|
|
|
"i c #760F0F", |
244
|
|
|
|
|
|
|
"j c #5F0C0C", |
245
|
|
|
|
|
|
|
"k c #150303", |
246
|
|
|
|
|
|
|
"l c #460909", |
247
|
|
|
|
|
|
|
"m c #B51717", |
248
|
|
|
|
|
|
|
"n c #310606", |
249
|
|
|
|
|
|
|
"o c #480909", |
250
|
|
|
|
|
|
|
"p c #200404", |
251
|
|
|
|
|
|
|
"q c #AD1616", |
252
|
|
|
|
|
|
|
"r c #620C0C", |
253
|
|
|
|
|
|
|
"s c #120202", |
254
|
|
|
|
|
|
|
"t c #A11414", |
255
|
|
|
|
|
|
|
"u c #790F0F", |
256
|
|
|
|
|
|
|
"v c #881111", |
257
|
|
|
|
|
|
|
"w c #931212", |
258
|
|
|
|
|
|
|
"x c #8D1212", |
259
|
|
|
|
|
|
|
"y c #AA1515", |
260
|
|
|
|
|
|
|
"z c #1B0303", |
261
|
|
|
|
|
|
|
"A c #570B0B", |
262
|
|
|
|
|
|
|
"B c #080101", |
263
|
|
|
|
|
|
|
"C c #6F0E0E", |
264
|
|
|
|
|
|
|
"D c #B31616", |
265
|
|
|
|
|
|
|
"E c #750F0F", |
266
|
|
|
|
|
|
|
"F c #390707", |
267
|
|
|
|
|
|
|
"G c #130202", |
268
|
|
|
|
|
|
|
"H c #560B0B", |
269
|
|
|
|
|
|
|
"I c #A51515", |
270
|
|
|
|
|
|
|
"J c #3E0808", |
271
|
|
|
|
|
|
|
"K c #100202", |
272
|
|
|
|
|
|
|
"L c #861111", |
273
|
|
|
|
|
|
|
" .. .. .. .. .. . ", |
274
|
|
|
|
|
|
|
" ..... .. ..... .. . ", |
275
|
|
|
|
|
|
|
" ", |
276
|
|
|
|
|
|
|
" ", |
277
|
|
|
|
|
|
|
" ", |
278
|
|
|
|
|
|
|
" ", |
279
|
|
|
|
|
|
|
"+++++++++++++++ @#$%&*%=-; ", |
280
|
|
|
|
|
|
|
"++++++++++++++> ,\')++++++++!~", |
281
|
|
|
|
|
|
|
" {]+^ ,/+>(_:<;[}!++", |
282
|
|
|
|
|
|
|
" |1+2 3+45 67+", |
283
|
|
|
|
|
|
|
" 89+0a bc>d e", |
284
|
|
|
|
|
|
|
"
|
285
|
|
|
|
|
|
|
" ..... i..... ..... ....... ", |
286
|
|
|
|
|
|
|
" .. j+.. ..!+k.. .. . ", |
287
|
|
|
|
|
|
|
" . l+*.. . m+; . .. . ", |
288
|
|
|
|
|
|
|
" . n&+o.. . m+; . .. . ", |
289
|
|
|
|
|
|
|
" . pq+r .. . !+k . .. . ", |
290
|
|
|
|
|
|
|
" ..st+u, .. . v+_ . .. . ", |
291
|
|
|
|
|
|
|
" ..w+x; .. ..3+h.. .. . ", |
292
|
|
|
|
|
|
|
" a..... .. ..... .. .}", |
293
|
|
|
|
|
|
|
" 2+yz A+45 BC+", |
294
|
|
|
|
|
|
|
"#+D5 ,E+>uFG<;pH%++", |
295
|
|
|
|
|
|
|
">++++++++++++++ ,3c++++++++IJ", |
296
|
|
|
|
|
|
|
"+++++++++++++++ K\'LI**%=l; ", |
297
|
|
|
|
|
|
|
" ", |
298
|
|
|
|
|
|
|
" ", |
299
|
|
|
|
|
|
|
" ", |
300
|
|
|
|
|
|
|
" ", |
301
|
|
|
|
|
|
|
" ", |
302
|
|
|
|
|
|
|
" ", |
303
|
|
|
|
|
|
|
" ..... ..... ..... ....... ", |
304
|
|
|
|
|
|
|
" .. .. .. .. .. . "}; |
305
|
|
|
|
|
|
|
' |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head2 xpmGtk2Image |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
This returns a Gtk2::Image object with it. This is done as getting a Gtk2::Image object from raw data is |
312
|
|
|
|
|
|
|
not a straight forward processes. It requires access to "/tmp/" to write the scratch file. |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
my $image=$zccg->xpmGtk2Image; |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=cut |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub xpmGtk2Image{ |
319
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
320
|
0
|
|
|
|
|
|
my $xpm=$self->xpm; |
321
|
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
|
my $file="/tmp/".rand().rand().rand().rand().".xpm"; |
323
|
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
|
open(XPM, '>', $file); |
325
|
0
|
|
|
|
|
|
print XPM $xpm; |
326
|
0
|
|
|
|
|
|
close(XPM); |
327
|
|
|
|
|
|
|
|
328
|
0
|
|
|
|
|
|
my $image=Gtk2::Image->new_from_file($file); |
329
|
|
|
|
|
|
|
|
330
|
0
|
|
|
|
|
|
unlink($file); |
331
|
|
|
|
|
|
|
|
332
|
0
|
|
|
|
|
|
return $image; |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
=head2 dialogs |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
This returns the available dailogs. |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=cut |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
sub dialogs{ |
342
|
0
|
|
|
0
|
1
|
|
return ('crontab'); |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
=head2 windows |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
This returns a list of available windows. |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=cut |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
sub windows{ |
352
|
0
|
|
|
0
|
1
|
|
return (); |
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
=head2 errorblank |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
This blanks the error storage and is only meant for internal usage. |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
It does the following. |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
$self->{error}=undef; |
362
|
|
|
|
|
|
|
$self->{errorString}=""; |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=cut |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
#blanks the error flags |
367
|
|
|
|
|
|
|
sub errorblank{ |
368
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
369
|
|
|
|
|
|
|
|
370
|
0
|
0
|
|
|
|
|
if ($self->{perror}) { |
371
|
0
|
|
|
|
|
|
warn('ZConf-Cron-GUI errorblank: A permanent error is set.'); |
372
|
0
|
|
|
|
|
|
return undef; |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
|
375
|
0
|
|
|
|
|
|
$self->{error}=undef; |
376
|
0
|
|
|
|
|
|
$self->{errorString}=""; |
377
|
|
|
|
|
|
|
|
378
|
0
|
|
|
|
|
|
return 1; |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=head1 tray Related Methods. |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
These methods are entirely related to the tray method. |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
=head2 refreshMenuItem |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
This method refresheses the menu. |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
It takes one arguement and it is a hash reference. |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=head3 hash reference keys |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
=head4 gui |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
This is the GUI ID of the tray GUI. |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
=head4 self |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
This is the ZConf::Cron::GUI::GTK object. |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
=cut |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
sub refreshMenuItem{ |
404
|
0
|
|
|
0
|
1
|
|
my %args; |
405
|
0
|
|
|
|
|
|
%args=%{$_[1]}; |
|
0
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
#makes sure we have a gui ID |
408
|
0
|
0
|
|
|
|
|
if (!defined($args{gui})) { |
409
|
0
|
|
|
|
|
|
return undef; |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
#make sure we have our self |
413
|
0
|
0
|
|
|
|
|
if (!defined($args{self})) { |
414
|
0
|
|
|
|
|
|
return undef; |
415
|
|
|
|
|
|
|
} |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
#gets the gui ID |
418
|
0
|
|
|
|
|
|
my $guiID=$args{gui}; |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
#easier to use |
421
|
0
|
|
|
|
|
|
my $gui=$args{gui}; |
422
|
0
|
|
|
|
|
|
my $self=$args{self}; |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
#makes sure the GUI exists |
425
|
0
|
0
|
|
|
|
|
if (!defined($self->{gui}{$gui})) { |
426
|
0
|
|
|
|
|
|
return undef; |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
#rebuilds the basic menu items |
430
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menu}=Gtk2::Menu->new; |
431
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menu}->show; |
432
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menuTearoff}=Gtk2::TearoffMenuItem->new; |
433
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menuTearoff}->show; |
434
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menu}->append($self->{gui}{$gui}{menuTearoff}); |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
#adds the refresh menu item |
437
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{refresh}=Gtk2::MenuItem->new('_refresh'); |
438
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{refresh}->show; |
439
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{refresh}->signal_connect(activate=>\&refreshMenuItem, |
440
|
|
|
|
|
|
|
{ |
441
|
|
|
|
|
|
|
gui=>$guiID, |
442
|
|
|
|
|
|
|
self=>$self, |
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
); |
445
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menu}->append($self->{gui}{$gui}{refresh}); |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
#adds the edit item |
448
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{edit}=Gtk2::MenuItem->new('_edit'); |
449
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{edit}->show; |
450
|
|
|
|
|
|
|
$self->{gui}{$gui}{edit}->signal_connect(activate=>sub{ |
451
|
0
|
|
|
0
|
|
|
$_[1]{self}->crontab; |
452
|
0
|
|
|
|
|
|
$_[1]{self}->refreshMenuItem( { |
453
|
|
|
|
|
|
|
gui=>$_[1]{gui}, |
454
|
|
|
|
|
|
|
self=>$_[1]{self} |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
); |
457
|
|
|
|
|
|
|
}, |
458
|
0
|
|
|
|
|
|
\%args |
459
|
|
|
|
|
|
|
); |
460
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menu}->append($self->{gui}{$gui}{edit}); |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
#adds the seperator item |
463
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{seperator}=Gtk2::SeparatorMenuItem->new(); |
464
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{seperator}->show; |
465
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menu}->append($self->{gui}{$gui}{seperator}); |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
#gets the tabs |
468
|
0
|
|
|
|
|
|
my @tabs=$self->{zcc}->getTabs; |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
#creates the object to hold the cron tabs to run |
471
|
0
|
|
|
|
|
|
my $int=0; |
472
|
0
|
|
|
|
|
|
while (defined($tabs[$int])) { |
473
|
0
|
|
|
|
|
|
my $name='item'.$int; |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
#adds the a new item |
476
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{$name}=Gtk2::MenuItem->new('_'.$tabs[$int]); |
477
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{$name}->show; |
478
|
|
|
|
|
|
|
$self->{gui}{$gui}{$name}->signal_connect(activate=>sub{ |
479
|
0
|
|
|
0
|
|
|
my $safetab=shell_quote($_[1]{tab}); |
480
|
|
|
|
|
|
|
#my $sef=$_[1]{self}->{zcc}-> |
481
|
0
|
|
|
|
|
|
system('zccron -t '.$safetab); |
482
|
|
|
|
|
|
|
}, |
483
|
|
|
|
|
|
|
{ |
484
|
0
|
|
|
|
|
|
gui=>$guiID, |
485
|
|
|
|
|
|
|
self=>$self, |
486
|
|
|
|
|
|
|
tab=>$tabs[$int], |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
); |
489
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menu}->append($self->{gui}{$gui}{$name}); |
490
|
|
|
|
|
|
|
|
491
|
0
|
|
|
|
|
|
$int++; |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
#adds the seperator item |
495
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{seperator2}=Gtk2::SeparatorMenuItem->new(); |
496
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{seperator2}->show; |
497
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menu}->append($self->{gui}{$gui}{seperator2}); |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
#the quit button |
500
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{quit}=Gtk2::MenuItem->new('_quit'); |
501
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{quit}->show; |
502
|
|
|
|
|
|
|
$self->{gui}{$gui}{quit}->signal_connect(activate=>sub{ |
503
|
0
|
|
|
0
|
|
|
exit 0; |
504
|
|
|
|
|
|
|
} |
505
|
0
|
|
|
|
|
|
); |
506
|
0
|
|
|
|
|
|
$self->{gui}{$gui}{menu}->append($self->{gui}{$gui}{quit}); |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
#adds the new menu |
509
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
|
return 1; |
511
|
|
|
|
|
|
|
} |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
=head2 popup |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
This pops the menu up. |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=cut |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
sub popup{ |
520
|
0
|
|
|
0
|
1
|
|
my $widget=$_[0]; |
521
|
0
|
|
|
|
|
|
my %args=%{ $_[1] }; |
|
0
|
|
|
|
|
|
|
522
|
0
|
|
|
|
|
|
my $menu=$args{self}->{gui}{ $args{gui} }{menu}; |
523
|
|
|
|
|
|
|
|
524
|
0
|
|
|
|
|
|
my ($x, $y, $push_in) = Gtk2::StatusIcon::position_menu($menu, $widget); |
525
|
|
|
|
|
|
|
|
526
|
0
|
|
|
|
|
|
$menu->show_all(); |
527
|
0
|
|
|
0
|
|
|
$menu->popup( undef, undef, |
528
|
|
|
|
|
|
|
sub{return ($x,$y,0)} , |
529
|
0
|
|
|
|
|
|
undef, 0, 0 ); |
530
|
|
|
|
|
|
|
} |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=head1 DIALOGS |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
ask |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=head1 WINDOWS |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
At this time, no windows are supported. |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
=head1 ERROR CODES |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
=head2 1 |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
Initializing ZConf::Cron failed. |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
=head2 2 |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
Could not run "gtk-gzccrontab" as it was not found in the path. |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
=head2 3 |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
'gtk-gzccrontab' exited with a non-zero. |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
=head1 AUTHOR |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
=head1 BUGS |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
561
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
562
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
=head1 SUPPORT |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
perldoc ZConf::Cron::GUI |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
You can also look for information at: |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
=over 4 |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
L |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
L |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
=item * CPAN Ratings |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
L |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
=item * Search CPAN |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
L |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
=back |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
605
|
|
|
|
|
|
|
under the same terms as Perl itself. |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
=cut |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
1; # End of ZConf::Cron::GUI::GTK |