line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ZConf::RSS::GUI::GTK; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19970
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
946
|
use ZConf::GUI; |
|
1
|
|
|
|
|
174157
|
|
|
1
|
|
|
|
|
39
|
|
6
|
1
|
|
|
1
|
|
1146
|
use ZConf::RSS; |
|
1
|
|
|
|
|
95647
|
|
|
1
|
|
|
|
|
43
|
|
7
|
1
|
|
|
1
|
|
1082
|
use ZConf::RSS::GUI; |
|
1
|
|
|
|
|
1751
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
483
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Gtk2::SimpleList; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
ZConf::RSS::GUI::GTK - Providees the GTK backend for ZConf::RSS::GUI. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.0.1 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use ZConf::RSS::GUI::GTK; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $zcrssgtk = ZConf::RSS::GUI::GTK->new(); |
29
|
|
|
|
|
|
|
... |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 new |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head3 args hash |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head4 obj |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This is object returned by ZConf::RSS. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $zcrssgtk=ZConf::RSS::GUI::GTK->new({obj=>$obj}); |
42
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
43
|
|
|
|
|
|
|
print "Error!\n"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new{ |
49
|
|
|
|
|
|
|
my %args; |
50
|
|
|
|
|
|
|
if(defined($_[1])){ |
51
|
|
|
|
|
|
|
%args= %{$_[1]}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
my $function='new'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $self={error=>undef, |
56
|
|
|
|
|
|
|
perror=>undef, |
57
|
|
|
|
|
|
|
errorString=>undef, |
58
|
|
|
|
|
|
|
module=>'ZConf-RSS-GUI-GTK', |
59
|
|
|
|
|
|
|
gui=>{}, |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
bless $self; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#gets the object or initiate it |
64
|
|
|
|
|
|
|
if (!defined($args{obj})) { |
65
|
|
|
|
|
|
|
$self->{obj}=ZConf::RSS->new; |
66
|
|
|
|
|
|
|
if ($self->{obj}->{error}) { |
67
|
|
|
|
|
|
|
$self->{error}=1; |
68
|
|
|
|
|
|
|
$self->{perror}=1; |
69
|
|
|
|
|
|
|
$self->{errorString}='Failed to initiate ZConf::RSS. error="'. |
70
|
|
|
|
|
|
|
$self->{obj}->{error}.'" errorString="'.$self->{obj}->{errorString}.'"'; |
71
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
72
|
|
|
|
|
|
|
return $self; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
}else { |
75
|
|
|
|
|
|
|
$self->{obj}=$args{obj}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#gets the zconf object |
79
|
|
|
|
|
|
|
$self->{zconf}=$self->{obj}->{zconf}; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Gtk2->init; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
return $self; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 addFeed |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This calls a dialog for creating a new feed. It will also init |
89
|
|
|
|
|
|
|
Gtk2 and start it's main loop. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
If GTK is already inited and you don't want the main loop exited, |
92
|
|
|
|
|
|
|
use addFeedDialog. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
One agruement is accepted and it is the URL to set it to by default. |
95
|
|
|
|
|
|
|
If not specified, '' is used. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$zcrssgtk->addFeed('http://foo.bar/rss.xml'); |
98
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
99
|
|
|
|
|
|
|
print "Error!\n"; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub addFeed{ |
105
|
|
|
|
|
|
|
my $self=$_[0]; |
106
|
|
|
|
|
|
|
my $url=$_[1]; |
107
|
|
|
|
|
|
|
my $function='addFeed'; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
$self->errorblank; |
110
|
|
|
|
|
|
|
if ($self->{error}) { |
111
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
112
|
|
|
|
|
|
|
return undef; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Gtk2->init; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $guiID=$self->addFeedDialog({ |
118
|
|
|
|
|
|
|
url=>$url, |
119
|
|
|
|
|
|
|
killmain=>1, |
120
|
|
|
|
|
|
|
}); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
if ($self->{error}) { |
123
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': addFeedDialog errored'); |
124
|
|
|
|
|
|
|
return undef; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
return 1; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 addFeedDialog |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
A dialog for adding a new feed. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
One arguement is taken and it is a hash. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head3 hash args |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head4 id |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This is GUI ID to update after it is called. If this is not defined, |
141
|
|
|
|
|
|
|
no attempted to update it will be made. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head4 url |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This is the URL to set it to initially. If this is not defined, |
146
|
|
|
|
|
|
|
it is set to ''. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
$zcrssgtk->addFeedDialog({ |
149
|
|
|
|
|
|
|
url=>'http://foo.bar/rss.xml', |
150
|
|
|
|
|
|
|
}) |
151
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
152
|
|
|
|
|
|
|
print "Error!\n"; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub addFeedDialog{ |
158
|
|
|
|
|
|
|
my $self=$_[0]; |
159
|
|
|
|
|
|
|
my $url=$_[1]{url}; |
160
|
|
|
|
|
|
|
my $guiID=$_[1]{id}; |
161
|
|
|
|
|
|
|
my $function='addFeedDialog'; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
$self->errorblank; |
164
|
|
|
|
|
|
|
if ($self->{error}) { |
165
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
166
|
|
|
|
|
|
|
return undef; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Gtk2->init; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
if (!defined($url)) { |
172
|
|
|
|
|
|
|
$url=''; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
my $window = Gtk2::Dialog->new('ZConf::RSS - Add new RSS feed?', |
176
|
|
|
|
|
|
|
undef, |
177
|
|
|
|
|
|
|
[qw/modal destroy-with-parent/], |
178
|
|
|
|
|
|
|
'gtk-cancel' => 'cancel', |
179
|
|
|
|
|
|
|
'gtk-ok' => 'accept', |
180
|
|
|
|
|
|
|
); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
$window->set_position('center-always'); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', 0); |
185
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 0); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
my $vbox = $window->vbox; |
188
|
|
|
|
|
|
|
$vbox->set_border_width(5); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
my $label = Gtk2::Label->new_with_mnemonic('Add new RSS feed?'); |
191
|
|
|
|
|
|
|
$vbox->pack_start($label, 0, 0, 1); |
192
|
|
|
|
|
|
|
$label->show; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
#url stuff |
195
|
|
|
|
|
|
|
my $ubox=Gtk2::HBox->new; |
196
|
|
|
|
|
|
|
$ubox->show; |
197
|
|
|
|
|
|
|
my $ulabel=Gtk2::Label->new('URL: '); |
198
|
|
|
|
|
|
|
$ulabel->show; |
199
|
|
|
|
|
|
|
$ubox->pack_start($ulabel, 0, 1, 0); |
200
|
|
|
|
|
|
|
my $uentry = Gtk2::Entry->new(); |
201
|
|
|
|
|
|
|
$uentry->set_editable(1); |
202
|
|
|
|
|
|
|
$uentry->set_text($url); |
203
|
|
|
|
|
|
|
$uentry->show; |
204
|
|
|
|
|
|
|
$ubox->pack_start($uentry, 1, 1, 0); |
205
|
|
|
|
|
|
|
$vbox->pack_start($ubox, 0, 0, 1); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
#name stuff |
208
|
|
|
|
|
|
|
my $nhbox=Gtk2::HBox->new; |
209
|
|
|
|
|
|
|
$nhbox->show; |
210
|
|
|
|
|
|
|
my $nlabel=Gtk2::Label->new('name: '); |
211
|
|
|
|
|
|
|
$nlabel->show; |
212
|
|
|
|
|
|
|
$nhbox->pack_start($nlabel, 0, 1, 0); |
213
|
|
|
|
|
|
|
my $nentry = Gtk2::Entry->new(); |
214
|
|
|
|
|
|
|
$nentry->set_text(''); |
215
|
|
|
|
|
|
|
$nhbox->pack_start($nentry, 1, 1, 0); |
216
|
|
|
|
|
|
|
$nentry->show; |
217
|
|
|
|
|
|
|
$vbox->pack_start($nhbox, 0, 0, 1); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
#top template stuff |
220
|
|
|
|
|
|
|
my $tthbox=Gtk2::HBox->new; |
221
|
|
|
|
|
|
|
$tthbox->show; |
222
|
|
|
|
|
|
|
my $ttlabel=Gtk2::Label->new('top template: '); |
223
|
|
|
|
|
|
|
$ttlabel->show; |
224
|
|
|
|
|
|
|
$tthbox->pack_start($ttlabel, 0, 1, 0); |
225
|
|
|
|
|
|
|
my $ttentry = Gtk2::Entry->new(); |
226
|
|
|
|
|
|
|
$ttentry->set_text('defaultTop'); |
227
|
|
|
|
|
|
|
$tthbox->pack_start($ttentry, 1, 1, 0); |
228
|
|
|
|
|
|
|
$ttentry->show; |
229
|
|
|
|
|
|
|
$vbox->pack_start($tthbox, 0, 0, 1); |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
#item template stuff |
232
|
|
|
|
|
|
|
my $ithbox=Gtk2::HBox->new; |
233
|
|
|
|
|
|
|
$ithbox->show; |
234
|
|
|
|
|
|
|
my $itlabel=Gtk2::Label->new('item template: '); |
235
|
|
|
|
|
|
|
$itlabel->show; |
236
|
|
|
|
|
|
|
$ithbox->pack_start($itlabel, 0, 1, 0); |
237
|
|
|
|
|
|
|
my $itentry = Gtk2::Entry->new(); |
238
|
|
|
|
|
|
|
$itentry->set_text('defaultItem'); |
239
|
|
|
|
|
|
|
$ithbox->pack_start($itentry, 1, 1, 0); |
240
|
|
|
|
|
|
|
$itentry->show; |
241
|
|
|
|
|
|
|
$vbox->pack_start($ithbox, 0, 0, 1); |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
#bottom template stuff |
244
|
|
|
|
|
|
|
my $bthbox=Gtk2::HBox->new; |
245
|
|
|
|
|
|
|
$bthbox->show; |
246
|
|
|
|
|
|
|
my $btlabel=Gtk2::Label->new('bottom template: '); |
247
|
|
|
|
|
|
|
$btlabel->show; |
248
|
|
|
|
|
|
|
$bthbox->pack_start($btlabel, 0, 1, 0); |
249
|
|
|
|
|
|
|
my $btentry = Gtk2::Entry->new(); |
250
|
|
|
|
|
|
|
$btentry->set_text('defaultBottom'); |
251
|
|
|
|
|
|
|
$bthbox->pack_start($btentry, 1, 1, 0); |
252
|
|
|
|
|
|
|
$btentry->show; |
253
|
|
|
|
|
|
|
$vbox->pack_start($bthbox, 0, 0, 1); |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
$uentry->signal_connect (changed => sub { |
256
|
|
|
|
|
|
|
my $text = $uentry->get_text; |
257
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
258
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
); |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
$nentry->signal_connect (changed => sub { |
263
|
|
|
|
|
|
|
my $text = $nentry->get_text; |
264
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
265
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
); |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
$ttentry->signal_connect (changed => sub { |
270
|
|
|
|
|
|
|
my $text = $ttentry->get_text; |
271
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
272
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
); |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
$itentry->signal_connect (changed => sub { |
277
|
|
|
|
|
|
|
my $text = $itentry->get_text; |
278
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
279
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
); |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
$btentry->signal_connect (changed => sub { |
284
|
|
|
|
|
|
|
my $text = $btentry->get_text; |
285
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
286
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
); |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
my $name; |
291
|
|
|
|
|
|
|
my $top; |
292
|
|
|
|
|
|
|
my $item; |
293
|
|
|
|
|
|
|
my $bottom; |
294
|
|
|
|
|
|
|
my $pressed; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
$window->signal_connect(response => sub { |
298
|
|
|
|
|
|
|
$url=$uentry->get_text; |
299
|
|
|
|
|
|
|
$name=$nentry->get_text; |
300
|
|
|
|
|
|
|
$top=$ttentry->get_text; |
301
|
|
|
|
|
|
|
$item=$itentry->get_text; |
302
|
|
|
|
|
|
|
$bottom=$btentry->get_text; |
303
|
|
|
|
|
|
|
$pressed=$_[1]; |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
); |
306
|
|
|
|
|
|
|
#runs the dailog and gets the response |
307
|
|
|
|
|
|
|
#'cancel' means the user decided not to create a new set |
308
|
|
|
|
|
|
|
#'accept' means the user wants to create a new set with the entered name |
309
|
|
|
|
|
|
|
my $response=$window->run; |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
$window->destroy; |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
if ($pressed ne 'accept') { |
314
|
|
|
|
|
|
|
return undef; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
#add the bookmark |
318
|
|
|
|
|
|
|
$self->{obj}->setFeed({ |
319
|
|
|
|
|
|
|
feed=>$url, |
320
|
|
|
|
|
|
|
name=>$name, |
321
|
|
|
|
|
|
|
topTemplate=>$top, |
322
|
|
|
|
|
|
|
bottomTemplate=>$bottom, |
323
|
|
|
|
|
|
|
itemTemplate=>$item, |
324
|
|
|
|
|
|
|
}); |
325
|
|
|
|
|
|
|
if ($self->{obj}->{error}) { |
326
|
|
|
|
|
|
|
$self->{error}=3; |
327
|
|
|
|
|
|
|
$self->{errorString}='setFeed errored. error="'.$self->{obj}->{error}.'" errorstring="'.$self->{errorString}.'"'; |
328
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
329
|
|
|
|
|
|
|
return undef; |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
if (!defined($guiID)) { |
333
|
|
|
|
|
|
|
return 1; |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
#update the stuff |
337
|
|
|
|
|
|
|
$self->updateFeedList( $guiID ); |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
return 1; |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
=head2 addTemplateDialog |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
A dialog for adding a new feed. |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
One arguement is taken and it is a the GUI ID for the manage VBox in question. |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
$zcrssgtk->addFeedDialog( $guiID ); |
350
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
351
|
|
|
|
|
|
|
print "Error!\n"; |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=cut |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub addTemplateDialog{ |
357
|
|
|
|
|
|
|
my $self=$_[0]; |
358
|
|
|
|
|
|
|
my $guiID=$_[1]; |
359
|
|
|
|
|
|
|
my $function='addTemplateDialog'; |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
$self->errorblank; |
362
|
|
|
|
|
|
|
if ($self->{error}) { |
363
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
364
|
|
|
|
|
|
|
return undef; |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
if (!defined($guiID)) { |
368
|
|
|
|
|
|
|
$self->{error}=4; |
369
|
|
|
|
|
|
|
$self->{errorString}='No GUI ID specified'; |
370
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
371
|
|
|
|
|
|
|
return undef; |
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
my $window = Gtk2::Dialog->new('ZConf::RSS - Add new template?', |
375
|
|
|
|
|
|
|
undef, |
376
|
|
|
|
|
|
|
[qw/modal destroy-with-parent/], |
377
|
|
|
|
|
|
|
'gtk-cancel' => 'cancel', |
378
|
|
|
|
|
|
|
'gtk-ok' => 'accept', |
379
|
|
|
|
|
|
|
); |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
$window->set_position('center-always'); |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', 0); |
384
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 0); |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
my $vbox = $window->vbox; |
387
|
|
|
|
|
|
|
$vbox->set_border_width(5); |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
my $label = Gtk2::Label->new_with_mnemonic('Add new template?'); |
390
|
|
|
|
|
|
|
$vbox->pack_start($label, 0, 0, 1); |
391
|
|
|
|
|
|
|
$label->show; |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
#name stuff |
395
|
|
|
|
|
|
|
my $nhbox=Gtk2::HBox->new; |
396
|
|
|
|
|
|
|
$nhbox->show; |
397
|
|
|
|
|
|
|
my $nlabel=Gtk2::Label->new('name: '); |
398
|
|
|
|
|
|
|
$nlabel->show; |
399
|
|
|
|
|
|
|
$nhbox->pack_start($nlabel, 0, 1, 0); |
400
|
|
|
|
|
|
|
my $nentry = Gtk2::Entry->new(); |
401
|
|
|
|
|
|
|
$nentry->set_text(''); |
402
|
|
|
|
|
|
|
$nhbox->pack_start($nentry, 1, 1, 0); |
403
|
|
|
|
|
|
|
$nentry->show; |
404
|
|
|
|
|
|
|
$vbox->pack_start($nhbox, 0, 0, 1); |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
$nentry->signal_connect (changed => sub { |
407
|
|
|
|
|
|
|
my $text = $nentry->get_text; |
408
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
409
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
); |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
my $name; |
414
|
|
|
|
|
|
|
my $pressed; |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
$window->signal_connect(response => sub { |
417
|
|
|
|
|
|
|
$name=$nentry->get_text; |
418
|
|
|
|
|
|
|
$pressed=$_[1]; |
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
); |
421
|
|
|
|
|
|
|
#runs the dailog and gets the response |
422
|
|
|
|
|
|
|
#'cancel' means the user decided not to create a new set |
423
|
|
|
|
|
|
|
#'accept' means the user wants to create a new set with the entered name |
424
|
|
|
|
|
|
|
my $response=$window->run; |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
$window->destroy; |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
#kill the main if needed |
429
|
|
|
|
|
|
|
if ($_[1]{killmain}) { |
430
|
|
|
|
|
|
|
Gtk2->main_quit; |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
if ($pressed ne 'accept') { |
434
|
|
|
|
|
|
|
return undef; |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
#add the bookmark |
438
|
|
|
|
|
|
|
$self->{obj}->setTemplate($name, ''); |
439
|
|
|
|
|
|
|
if ($self->{obj}->{error}) { |
440
|
|
|
|
|
|
|
$self->{error}=3; |
441
|
|
|
|
|
|
|
$self->{errorString}='setTemplate errored. error="'.$self->{obj}->{error}.'" errorstring="'.$self->{errorString}.'"'; |
442
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
443
|
|
|
|
|
|
|
return undef; |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
if (!defined($guiID)) { |
447
|
|
|
|
|
|
|
return 1; |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
#update the stuff |
451
|
|
|
|
|
|
|
$self->updateTemplateList( $guiID ); |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
return 1; |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
=head2 manage |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
Invokes the view window. |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
$zcrssgtk->manage; |
461
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
462
|
|
|
|
|
|
|
print "Error!\n"; |
463
|
|
|
|
|
|
|
} |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=cut |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
sub manage{ |
468
|
|
|
|
|
|
|
my $self=$_[0]; |
469
|
|
|
|
|
|
|
my $function='manage'; |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
$self->errorblank; |
472
|
|
|
|
|
|
|
if ($self->{error}) { |
473
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
474
|
|
|
|
|
|
|
return undef; |
475
|
|
|
|
|
|
|
} |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
Gtk2->init; |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
my $guiID=$self->manageWindow; |
480
|
|
|
|
|
|
|
$self->{gui}{$guiID}{window}->show; |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
Gtk2->main; |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
return 1; |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=head2 manageVBox |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
This creates a VBox for the manage GUI and returns the GUI ID of it. |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=head3 args hash |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=head4 disableQuit |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
If this is set to true, the quit selection under the misc functions menu will not be present. |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
my $guiID=$zcrssgtk->manageVBox; |
498
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
499
|
|
|
|
|
|
|
print "Error!\n"; |
500
|
|
|
|
|
|
|
}else{ |
501
|
|
|
|
|
|
|
$window=Gtk2::Window->new; |
502
|
|
|
|
|
|
|
$window->set_default_size(750, 400); |
503
|
|
|
|
|
|
|
$window->set_title('ZConf::RSS: manage'); |
504
|
|
|
|
|
|
|
$window->add($zcrssgtk->{gui}{$guiID}{vbox}); |
505
|
|
|
|
|
|
|
} |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=cut |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
sub manageVBox{ |
510
|
|
|
|
|
|
|
my $self=$_[0]; |
511
|
|
|
|
|
|
|
my %args; |
512
|
|
|
|
|
|
|
if(defined($_[1])){ |
513
|
|
|
|
|
|
|
%args= %{$_[1]}; |
514
|
|
|
|
|
|
|
} |
515
|
|
|
|
|
|
|
my $function='manageVBox'; |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
$self->errorblank; |
518
|
|
|
|
|
|
|
if ($self->{error}) { |
519
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
520
|
|
|
|
|
|
|
return undef; |
521
|
|
|
|
|
|
|
} |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
my %gui; |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
$gui{id}=rand().rand().rand(); |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
#the main box |
528
|
|
|
|
|
|
|
$gui{vbox}=Gtk2::VBox->new; |
529
|
|
|
|
|
|
|
$gui{vbox}->show; |
530
|
|
|
|
|
|
|
$gui{hpaned}=Gtk2::HPaned->new; |
531
|
|
|
|
|
|
|
$gui{hpaned}->set_position(0); |
532
|
|
|
|
|
|
|
$gui{hpaned}->show; |
533
|
|
|
|
|
|
|
$gui{hpaned}->set_position(200); |
534
|
|
|
|
|
|
|
$gui{vbox}->pack_start($gui{hpaned}, 1, 1, 0); |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
#puts together the basics for the list box |
537
|
|
|
|
|
|
|
$gui{listbox}=Gtk2::VBox->new; |
538
|
|
|
|
|
|
|
$gui{listbox}->show; |
539
|
|
|
|
|
|
|
$gui{hpaned}->add1($gui{listbox}); |
540
|
|
|
|
|
|
|
#this is the menu bar that goes in the list box |
541
|
|
|
|
|
|
|
$gui{menubar}=Gtk2::MenuBar->new; |
542
|
|
|
|
|
|
|
$gui{menubarmenu}=Gtk2::MenuItem->new('_misc functions'); |
543
|
|
|
|
|
|
|
$gui{menubar}->show; |
544
|
|
|
|
|
|
|
$gui{menubarmenu}->show; |
545
|
|
|
|
|
|
|
$gui{menubar}->append($gui{menubarmenu}); |
546
|
|
|
|
|
|
|
$gui{listbox}->pack_start($gui{menubar}, 0, 1, 0); |
547
|
|
|
|
|
|
|
#the window that holdes |
548
|
|
|
|
|
|
|
$gui{listSW}=Gtk2::ScrolledWindow->new; |
549
|
|
|
|
|
|
|
$gui{listSW}->show; |
550
|
|
|
|
|
|
|
$gui{listbox}->pack_start($gui{listSW}, 1, 1, 0); |
551
|
|
|
|
|
|
|
#puts the feed list stuff together |
552
|
|
|
|
|
|
|
$gui{templatelist}=Gtk2::SimpleList->new( |
553
|
|
|
|
|
|
|
'Templates'=>'text', |
554
|
|
|
|
|
|
|
); |
555
|
|
|
|
|
|
|
$gui{templatelist}->get_selection->set_mode ('single'); |
556
|
|
|
|
|
|
|
$gui{templatelist}->show; |
557
|
|
|
|
|
|
|
$gui{templatelist}->signal_connect(row_activated=>sub{ |
558
|
|
|
|
|
|
|
$_[3]{self}->updateTemplateText($_[3]{id}); |
559
|
|
|
|
|
|
|
}, |
560
|
|
|
|
|
|
|
{ |
561
|
|
|
|
|
|
|
self=>$self, |
562
|
|
|
|
|
|
|
id=>$gui{id}, |
563
|
|
|
|
|
|
|
} |
564
|
|
|
|
|
|
|
); |
565
|
|
|
|
|
|
|
$gui{listSW}->add($gui{templatelist}); |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
#puts together the menu |
568
|
|
|
|
|
|
|
$gui{menu}=Gtk2::Menu->new; |
569
|
|
|
|
|
|
|
$gui{menu}->show; |
570
|
|
|
|
|
|
|
#add |
571
|
|
|
|
|
|
|
$gui{menuAdd}=Gtk2::MenuItem->new('_add'); |
572
|
|
|
|
|
|
|
$gui{menuAdd}->show; |
573
|
|
|
|
|
|
|
$gui{menuAdd}->signal_connect(activate=>sub{ |
574
|
|
|
|
|
|
|
$_[1]{self}->addTemplateDialog({id=>$_[1]{id}}); |
575
|
|
|
|
|
|
|
}, |
576
|
|
|
|
|
|
|
{ |
577
|
|
|
|
|
|
|
id=>$gui{id}, |
578
|
|
|
|
|
|
|
self=>$self, |
579
|
|
|
|
|
|
|
} |
580
|
|
|
|
|
|
|
); |
581
|
|
|
|
|
|
|
$gui{menu}->append($gui{menuAdd}); |
582
|
|
|
|
|
|
|
#remove |
583
|
|
|
|
|
|
|
$gui{menuRemove}=Gtk2::MenuItem->new('_remove'); |
584
|
|
|
|
|
|
|
$gui{menuRemove}->show; |
585
|
|
|
|
|
|
|
$gui{menuRemove}->signal_connect(activate=>sub{ |
586
|
|
|
|
|
|
|
$_[1]{self}->removeTemplateDialog($_[1]{id}); |
587
|
|
|
|
|
|
|
}, |
588
|
|
|
|
|
|
|
{ |
589
|
|
|
|
|
|
|
id=>$gui{id}, |
590
|
|
|
|
|
|
|
self=>$self, |
591
|
|
|
|
|
|
|
} |
592
|
|
|
|
|
|
|
); |
593
|
|
|
|
|
|
|
$gui{menu}->append($gui{menuRemove}); |
594
|
|
|
|
|
|
|
#quit |
595
|
|
|
|
|
|
|
if (!$args{disableQuit}) { |
596
|
|
|
|
|
|
|
$gui{menuQuit}=Gtk2::MenuItem->new('_quit'); |
597
|
|
|
|
|
|
|
$gui{menuQuit}->show; |
598
|
|
|
|
|
|
|
$gui{menuQuit}->signal_connect(activate=>sub{ |
599
|
|
|
|
|
|
|
Gtk2->main_quit; |
600
|
|
|
|
|
|
|
}, |
601
|
|
|
|
|
|
|
{ |
602
|
|
|
|
|
|
|
id=>$gui{id}, |
603
|
|
|
|
|
|
|
self=>$self, |
604
|
|
|
|
|
|
|
} |
605
|
|
|
|
|
|
|
); |
606
|
|
|
|
|
|
|
$gui{menu}->append($gui{menuQuit}); |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
#attaches it |
609
|
|
|
|
|
|
|
$gui{menubarmenu}->set_submenu($gui{menu}); |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
#puts together the view section |
612
|
|
|
|
|
|
|
$gui{textVBox}=Gtk2::VBox->new; |
613
|
|
|
|
|
|
|
$gui{textVBox}->show; |
614
|
|
|
|
|
|
|
$gui{hpaned}->add2($gui{textVBox}); |
615
|
|
|
|
|
|
|
#adds the hbox that will hold the save/reload button |
616
|
|
|
|
|
|
|
$gui{buttonHBox}=Gtk2::HBox->new; |
617
|
|
|
|
|
|
|
$gui{buttonHBox}->show; |
618
|
|
|
|
|
|
|
$gui{textVBox}->pack_start($gui{buttonHBox}, 0, 1, 0); |
619
|
|
|
|
|
|
|
#reload button |
620
|
|
|
|
|
|
|
$gui{reloadTemplate}=Gtk2::Button->new(); |
621
|
|
|
|
|
|
|
$gui{reloadTemplateLabel}=Gtk2::Label->new('Reload Selected Template'); |
622
|
|
|
|
|
|
|
$gui{reloadTemplateLabel}->show; |
623
|
|
|
|
|
|
|
$gui{reloadTemplate}->add($gui{reloadTemplateLabel}); |
624
|
|
|
|
|
|
|
$gui{reloadTemplate}->show; |
625
|
|
|
|
|
|
|
$gui{buttonHBox}->pack_start($gui{reloadTemplate}, 0, 1, 0); |
626
|
|
|
|
|
|
|
$gui{reloadTemplate}->signal_connect(clicked=>sub{ |
627
|
|
|
|
|
|
|
$_[1]{self}->updateTemplateText($_[1]{id}); |
628
|
|
|
|
|
|
|
}, |
629
|
|
|
|
|
|
|
{ |
630
|
|
|
|
|
|
|
id=>$gui{id}, |
631
|
|
|
|
|
|
|
self=>$self, |
632
|
|
|
|
|
|
|
} |
633
|
|
|
|
|
|
|
); |
634
|
|
|
|
|
|
|
#save button |
635
|
|
|
|
|
|
|
$gui{saveTemplate}=Gtk2::Button->new(); |
636
|
|
|
|
|
|
|
$gui{saveTemplateLabel}=Gtk2::Label->new('Save Selected Template'); |
637
|
|
|
|
|
|
|
$gui{saveTemplateLabel}->show; |
638
|
|
|
|
|
|
|
$gui{saveTemplate}->add($gui{saveTemplateLabel}); |
639
|
|
|
|
|
|
|
$gui{saveTemplate}->show; |
640
|
|
|
|
|
|
|
$gui{buttonHBox}->pack_start($gui{saveTemplate}, 0, 1, 0); |
641
|
|
|
|
|
|
|
$gui{saveTemplate}->signal_connect(clicked=>sub{ |
642
|
|
|
|
|
|
|
my $self=$_[1]{self}; |
643
|
|
|
|
|
|
|
my $guiID=$_[1]{id}; |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
#get the current template name |
646
|
|
|
|
|
|
|
my @selected=$self->{gui}{ $guiID }{templatelist}->get_selected_indices; |
647
|
|
|
|
|
|
|
if(!defined($selected[0])){ |
648
|
|
|
|
|
|
|
return undef; |
649
|
|
|
|
|
|
|
} |
650
|
|
|
|
|
|
|
my $templateName=$self->{templates}[$selected[0]]; |
651
|
|
|
|
|
|
|
if (!defined($templateName)) { |
652
|
|
|
|
|
|
|
return undef; |
653
|
|
|
|
|
|
|
} |
654
|
|
|
|
|
|
|
my $template=$self->{gui}{ $guiID }{buffer}->get_text( |
655
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{buffer}->get_start_iter, |
656
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{buffer}->get_end_iter, |
657
|
|
|
|
|
|
|
1 |
658
|
|
|
|
|
|
|
); |
659
|
|
|
|
|
|
|
$self->{obj}->setTemplate($templateName, $template); |
660
|
|
|
|
|
|
|
}, |
661
|
|
|
|
|
|
|
{ |
662
|
|
|
|
|
|
|
id=>$gui{id}, |
663
|
|
|
|
|
|
|
self=>$self, |
664
|
|
|
|
|
|
|
} |
665
|
|
|
|
|
|
|
); |
666
|
|
|
|
|
|
|
#adds the VPaned that will hold the template and the template info |
667
|
|
|
|
|
|
|
$gui{textVPaned}=Gtk2::VPaned->new; |
668
|
|
|
|
|
|
|
$gui{textVPaned}->show; |
669
|
|
|
|
|
|
|
$gui{textVPaned}->set_position(200); |
670
|
|
|
|
|
|
|
$gui{textVBox}->pack_start($gui{textVPaned}, 1, 1, 1); |
671
|
|
|
|
|
|
|
#adds the template info text view |
672
|
|
|
|
|
|
|
$gui{templateInfo}=Gtk2::TextView->new; |
673
|
|
|
|
|
|
|
$gui{templateInfo}->show; |
674
|
|
|
|
|
|
|
$gui{templateInfo}->set_editable(0); |
675
|
|
|
|
|
|
|
$gui{templateInfoSW}=Gtk2::ScrolledWindow->new; |
676
|
|
|
|
|
|
|
$gui{templateInfoSW}->show; |
677
|
|
|
|
|
|
|
$gui{templateInfoSW}->add($gui{templateInfo}); |
678
|
|
|
|
|
|
|
$gui{textVPaned}->add1($gui{templateInfoSW}); |
679
|
|
|
|
|
|
|
$gui{templateInfoBuffer}=Gtk2::TextBuffer->new; |
680
|
|
|
|
|
|
|
$gui{templateInfoBuffer}->set_text( |
681
|
|
|
|
|
|
|
'TEMPLATE VARIABLES |
682
|
|
|
|
|
|
|
The templating system used is \'Text::NeatTemplate\'. The varialbes are as below. |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
CHANNEL |
685
|
|
|
|
|
|
|
{$ctitle} - This is the title for the channel. |
686
|
|
|
|
|
|
|
{$cdesc} - This is the description for the channel. |
687
|
|
|
|
|
|
|
{$cpubdate} - This is the publication date for the channel. |
688
|
|
|
|
|
|
|
{$ccopyright} - This is the copyright info for the channel. |
689
|
|
|
|
|
|
|
{$clink} - This is the link for the channel. |
690
|
|
|
|
|
|
|
{$clang} - This is the language for the channel. |
691
|
|
|
|
|
|
|
{$cimage} - This is the image for the channel. |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
ITEM |
694
|
|
|
|
|
|
|
{$ititle} - This is the title for a item. |
695
|
|
|
|
|
|
|
{$idesc} - This is the description for a item. |
696
|
|
|
|
|
|
|
{$idescFTWL} - This is the description for a item that has been has been formated with \'HTML::FormatText::WithLinks\' |
697
|
|
|
|
|
|
|
{$ipubdate} - This is the date published for a item. |
698
|
|
|
|
|
|
|
{$icat} - This is the category for a item. |
699
|
|
|
|
|
|
|
{$iauthor} - This is the author for a item. |
700
|
|
|
|
|
|
|
{$iguid} - This is the item\'s guid element. |
701
|
|
|
|
|
|
|
{$ilink} - This is the link for a item.' |
702
|
|
|
|
|
|
|
); |
703
|
|
|
|
|
|
|
$gui{templateInfo}->set_buffer($gui{templateInfoBuffer}); |
704
|
|
|
|
|
|
|
#puts together the template text view |
705
|
|
|
|
|
|
|
$gui{text}=Gtk2::TextView->new; |
706
|
|
|
|
|
|
|
$gui{text}->show; |
707
|
|
|
|
|
|
|
$gui{text}->set_editable(1); |
708
|
|
|
|
|
|
|
$gui{textSW}=Gtk2::ScrolledWindow->new; |
709
|
|
|
|
|
|
|
$gui{textSW}->show; |
710
|
|
|
|
|
|
|
$gui{textSW}->add($gui{text}); |
711
|
|
|
|
|
|
|
$gui{textVPaned}->add2($gui{textSW}); |
712
|
|
|
|
|
|
|
$gui{buffer}=Gtk2::TextBuffer->new; |
713
|
|
|
|
|
|
|
$gui{buffer}->set_text(''); |
714
|
|
|
|
|
|
|
$gui{text}->set_buffer($gui{buffer}); |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
$self->{gui}{ $gui{id} }=\%gui; |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
#this updates it |
719
|
|
|
|
|
|
|
$self->updateTemplateList($gui{id}); |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
return $gui{id}; |
722
|
|
|
|
|
|
|
} |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
=head2 manageWindow |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
This generates the manage window. |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
=head3 args hash |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
=head4 disableQuit |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
Do not show the quit selection in the menu. |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
=head4 quitOnClose |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
If the window is closed, quit the main GTK loop. |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
=head4 removeOnClose |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
Removes the GUI upon close. |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
Gtk2->init; |
744
|
|
|
|
|
|
|
my $guiID=$zcrssgtk->manageWindow; |
745
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
746
|
|
|
|
|
|
|
print "Error!\n"; |
747
|
|
|
|
|
|
|
}else{ |
748
|
|
|
|
|
|
|
$zcrssgtk->{gui}{$guiID}{window}->show; |
749
|
|
|
|
|
|
|
$Gtk2->main; |
750
|
|
|
|
|
|
|
} |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
=cut |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
sub manageWindow{ |
755
|
|
|
|
|
|
|
my $self=$_[0]; |
756
|
|
|
|
|
|
|
my %args; |
757
|
|
|
|
|
|
|
if(defined($_[1])){ |
758
|
|
|
|
|
|
|
%args= %{$_[1]}; |
759
|
|
|
|
|
|
|
} |
760
|
|
|
|
|
|
|
my $function='manageWindow'; |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
$self->errorblank; |
763
|
|
|
|
|
|
|
if ($self->{error}) { |
764
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
765
|
|
|
|
|
|
|
return undef; |
766
|
|
|
|
|
|
|
} |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
my $guiID=$self->manageVBox({disableQuit=>$args{disableQuit}}); |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}=Gtk2::Window->new; |
771
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->set_default_size(750, 500); |
772
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->set_title('ZConf::RSS: manage'); |
773
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->add($self->{gui}{$guiID}{vbox}); |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
#handles the closure stuff |
776
|
|
|
|
|
|
|
if ($args{quitOnClose}) { |
777
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->signal_connect(delete_event=>sub{ |
778
|
|
|
|
|
|
|
Gtk2->main_quit; |
779
|
|
|
|
|
|
|
} |
780
|
|
|
|
|
|
|
); |
781
|
|
|
|
|
|
|
} |
782
|
|
|
|
|
|
|
if ($args{quitOnClose}) { |
783
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->signal_connect(delete_event=>sub{ |
784
|
|
|
|
|
|
|
delete($self->{gui}{ $guiID }); |
785
|
|
|
|
|
|
|
}); |
786
|
|
|
|
|
|
|
} |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
return $guiID; |
789
|
|
|
|
|
|
|
} |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
=head2 modifyFeedDialog |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
This is the modifies the currently selected feed. |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
Only one arguement is required and it is GUI ID. |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
$zcrssgtk->modifyFeedDialog($guiID); |
798
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
799
|
|
|
|
|
|
|
print "Error!\n"; |
800
|
|
|
|
|
|
|
} |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
=cut |
803
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
sub modifyFeedDialog{ |
805
|
|
|
|
|
|
|
my $self=$_[0]; |
806
|
|
|
|
|
|
|
my $guiID=$_[1]; |
807
|
|
|
|
|
|
|
my $function='addFeedDialog'; |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
$self->errorblank; |
810
|
|
|
|
|
|
|
if ($self->{error}) { |
811
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
812
|
|
|
|
|
|
|
return undef; |
813
|
|
|
|
|
|
|
} |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
if (!defined($guiID)) { |
816
|
|
|
|
|
|
|
$self->{error}=4; |
817
|
|
|
|
|
|
|
$self->{errorString}='No GUI ID specified'; |
818
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':"'.$self->{error}.': '.$self->{errorString}); |
819
|
|
|
|
|
|
|
return undef; |
820
|
|
|
|
|
|
|
} |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
#get the feed |
823
|
|
|
|
|
|
|
my @selected=$self->{gui}{ $guiID }{feedlist}->get_selected_indices; |
824
|
|
|
|
|
|
|
if(!defined($selected[0])){ |
825
|
|
|
|
|
|
|
return undef; |
826
|
|
|
|
|
|
|
} |
827
|
|
|
|
|
|
|
my $feed=$self->{feeds}[$selected[0]]; |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
#gets the feed args |
830
|
|
|
|
|
|
|
my %feedArgs=$self->{obj}->getFeedArgs($feed); |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
my $window = Gtk2::Dialog->new('ZConf::RSS - Modify the feed "'.$feed.'"?', |
833
|
|
|
|
|
|
|
undef, |
834
|
|
|
|
|
|
|
[qw/modal destroy-with-parent/], |
835
|
|
|
|
|
|
|
'gtk-cancel' => 'cancel', |
836
|
|
|
|
|
|
|
'gtk-ok' => 'accept', |
837
|
|
|
|
|
|
|
); |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
$window->set_position('center-always'); |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', 0); |
842
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 0); |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
my $vbox = $window->vbox; |
845
|
|
|
|
|
|
|
$vbox->set_border_width(5); |
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
#url stuff |
848
|
|
|
|
|
|
|
my $ubox=Gtk2::HBox->new; |
849
|
|
|
|
|
|
|
$ubox->show; |
850
|
|
|
|
|
|
|
my $ulabel=Gtk2::Label->new('URL: '); |
851
|
|
|
|
|
|
|
$ulabel->show; |
852
|
|
|
|
|
|
|
$ubox->pack_start($ulabel, 0, 1, 0); |
853
|
|
|
|
|
|
|
my $uentry = Gtk2::Entry->new(); |
854
|
|
|
|
|
|
|
$uentry->set_editable(1); |
855
|
|
|
|
|
|
|
$uentry->set_text($feedArgs{feed}); |
856
|
|
|
|
|
|
|
$uentry->show; |
857
|
|
|
|
|
|
|
$ubox->pack_start($uentry, 1, 1, 0); |
858
|
|
|
|
|
|
|
$vbox->pack_start($ubox, 0, 0, 1); |
859
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
#name stuff |
861
|
|
|
|
|
|
|
my $nhbox=Gtk2::HBox->new; |
862
|
|
|
|
|
|
|
$nhbox->show; |
863
|
|
|
|
|
|
|
my $nlabel=Gtk2::Label->new('name: '); |
864
|
|
|
|
|
|
|
$nlabel->show; |
865
|
|
|
|
|
|
|
$nhbox->pack_start($nlabel, 0, 1, 0); |
866
|
|
|
|
|
|
|
my $nentry = Gtk2::Entry->new(); |
867
|
|
|
|
|
|
|
$nentry->set_text($feedArgs{name}); |
868
|
|
|
|
|
|
|
$nhbox->pack_start($nentry, 1, 1, 0); |
869
|
|
|
|
|
|
|
$nentry->show; |
870
|
|
|
|
|
|
|
$vbox->pack_start($nhbox, 0, 0, 1); |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
#top template stuff |
873
|
|
|
|
|
|
|
my $tthbox=Gtk2::HBox->new; |
874
|
|
|
|
|
|
|
$tthbox->show; |
875
|
|
|
|
|
|
|
my $ttlabel=Gtk2::Label->new('top template: '); |
876
|
|
|
|
|
|
|
$ttlabel->show; |
877
|
|
|
|
|
|
|
$tthbox->pack_start($ttlabel, 0, 1, 0); |
878
|
|
|
|
|
|
|
my $ttentry = Gtk2::Entry->new(); |
879
|
|
|
|
|
|
|
$ttentry->set_text($feedArgs{topTemplate}); |
880
|
|
|
|
|
|
|
$tthbox->pack_start($ttentry, 1, 1, 0); |
881
|
|
|
|
|
|
|
$ttentry->show; |
882
|
|
|
|
|
|
|
$vbox->pack_start($tthbox, 0, 0, 1); |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
#item template stuff |
885
|
|
|
|
|
|
|
my $ithbox=Gtk2::HBox->new; |
886
|
|
|
|
|
|
|
$ithbox->show; |
887
|
|
|
|
|
|
|
my $itlabel=Gtk2::Label->new('item template: '); |
888
|
|
|
|
|
|
|
$itlabel->show; |
889
|
|
|
|
|
|
|
$ithbox->pack_start($itlabel, 0, 1, 0); |
890
|
|
|
|
|
|
|
my $itentry = Gtk2::Entry->new(); |
891
|
|
|
|
|
|
|
$itentry->set_text($feedArgs{itemTemplate}); |
892
|
|
|
|
|
|
|
$ithbox->pack_start($itentry, 1, 1, 0); |
893
|
|
|
|
|
|
|
$itentry->show; |
894
|
|
|
|
|
|
|
$vbox->pack_start($ithbox, 0, 0, 1); |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
#bottom template stuff |
897
|
|
|
|
|
|
|
my $bthbox=Gtk2::HBox->new; |
898
|
|
|
|
|
|
|
$bthbox->show; |
899
|
|
|
|
|
|
|
my $btlabel=Gtk2::Label->new('bottom template: '); |
900
|
|
|
|
|
|
|
$btlabel->show; |
901
|
|
|
|
|
|
|
$bthbox->pack_start($btlabel, 0, 1, 0); |
902
|
|
|
|
|
|
|
my $btentry = Gtk2::Entry->new(); |
903
|
|
|
|
|
|
|
$btentry->set_text($feedArgs{bottomTemplate}); |
904
|
|
|
|
|
|
|
$bthbox->pack_start($btentry, 1, 1, 0); |
905
|
|
|
|
|
|
|
$btentry->show; |
906
|
|
|
|
|
|
|
$vbox->pack_start($bthbox, 0, 0, 1); |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
$uentry->signal_connect (changed => sub { |
909
|
|
|
|
|
|
|
my $text = $uentry->get_text; |
910
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
911
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
912
|
|
|
|
|
|
|
} |
913
|
|
|
|
|
|
|
); |
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
$nentry->signal_connect (changed => sub { |
916
|
|
|
|
|
|
|
my $text = $nentry->get_text; |
917
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
918
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
919
|
|
|
|
|
|
|
} |
920
|
|
|
|
|
|
|
); |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
$ttentry->signal_connect (changed => sub { |
923
|
|
|
|
|
|
|
my $text = $ttentry->get_text; |
924
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
925
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
926
|
|
|
|
|
|
|
} |
927
|
|
|
|
|
|
|
); |
928
|
|
|
|
|
|
|
|
929
|
|
|
|
|
|
|
$itentry->signal_connect (changed => sub { |
930
|
|
|
|
|
|
|
my $text = $itentry->get_text; |
931
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
932
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
933
|
|
|
|
|
|
|
} |
934
|
|
|
|
|
|
|
); |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
$btentry->signal_connect (changed => sub { |
937
|
|
|
|
|
|
|
my $text = $btentry->get_text; |
938
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', $text !~ m/^\s*$/); |
939
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 1); |
940
|
|
|
|
|
|
|
} |
941
|
|
|
|
|
|
|
); |
942
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
my $name; |
944
|
|
|
|
|
|
|
my $top; |
945
|
|
|
|
|
|
|
my $item; |
946
|
|
|
|
|
|
|
my $bottom; |
947
|
|
|
|
|
|
|
my $pressed; |
948
|
|
|
|
|
|
|
my $url; |
949
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
|
951
|
|
|
|
|
|
|
$window->signal_connect(response => sub { |
952
|
|
|
|
|
|
|
$url=$uentry->get_text; |
953
|
|
|
|
|
|
|
$name=$nentry->get_text; |
954
|
|
|
|
|
|
|
$top=$ttentry->get_text; |
955
|
|
|
|
|
|
|
$item=$itentry->get_text; |
956
|
|
|
|
|
|
|
$bottom=$btentry->get_text; |
957
|
|
|
|
|
|
|
$pressed=$_[1]; |
958
|
|
|
|
|
|
|
} |
959
|
|
|
|
|
|
|
); |
960
|
|
|
|
|
|
|
#runs the dailog and gets the response |
961
|
|
|
|
|
|
|
#'cancel' means the user decided not to create a new set |
962
|
|
|
|
|
|
|
#'accept' means the user wants to create a new set with the entered name |
963
|
|
|
|
|
|
|
my $response=$window->run; |
964
|
|
|
|
|
|
|
|
965
|
|
|
|
|
|
|
$window->destroy; |
966
|
|
|
|
|
|
|
|
967
|
|
|
|
|
|
|
if ($pressed ne 'accept') { |
968
|
|
|
|
|
|
|
return undef; |
969
|
|
|
|
|
|
|
} |
970
|
|
|
|
|
|
|
|
971
|
|
|
|
|
|
|
#remove the old one if we are renaming it |
972
|
|
|
|
|
|
|
if ($name ne $feedArgs{name}) { |
973
|
|
|
|
|
|
|
$self->{obj}->delFeed($feed); |
974
|
|
|
|
|
|
|
if ($self->{obj}->{error}) { |
975
|
|
|
|
|
|
|
$self->{error}=3; |
976
|
|
|
|
|
|
|
$self->{errorString}='setFeed errored. error="'.$self->{obj}->{error}.'" errorstring="'.$self->{errorString}.'"'; |
977
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
978
|
|
|
|
|
|
|
return undef; |
979
|
|
|
|
|
|
|
} |
980
|
|
|
|
|
|
|
} |
981
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
#add the bookmark |
984
|
|
|
|
|
|
|
$self->{obj}->setFeed({ |
985
|
|
|
|
|
|
|
feed=>$url, |
986
|
|
|
|
|
|
|
name=>$name, |
987
|
|
|
|
|
|
|
topTemplate=>$top, |
988
|
|
|
|
|
|
|
bottomTemplate=>$bottom, |
989
|
|
|
|
|
|
|
itemTemplate=>$item, |
990
|
|
|
|
|
|
|
}); |
991
|
|
|
|
|
|
|
if ($self->{obj}->{error}) { |
992
|
|
|
|
|
|
|
$self->{error}=3; |
993
|
|
|
|
|
|
|
$self->{errorString}='setFeed errored. error="'.$self->{obj}->{error}.'" errorstring="'.$self->{errorString}.'"'; |
994
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
995
|
|
|
|
|
|
|
return undef; |
996
|
|
|
|
|
|
|
} |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
#update the stuff |
999
|
|
|
|
|
|
|
$self->updateFeedList( $guiID ); |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
return 1; |
1002
|
|
|
|
|
|
|
} |
1003
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
=head2 removeFeedDialog |
1005
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
A dialog for adding a new feed. |
1007
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
One arguement is taken and it is the GUI ID. |
1009
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
$zcrssgtk->removeFeedDialog($guiID); |
1011
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
1012
|
|
|
|
|
|
|
print "Error!\n"; |
1013
|
|
|
|
|
|
|
} |
1014
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
=cut |
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
sub removeFeedDialog{ |
1018
|
|
|
|
|
|
|
my $self=$_[0]; |
1019
|
|
|
|
|
|
|
my $guiID=$_[1]; |
1020
|
|
|
|
|
|
|
my $function='removeFeedDialog'; |
1021
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
$self->errorblank; |
1023
|
|
|
|
|
|
|
if ($self->{error}) { |
1024
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1025
|
|
|
|
|
|
|
return undef; |
1026
|
|
|
|
|
|
|
} |
1027
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
if (!defined($guiID)) { |
1029
|
|
|
|
|
|
|
$self->{error}=4; |
1030
|
|
|
|
|
|
|
$self->{errorString}='No GUI ID specified'; |
1031
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':"'.$self->{error}.': '.$self->{errorString}); |
1032
|
|
|
|
|
|
|
return undef; |
1033
|
|
|
|
|
|
|
} |
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
my @selected=$self->{gui}{ $guiID }{feedlist}->get_selected_indices; |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
if(!defined($selected[0])){ |
1038
|
|
|
|
|
|
|
return undef; |
1039
|
|
|
|
|
|
|
} |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
my $feed=$self->{feeds}[$selected[0]]; |
1042
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
my $window = Gtk2::Dialog->new('ZConf::RSS - Remove the feed "'.$feed.'"?', |
1044
|
|
|
|
|
|
|
undef, |
1045
|
|
|
|
|
|
|
[qw/modal destroy-with-parent/], |
1046
|
|
|
|
|
|
|
'gtk-cancel' => 'cancel', |
1047
|
|
|
|
|
|
|
'gtk-ok' => 'ok', |
1048
|
|
|
|
|
|
|
); |
1049
|
|
|
|
|
|
|
|
1050
|
|
|
|
|
|
|
$window->set_position('center-always'); |
1051
|
|
|
|
|
|
|
|
1052
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', 0); |
1053
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 0); |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
my $vbox = $window->vbox; |
1056
|
|
|
|
|
|
|
$vbox->set_border_width(5); |
1057
|
|
|
|
|
|
|
|
1058
|
|
|
|
|
|
|
my $label = Gtk2::Label->new_with_mnemonic('Remove the feed "'.$feed.'"?'); |
1059
|
|
|
|
|
|
|
$vbox->pack_start($label, 0, 0, 1); |
1060
|
|
|
|
|
|
|
$label->show; |
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
my $pressed; |
1063
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
$window->signal_connect(response => sub { |
1065
|
|
|
|
|
|
|
$pressed=$_[1]; |
1066
|
|
|
|
|
|
|
} |
1067
|
|
|
|
|
|
|
); |
1068
|
|
|
|
|
|
|
#runs the dailog and gets the response |
1069
|
|
|
|
|
|
|
#'cancel' means the user decided not to create a new set |
1070
|
|
|
|
|
|
|
#'accept' means the user wants to create a new set with the entered name |
1071
|
|
|
|
|
|
|
my $response=$window->run; |
1072
|
|
|
|
|
|
|
|
1073
|
|
|
|
|
|
|
$window->destroy; |
1074
|
|
|
|
|
|
|
|
1075
|
|
|
|
|
|
|
if ($pressed ne 'ok') { |
1076
|
|
|
|
|
|
|
return undef; |
1077
|
|
|
|
|
|
|
} |
1078
|
|
|
|
|
|
|
|
1079
|
|
|
|
|
|
|
#remove the feed |
1080
|
|
|
|
|
|
|
$self->{obj}->delFeed($feed); |
1081
|
|
|
|
|
|
|
if ($self->{obj}->{error}) { |
1082
|
|
|
|
|
|
|
$self->{error}=3; |
1083
|
|
|
|
|
|
|
$self->{errorString}='delFeed errored. error="'.$self->{obj}->{error}.'" errorstring="'.$self->{errorString}.'"'; |
1084
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
1085
|
|
|
|
|
|
|
return undef; |
1086
|
|
|
|
|
|
|
} |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
if (!defined($guiID)) { |
1089
|
|
|
|
|
|
|
return 1; |
1090
|
|
|
|
|
|
|
} |
1091
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
#update the stuff |
1093
|
|
|
|
|
|
|
$self->updateFeedList( $guiID ); |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
return 1; |
1096
|
|
|
|
|
|
|
} |
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
=head2 removeTemplateDialog |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
A dialog for adding a new feed. |
1101
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
One arguement is taken and it is the GUI ID. |
1103
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
$zcrssgtk->removeTemplateDialog($guiID); |
1105
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
1106
|
|
|
|
|
|
|
print "Error!\n"; |
1107
|
|
|
|
|
|
|
} |
1108
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
=cut |
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
sub removeTemplateDialog{ |
1112
|
|
|
|
|
|
|
my $self=$_[0]; |
1113
|
|
|
|
|
|
|
my $guiID=$_[1]; |
1114
|
|
|
|
|
|
|
my $function='removeTemplateDialog'; |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
$self->errorblank; |
1117
|
|
|
|
|
|
|
if ($self->{error}) { |
1118
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1119
|
|
|
|
|
|
|
return undef; |
1120
|
|
|
|
|
|
|
} |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
if (!defined($guiID)) { |
1123
|
|
|
|
|
|
|
$self->{error}=4; |
1124
|
|
|
|
|
|
|
$self->{errorString}='No GUI ID specified'; |
1125
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':"'.$self->{error}.': '.$self->{errorString}); |
1126
|
|
|
|
|
|
|
return undef; |
1127
|
|
|
|
|
|
|
} |
1128
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
my @selected=$self->{gui}{ $guiID }{templatelist}->get_selected_indices; |
1130
|
|
|
|
|
|
|
|
1131
|
|
|
|
|
|
|
if(!defined($selected[0])){ |
1132
|
|
|
|
|
|
|
return undef; |
1133
|
|
|
|
|
|
|
} |
1134
|
|
|
|
|
|
|
|
1135
|
|
|
|
|
|
|
my $template=$self->{templates}[$selected[0]]; |
1136
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
my $window = Gtk2::Dialog->new('ZConf::RSS - Remove the template "'.$template.'"?', |
1138
|
|
|
|
|
|
|
undef, |
1139
|
|
|
|
|
|
|
[qw/modal destroy-with-parent/], |
1140
|
|
|
|
|
|
|
'gtk-cancel' => 'cancel', |
1141
|
|
|
|
|
|
|
'gtk-ok' => 'ok', |
1142
|
|
|
|
|
|
|
); |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
$window->set_position('center-always'); |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
$window->set_response_sensitive ('accept', 0); |
1147
|
|
|
|
|
|
|
$window->set_response_sensitive ('reject', 0); |
1148
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
my $vbox = $window->vbox; |
1150
|
|
|
|
|
|
|
$vbox->set_border_width(5); |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
my $label = Gtk2::Label->new_with_mnemonic('Remove the template "'.$template.'"?'); |
1153
|
|
|
|
|
|
|
$vbox->pack_start($label, 0, 0, 1); |
1154
|
|
|
|
|
|
|
$label->show; |
1155
|
|
|
|
|
|
|
|
1156
|
|
|
|
|
|
|
my $pressed; |
1157
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
$window->signal_connect(response => sub { |
1159
|
|
|
|
|
|
|
$pressed=$_[1]; |
1160
|
|
|
|
|
|
|
} |
1161
|
|
|
|
|
|
|
); |
1162
|
|
|
|
|
|
|
#runs the dailog and gets the response |
1163
|
|
|
|
|
|
|
#'cancel' means the user decided not to create a new set |
1164
|
|
|
|
|
|
|
#'accept' means the user wants to create a new set with the entered name |
1165
|
|
|
|
|
|
|
my $response=$window->run; |
1166
|
|
|
|
|
|
|
|
1167
|
|
|
|
|
|
|
$window->destroy; |
1168
|
|
|
|
|
|
|
|
1169
|
|
|
|
|
|
|
if ($pressed ne 'ok') { |
1170
|
|
|
|
|
|
|
return undef; |
1171
|
|
|
|
|
|
|
} |
1172
|
|
|
|
|
|
|
|
1173
|
|
|
|
|
|
|
#remove the feed |
1174
|
|
|
|
|
|
|
$self->{obj}->delTemplate($template); |
1175
|
|
|
|
|
|
|
if ($self->{obj}->{error}) { |
1176
|
|
|
|
|
|
|
$self->{error}=3; |
1177
|
|
|
|
|
|
|
$self->{errorString}='delTemplate errored. error="'.$self->{obj}->{error}.'" errorstring="'.$self->{errorString}.'"'; |
1178
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
1179
|
|
|
|
|
|
|
return undef; |
1180
|
|
|
|
|
|
|
} |
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
#update the stuff |
1183
|
|
|
|
|
|
|
$self->updateTemplateList( $guiID ); |
1184
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
return 1; |
1186
|
|
|
|
|
|
|
} |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
=head2 view |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
Invokes the view window. |
1191
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
$zcrssgtk->view; |
1193
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
1194
|
|
|
|
|
|
|
print "Error!\n"; |
1195
|
|
|
|
|
|
|
} |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
=cut |
1198
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
sub view{ |
1200
|
|
|
|
|
|
|
my $self=$_[0]; |
1201
|
|
|
|
|
|
|
my $function='view'; |
1202
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
$self->errorblank; |
1204
|
|
|
|
|
|
|
if ($self->{error}) { |
1205
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1206
|
|
|
|
|
|
|
return undef; |
1207
|
|
|
|
|
|
|
} |
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
Gtk2->init; |
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
my $guiID=$self->viewWindow({quitOnClose=>1, removeOnClose=>1}); |
1212
|
|
|
|
|
|
|
$self->{gui}{$guiID}{window}->show; |
1213
|
|
|
|
|
|
|
|
1214
|
|
|
|
|
|
|
Gtk2->main; |
1215
|
|
|
|
|
|
|
|
1216
|
|
|
|
|
|
|
return 1; |
1217
|
|
|
|
|
|
|
} |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
=head2 viewVBox |
1220
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
This creates a VBox for the view GUI and returns the GUI ID of it. |
1222
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
=head3 args hash |
1224
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
=head4 disableQuit |
1226
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
If this is set to true, the quit selection under the misc functions menu will not be present. |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
my $guiID=$zcrssgtk->viewVBox; |
1230
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
1231
|
|
|
|
|
|
|
print "Error!\n"; |
1232
|
|
|
|
|
|
|
}else{ |
1233
|
|
|
|
|
|
|
$window=Gtk2::Window->new; |
1234
|
|
|
|
|
|
|
$window->set_default_size(750, 400); |
1235
|
|
|
|
|
|
|
$window->set_title('ZConf::RSS: view'); |
1236
|
|
|
|
|
|
|
$window->add($zcrssgtk->{gui}{$guiID}{vbox}); |
1237
|
|
|
|
|
|
|
} |
1238
|
|
|
|
|
|
|
|
1239
|
|
|
|
|
|
|
=cut |
1240
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
sub viewVBox{ |
1242
|
|
|
|
|
|
|
my $self=$_[0]; |
1243
|
|
|
|
|
|
|
my %args; |
1244
|
|
|
|
|
|
|
if(defined($_[1])){ |
1245
|
|
|
|
|
|
|
%args= %{$_[1]}; |
1246
|
|
|
|
|
|
|
} |
1247
|
|
|
|
|
|
|
my $function='viewVBox'; |
1248
|
|
|
|
|
|
|
|
1249
|
|
|
|
|
|
|
$self->errorblank; |
1250
|
|
|
|
|
|
|
if ($self->{error}) { |
1251
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1252
|
|
|
|
|
|
|
return undef; |
1253
|
|
|
|
|
|
|
} |
1254
|
|
|
|
|
|
|
|
1255
|
|
|
|
|
|
|
my %gui; |
1256
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
$gui{id}=rand().rand().rand(); |
1258
|
|
|
|
|
|
|
|
1259
|
|
|
|
|
|
|
#the main box |
1260
|
|
|
|
|
|
|
$gui{vbox}=Gtk2::VBox->new; |
1261
|
|
|
|
|
|
|
$gui{vbox}->show; |
1262
|
|
|
|
|
|
|
$gui{hpaned}=Gtk2::HPaned->new; |
1263
|
|
|
|
|
|
|
$gui{hpaned}->set_position(0); |
1264
|
|
|
|
|
|
|
$gui{hpaned}->show; |
1265
|
|
|
|
|
|
|
$gui{hpaned}->set_position(200); |
1266
|
|
|
|
|
|
|
$gui{vbox}->pack_start($gui{hpaned}, 1, 1, 0); |
1267
|
|
|
|
|
|
|
|
1268
|
|
|
|
|
|
|
#puts together the basics for the list box |
1269
|
|
|
|
|
|
|
$gui{listbox}=Gtk2::VBox->new; |
1270
|
|
|
|
|
|
|
$gui{listbox}->show; |
1271
|
|
|
|
|
|
|
$gui{hpaned}->add1($gui{listbox}); |
1272
|
|
|
|
|
|
|
#this is the menu bar that goes in the list box |
1273
|
|
|
|
|
|
|
$gui{menubar}=Gtk2::MenuBar->new; |
1274
|
|
|
|
|
|
|
$gui{menubarmenu}=Gtk2::MenuItem->new('_misc functions'); |
1275
|
|
|
|
|
|
|
$gui{menubar}->show; |
1276
|
|
|
|
|
|
|
$gui{menubarmenu}->show; |
1277
|
|
|
|
|
|
|
$gui{menubar}->append($gui{menubarmenu}); |
1278
|
|
|
|
|
|
|
$gui{listbox}->pack_start($gui{menubar}, 0, 1, 0); |
1279
|
|
|
|
|
|
|
#the window that holdes |
1280
|
|
|
|
|
|
|
$gui{listSW}=Gtk2::ScrolledWindow->new; |
1281
|
|
|
|
|
|
|
$gui{listSW}->show; |
1282
|
|
|
|
|
|
|
$gui{listbox}->pack_start($gui{listSW}, 1, 1, 0); |
1283
|
|
|
|
|
|
|
#puts the feed list stuff together |
1284
|
|
|
|
|
|
|
$gui{feedlist}=Gtk2::SimpleList->new( |
1285
|
|
|
|
|
|
|
'RSS feeds'=>'text', |
1286
|
|
|
|
|
|
|
); |
1287
|
|
|
|
|
|
|
$gui{feedlist}->get_selection->set_mode ('single'); |
1288
|
|
|
|
|
|
|
$gui{feedlist}->show; |
1289
|
|
|
|
|
|
|
$gui{feedlist}->signal_connect(row_activated=>sub{ |
1290
|
|
|
|
|
|
|
$_[3]{self}->updateFeed($_[3]{id}); |
1291
|
|
|
|
|
|
|
}, |
1292
|
|
|
|
|
|
|
{ |
1293
|
|
|
|
|
|
|
self=>$self, |
1294
|
|
|
|
|
|
|
id=>$gui{id}, |
1295
|
|
|
|
|
|
|
} |
1296
|
|
|
|
|
|
|
); |
1297
|
|
|
|
|
|
|
$gui{listSW}->add($gui{feedlist}); |
1298
|
|
|
|
|
|
|
|
1299
|
|
|
|
|
|
|
#puts together the menu |
1300
|
|
|
|
|
|
|
$gui{menu}=Gtk2::Menu->new; |
1301
|
|
|
|
|
|
|
$gui{menu}->show; |
1302
|
|
|
|
|
|
|
#add |
1303
|
|
|
|
|
|
|
$gui{menuAdd}=Gtk2::MenuItem->new('_add'); |
1304
|
|
|
|
|
|
|
$gui{menuAdd}->show; |
1305
|
|
|
|
|
|
|
$gui{menuAdd}->signal_connect(activate=>sub{ |
1306
|
|
|
|
|
|
|
$_[1]{self}->addFeedDialog({id=>$_[1]{id}}); |
1307
|
|
|
|
|
|
|
}, |
1308
|
|
|
|
|
|
|
{ |
1309
|
|
|
|
|
|
|
id=>$gui{id}, |
1310
|
|
|
|
|
|
|
self=>$self, |
1311
|
|
|
|
|
|
|
} |
1312
|
|
|
|
|
|
|
); |
1313
|
|
|
|
|
|
|
$gui{menu}->append($gui{menuAdd}); |
1314
|
|
|
|
|
|
|
#modify |
1315
|
|
|
|
|
|
|
$gui{menuModify}=Gtk2::MenuItem->new('_modify'); |
1316
|
|
|
|
|
|
|
$gui{menuModify}->show; |
1317
|
|
|
|
|
|
|
$gui{menuModify}->signal_connect(activate=>sub{ |
1318
|
|
|
|
|
|
|
$_[1]{self}->modifyFeedDialog($_[1]{id}); |
1319
|
|
|
|
|
|
|
}, |
1320
|
|
|
|
|
|
|
{ |
1321
|
|
|
|
|
|
|
id=>$gui{id}, |
1322
|
|
|
|
|
|
|
self=>$self, |
1323
|
|
|
|
|
|
|
} |
1324
|
|
|
|
|
|
|
); |
1325
|
|
|
|
|
|
|
$gui{menu}->append($gui{menuModify}); |
1326
|
|
|
|
|
|
|
#remove |
1327
|
|
|
|
|
|
|
$gui{menuRemove}=Gtk2::MenuItem->new('_remove'); |
1328
|
|
|
|
|
|
|
$gui{menuRemove}->show; |
1329
|
|
|
|
|
|
|
$gui{menuRemove}->signal_connect(activate=>sub{ |
1330
|
|
|
|
|
|
|
$_[1]{self}->removeFeedDialog($_[1]{id}); |
1331
|
|
|
|
|
|
|
}, |
1332
|
|
|
|
|
|
|
{ |
1333
|
|
|
|
|
|
|
id=>$gui{id}, |
1334
|
|
|
|
|
|
|
self=>$self, |
1335
|
|
|
|
|
|
|
} |
1336
|
|
|
|
|
|
|
); |
1337
|
|
|
|
|
|
|
$gui{menu}->append($gui{menuRemove}); |
1338
|
|
|
|
|
|
|
#manage templates |
1339
|
|
|
|
|
|
|
$gui{menuManage}=Gtk2::MenuItem->new('manage _templates'); |
1340
|
|
|
|
|
|
|
$gui{menuManage}->show; |
1341
|
|
|
|
|
|
|
$gui{menuManage}->signal_connect(activate=>sub{ |
1342
|
|
|
|
|
|
|
my $guiID=$_[1]{self}->manageWindow({disableQuit=>1}); |
1343
|
|
|
|
|
|
|
$_[1]{self}->{gui}{ $guiID }{window}->show; |
1344
|
|
|
|
|
|
|
}, |
1345
|
|
|
|
|
|
|
{ |
1346
|
|
|
|
|
|
|
id=>$gui{id}, |
1347
|
|
|
|
|
|
|
self=>$self, |
1348
|
|
|
|
|
|
|
} |
1349
|
|
|
|
|
|
|
); |
1350
|
|
|
|
|
|
|
$gui{menu}->append($gui{menuManage}); |
1351
|
|
|
|
|
|
|
#quit |
1352
|
|
|
|
|
|
|
if (!$args{disableQuit}) { |
1353
|
|
|
|
|
|
|
$gui{menuQuit}=Gtk2::MenuItem->new('_quit'); |
1354
|
|
|
|
|
|
|
$gui{menuQuit}->show; |
1355
|
|
|
|
|
|
|
$gui{menuQuit}->signal_connect(activate=>sub{ |
1356
|
|
|
|
|
|
|
Gtk2->main_quit; |
1357
|
|
|
|
|
|
|
}, |
1358
|
|
|
|
|
|
|
{ |
1359
|
|
|
|
|
|
|
id=>$gui{id}, |
1360
|
|
|
|
|
|
|
self=>$self, |
1361
|
|
|
|
|
|
|
} |
1362
|
|
|
|
|
|
|
); |
1363
|
|
|
|
|
|
|
$gui{menu}->append($gui{menuQuit}); |
1364
|
|
|
|
|
|
|
} |
1365
|
|
|
|
|
|
|
#attaches it |
1366
|
|
|
|
|
|
|
$gui{menubarmenu}->set_submenu($gui{menu}); |
1367
|
|
|
|
|
|
|
|
1368
|
|
|
|
|
|
|
#puts together the view section |
1369
|
|
|
|
|
|
|
$gui{text}=Gtk2::TextView->new; |
1370
|
|
|
|
|
|
|
$gui{text}->show; |
1371
|
|
|
|
|
|
|
$gui{text}->set_editable(0); |
1372
|
|
|
|
|
|
|
$gui{textSW}=Gtk2::ScrolledWindow->new; |
1373
|
|
|
|
|
|
|
$gui{textSW}->show; |
1374
|
|
|
|
|
|
|
$gui{textSW}->add($gui{text}); |
1375
|
|
|
|
|
|
|
$gui{hpaned}->add2($gui{textSW}); |
1376
|
|
|
|
|
|
|
$gui{buffer}=Gtk2::TextBuffer->new; |
1377
|
|
|
|
|
|
|
$gui{buffer}->set_text(''); |
1378
|
|
|
|
|
|
|
$gui{text}->set_buffer($gui{buffer}); |
1379
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
$self->{gui}{ $gui{id} }=\%gui; |
1381
|
|
|
|
|
|
|
|
1382
|
|
|
|
|
|
|
#this updates it |
1383
|
|
|
|
|
|
|
$self->updateFeedList($gui{id}); |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
return $gui{id}; |
1386
|
|
|
|
|
|
|
} |
1387
|
|
|
|
|
|
|
|
1388
|
|
|
|
|
|
|
=head2 viewWindow |
1389
|
|
|
|
|
|
|
|
1390
|
|
|
|
|
|
|
This generates the view window. |
1391
|
|
|
|
|
|
|
|
1392
|
|
|
|
|
|
|
=head3 args hash |
1393
|
|
|
|
|
|
|
|
1394
|
|
|
|
|
|
|
=head4 disableQuit |
1395
|
|
|
|
|
|
|
|
1396
|
|
|
|
|
|
|
Do not show the quit selection the menu. |
1397
|
|
|
|
|
|
|
|
1398
|
|
|
|
|
|
|
=head4 quitOnClose |
1399
|
|
|
|
|
|
|
|
1400
|
|
|
|
|
|
|
If the window is closed, quit the main GTK loop. |
1401
|
|
|
|
|
|
|
|
1402
|
|
|
|
|
|
|
=head4 removeOnClose |
1403
|
|
|
|
|
|
|
|
1404
|
|
|
|
|
|
|
Removes the GUI upon close. |
1405
|
|
|
|
|
|
|
|
1406
|
|
|
|
|
|
|
Gtk2->init; |
1407
|
|
|
|
|
|
|
my $guiID=$zcrssgtk->viewWindow; |
1408
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
1409
|
|
|
|
|
|
|
print "Error!\n"; |
1410
|
|
|
|
|
|
|
}else{ |
1411
|
|
|
|
|
|
|
$zcrssgtk->{gui}{$guiID}{window}->show; |
1412
|
|
|
|
|
|
|
$Gtk2->main; |
1413
|
|
|
|
|
|
|
} |
1414
|
|
|
|
|
|
|
|
1415
|
|
|
|
|
|
|
=cut |
1416
|
|
|
|
|
|
|
|
1417
|
|
|
|
|
|
|
sub viewWindow{ |
1418
|
|
|
|
|
|
|
my $self=$_[0]; |
1419
|
|
|
|
|
|
|
my %args; |
1420
|
|
|
|
|
|
|
if(defined($_[1])){ |
1421
|
|
|
|
|
|
|
%args= %{$_[1]}; |
1422
|
|
|
|
|
|
|
} |
1423
|
|
|
|
|
|
|
my $function='viewWindow'; |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
$self->errorblank; |
1426
|
|
|
|
|
|
|
if ($self->{error}) { |
1427
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1428
|
|
|
|
|
|
|
return undef; |
1429
|
|
|
|
|
|
|
} |
1430
|
|
|
|
|
|
|
|
1431
|
|
|
|
|
|
|
my $guiID=$self->viewVBox({disableQuit=>$args{disableQuit}}); |
1432
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}=Gtk2::Window->new; |
1434
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->set_default_size(750, 400); |
1435
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->set_title('ZConf::RSS'); |
1436
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->add($self->{gui}{$guiID}{vbox}); |
1437
|
|
|
|
|
|
|
|
1438
|
|
|
|
|
|
|
#handles the closure stuff |
1439
|
|
|
|
|
|
|
if ($args{quitOnClose}) { |
1440
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->signal_connect(delete_event=>sub{ |
1441
|
|
|
|
|
|
|
Gtk2->main_quit; |
1442
|
|
|
|
|
|
|
} |
1443
|
|
|
|
|
|
|
); |
1444
|
|
|
|
|
|
|
} |
1445
|
|
|
|
|
|
|
if ($args{quitOnClose}) { |
1446
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{window}->signal_connect(delete_event=>sub{ |
1447
|
|
|
|
|
|
|
delete($self->{gui}{ $guiID }); |
1448
|
|
|
|
|
|
|
} |
1449
|
|
|
|
|
|
|
); |
1450
|
|
|
|
|
|
|
} |
1451
|
|
|
|
|
|
|
|
1452
|
|
|
|
|
|
|
return $guiID; |
1453
|
|
|
|
|
|
|
} |
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
=head2 updateFeed |
1456
|
|
|
|
|
|
|
|
1457
|
|
|
|
|
|
|
This updates the updates the feed view. |
1458
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
$zcrssgtk->updateFeed($guiID); |
1460
|
|
|
|
|
|
|
|
1461
|
|
|
|
|
|
|
=cut |
1462
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
sub updateFeed{ |
1464
|
|
|
|
|
|
|
my $self=$_[0]; |
1465
|
|
|
|
|
|
|
my $guiID=$_[1]; |
1466
|
|
|
|
|
|
|
my $function='updateFeed'; |
1467
|
|
|
|
|
|
|
|
1468
|
|
|
|
|
|
|
$self->errorblank; |
1469
|
|
|
|
|
|
|
if ($self->{error}) { |
1470
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1471
|
|
|
|
|
|
|
return undef; |
1472
|
|
|
|
|
|
|
} |
1473
|
|
|
|
|
|
|
|
1474
|
|
|
|
|
|
|
my @selected=$self->{gui}{ $guiID }{feedlist}->get_selected_indices; |
1475
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
if(!defined($selected[0])){ |
1477
|
|
|
|
|
|
|
return undef; |
1478
|
|
|
|
|
|
|
} |
1479
|
|
|
|
|
|
|
|
1480
|
|
|
|
|
|
|
my $feed=$self->{feeds}[$selected[0]]; |
1481
|
|
|
|
|
|
|
|
1482
|
|
|
|
|
|
|
my $feedString=$self->{obj}->getFeedAsTemplatedString($feed); |
1483
|
|
|
|
|
|
|
|
1484
|
|
|
|
|
|
|
if (!defined($feedString)) { |
1485
|
|
|
|
|
|
|
return undef; |
1486
|
|
|
|
|
|
|
} |
1487
|
|
|
|
|
|
|
|
1488
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{buffer}->set_text($feedString); |
1489
|
|
|
|
|
|
|
|
1490
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{text}->set_buffer($self->{gui}{ $guiID }{buffer}); |
1491
|
|
|
|
|
|
|
|
1492
|
|
|
|
|
|
|
return 1; |
1493
|
|
|
|
|
|
|
} |
1494
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
=head2 updateFeedList |
1496
|
|
|
|
|
|
|
|
1497
|
|
|
|
|
|
|
This updates the feed list. |
1498
|
|
|
|
|
|
|
|
1499
|
|
|
|
|
|
|
$zcrssgtk->updateFeed($guiID); |
1500
|
|
|
|
|
|
|
|
1501
|
|
|
|
|
|
|
=cut |
1502
|
|
|
|
|
|
|
|
1503
|
|
|
|
|
|
|
sub updateFeedList{ |
1504
|
|
|
|
|
|
|
my $self=$_[0]; |
1505
|
|
|
|
|
|
|
my $guiID=$_[1]; |
1506
|
|
|
|
|
|
|
my $function='updateFeedList'; |
1507
|
|
|
|
|
|
|
|
1508
|
|
|
|
|
|
|
$self->errorblank; |
1509
|
|
|
|
|
|
|
if ($self->{error}) { |
1510
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1511
|
|
|
|
|
|
|
return undef; |
1512
|
|
|
|
|
|
|
} |
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
#get the feeds and sort them |
1515
|
|
|
|
|
|
|
my @feeds=$self->{obj}->listFeeds(); |
1516
|
|
|
|
|
|
|
@feeds=sort(@feeds); |
1517
|
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
#make save it for later easy recall |
1519
|
|
|
|
|
|
|
$self->{feeds}=\@feeds; |
1520
|
|
|
|
|
|
|
|
1521
|
|
|
|
|
|
|
#puts it together |
1522
|
|
|
|
|
|
|
my @int=0; |
1523
|
|
|
|
|
|
|
|
1524
|
|
|
|
|
|
|
@{$self->{gui}{ $guiID }{feedlist}->{data}}=@feeds; |
1525
|
|
|
|
|
|
|
|
1526
|
|
|
|
|
|
|
return 1; |
1527
|
|
|
|
|
|
|
} |
1528
|
|
|
|
|
|
|
|
1529
|
|
|
|
|
|
|
=head2 updateTemplateList |
1530
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
This updates the template list for a manage window. |
1532
|
|
|
|
|
|
|
|
1533
|
|
|
|
|
|
|
One arguement is required and it is a GUI ID for the manage window in question. |
1534
|
|
|
|
|
|
|
|
1535
|
|
|
|
|
|
|
$zcrssgtk->updateTemplateList($guiID); |
1536
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
1537
|
|
|
|
|
|
|
print "Error!\n"; |
1538
|
|
|
|
|
|
|
} |
1539
|
|
|
|
|
|
|
|
1540
|
|
|
|
|
|
|
=cut |
1541
|
|
|
|
|
|
|
|
1542
|
|
|
|
|
|
|
sub updateTemplateList{ |
1543
|
|
|
|
|
|
|
my $self=$_[0]; |
1544
|
|
|
|
|
|
|
my $guiID=$_[1]; |
1545
|
|
|
|
|
|
|
my $function='updateFeedList'; |
1546
|
|
|
|
|
|
|
|
1547
|
|
|
|
|
|
|
$self->errorblank; |
1548
|
|
|
|
|
|
|
if ($self->{error}) { |
1549
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1550
|
|
|
|
|
|
|
return undef; |
1551
|
|
|
|
|
|
|
} |
1552
|
|
|
|
|
|
|
|
1553
|
|
|
|
|
|
|
#get the feeds and sort them |
1554
|
|
|
|
|
|
|
my @templates=$self->{obj}->listTemplates(); |
1555
|
|
|
|
|
|
|
@templates=sort(@templates); |
1556
|
|
|
|
|
|
|
|
1557
|
|
|
|
|
|
|
#make save it for later easy recall |
1558
|
|
|
|
|
|
|
$self->{templates}=\@templates; |
1559
|
|
|
|
|
|
|
|
1560
|
|
|
|
|
|
|
#puts it together |
1561
|
|
|
|
|
|
|
my @int=0; |
1562
|
|
|
|
|
|
|
|
1563
|
|
|
|
|
|
|
@{$self->{gui}{ $guiID }{templatelist}->{data}}=@templates; |
1564
|
|
|
|
|
|
|
|
1565
|
|
|
|
|
|
|
return 1; |
1566
|
|
|
|
|
|
|
} |
1567
|
|
|
|
|
|
|
|
1568
|
|
|
|
|
|
|
=head2 updateTemplateText |
1569
|
|
|
|
|
|
|
|
1570
|
|
|
|
|
|
|
This updates template text for the specified GUI ID. |
1571
|
|
|
|
|
|
|
|
1572
|
|
|
|
|
|
|
$zcrssgtl->updateTemplateText($guiID); |
1573
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
1574
|
|
|
|
|
|
|
print "Error!\n"; |
1575
|
|
|
|
|
|
|
} |
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
=cut |
1578
|
|
|
|
|
|
|
|
1579
|
|
|
|
|
|
|
sub updateTemplateText{ |
1580
|
|
|
|
|
|
|
my $self=$_[0]; |
1581
|
|
|
|
|
|
|
my $guiID=$_[1]; |
1582
|
|
|
|
|
|
|
|
1583
|
|
|
|
|
|
|
my @selected=$self->{gui}{ $guiID }{templatelist}->get_selected_indices; |
1584
|
|
|
|
|
|
|
|
1585
|
|
|
|
|
|
|
if(!defined($selected[0])){ |
1586
|
|
|
|
|
|
|
return undef; |
1587
|
|
|
|
|
|
|
} |
1588
|
|
|
|
|
|
|
|
1589
|
|
|
|
|
|
|
my $template=$self->{templates}[$selected[0]]; |
1590
|
|
|
|
|
|
|
|
1591
|
|
|
|
|
|
|
my $templateText=$self->{obj}->getTemplate($template); |
1592
|
|
|
|
|
|
|
|
1593
|
|
|
|
|
|
|
if (!defined($templateText)) { |
1594
|
|
|
|
|
|
|
return undef; |
1595
|
|
|
|
|
|
|
} |
1596
|
|
|
|
|
|
|
|
1597
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{buffer}->set_text($templateText); |
1598
|
|
|
|
|
|
|
|
1599
|
|
|
|
|
|
|
$self->{gui}{ $guiID }{text}->set_buffer($self->{gui}{ $guiID }{buffer}); |
1600
|
|
|
|
|
|
|
|
1601
|
|
|
|
|
|
|
} |
1602
|
|
|
|
|
|
|
|
1603
|
|
|
|
|
|
|
=head2 dialogs |
1604
|
|
|
|
|
|
|
|
1605
|
|
|
|
|
|
|
This returns a array of available dialogs. |
1606
|
|
|
|
|
|
|
|
1607
|
|
|
|
|
|
|
my @dialogs=$zcrssgtk->dialogs; |
1608
|
|
|
|
|
|
|
if($zcrssgtk->{error}){ |
1609
|
|
|
|
|
|
|
print "Error!\n"; |
1610
|
|
|
|
|
|
|
} |
1611
|
|
|
|
|
|
|
|
1612
|
|
|
|
|
|
|
=cut |
1613
|
|
|
|
|
|
|
|
1614
|
|
|
|
|
|
|
sub dialogs{ |
1615
|
|
|
|
|
|
|
my $self=$_[0]; |
1616
|
|
|
|
|
|
|
my $function='dialogs'; |
1617
|
|
|
|
|
|
|
|
1618
|
|
|
|
|
|
|
$self->errorblank; |
1619
|
|
|
|
|
|
|
if ($self->{error}) { |
1620
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1621
|
|
|
|
|
|
|
return undef; |
1622
|
|
|
|
|
|
|
} |
1623
|
|
|
|
|
|
|
|
1624
|
|
|
|
|
|
|
return ('addFeed'); |
1625
|
|
|
|
|
|
|
} |
1626
|
|
|
|
|
|
|
|
1627
|
|
|
|
|
|
|
=head2 windows |
1628
|
|
|
|
|
|
|
|
1629
|
|
|
|
|
|
|
This returns a array of available dialogs. |
1630
|
|
|
|
|
|
|
|
1631
|
|
|
|
|
|
|
my @windows=$zcrssGui->windows; |
1632
|
|
|
|
|
|
|
if($zcrssGui->{error}){ |
1633
|
|
|
|
|
|
|
print "Error!\n"; |
1634
|
|
|
|
|
|
|
} |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
=cut |
1637
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
sub windows{ |
1639
|
|
|
|
|
|
|
my $self=$_[0]; |
1640
|
|
|
|
|
|
|
my $function='windows'; |
1641
|
|
|
|
|
|
|
|
1642
|
|
|
|
|
|
|
$self->errorblank; |
1643
|
|
|
|
|
|
|
if ($self->{error}) { |
1644
|
|
|
|
|
|
|
warn($self->{module}.' '.$function.': A permanent error is set. error="'.$self->{error}.'" errorString="'.$self->{errorString}.'"'); |
1645
|
|
|
|
|
|
|
return undef; |
1646
|
|
|
|
|
|
|
} |
1647
|
|
|
|
|
|
|
|
1648
|
|
|
|
|
|
|
return ('view', 'manage'); |
1649
|
|
|
|
|
|
|
} |
1650
|
|
|
|
|
|
|
|
1651
|
|
|
|
|
|
|
=head2 errorblank |
1652
|
|
|
|
|
|
|
|
1653
|
|
|
|
|
|
|
This blanks the error storage and is only meant for internal usage. |
1654
|
|
|
|
|
|
|
|
1655
|
|
|
|
|
|
|
It does the following. |
1656
|
|
|
|
|
|
|
|
1657
|
|
|
|
|
|
|
$self->{error}=undef; |
1658
|
|
|
|
|
|
|
$self->{errorString}=""; |
1659
|
|
|
|
|
|
|
|
1660
|
|
|
|
|
|
|
=cut |
1661
|
|
|
|
|
|
|
|
1662
|
|
|
|
|
|
|
#blanks the error flags |
1663
|
|
|
|
|
|
|
sub errorblank{ |
1664
|
|
|
|
|
|
|
my $self=$_[0]; |
1665
|
|
|
|
|
|
|
|
1666
|
|
|
|
|
|
|
if ($self->{perror}) { |
1667
|
|
|
|
|
|
|
warn('ZConf-DevTemplate errorblank: A permanent error is set'); |
1668
|
|
|
|
|
|
|
return undef; |
1669
|
|
|
|
|
|
|
} |
1670
|
|
|
|
|
|
|
|
1671
|
|
|
|
|
|
|
$self->{error}=undef; |
1672
|
|
|
|
|
|
|
$self->{errorString}=""; |
1673
|
|
|
|
|
|
|
|
1674
|
|
|
|
|
|
|
return 1; |
1675
|
|
|
|
|
|
|
} |
1676
|
|
|
|
|
|
|
|
1677
|
|
|
|
|
|
|
=head1 ERROR CODES |
1678
|
|
|
|
|
|
|
|
1679
|
|
|
|
|
|
|
=head2 1 |
1680
|
|
|
|
|
|
|
|
1681
|
|
|
|
|
|
|
Failed to initiate ZConf::RSS. |
1682
|
|
|
|
|
|
|
|
1683
|
|
|
|
|
|
|
=head2 2 |
1684
|
|
|
|
|
|
|
|
1685
|
|
|
|
|
|
|
Failed to initiate ZConf::GUI. |
1686
|
|
|
|
|
|
|
|
1687
|
|
|
|
|
|
|
=head2 3 |
1688
|
|
|
|
|
|
|
|
1689
|
|
|
|
|
|
|
Adding the new feed failed. |
1690
|
|
|
|
|
|
|
|
1691
|
|
|
|
|
|
|
=head2 4 |
1692
|
|
|
|
|
|
|
|
1693
|
|
|
|
|
|
|
No GUI ID specified. |
1694
|
|
|
|
|
|
|
|
1695
|
|
|
|
|
|
|
=head2 5 |
1696
|
|
|
|
|
|
|
|
1697
|
|
|
|
|
|
|
Backend errored. |
1698
|
|
|
|
|
|
|
|
1699
|
|
|
|
|
|
|
=head2 6 |
1700
|
|
|
|
|
|
|
|
1701
|
|
|
|
|
|
|
Removing the old feed for the purpose of renaming it failed. |
1702
|
|
|
|
|
|
|
|
1703
|
|
|
|
|
|
|
=head1 WINDOWS |
1704
|
|
|
|
|
|
|
|
1705
|
|
|
|
|
|
|
Please not that unless working directly and specifically with a backend, windows and dialogs |
1706
|
|
|
|
|
|
|
are effectively the same in that they don't return until the window exits, generally. |
1707
|
|
|
|
|
|
|
|
1708
|
|
|
|
|
|
|
=head2 add |
1709
|
|
|
|
|
|
|
|
1710
|
|
|
|
|
|
|
This adds a new a new feed. |
1711
|
|
|
|
|
|
|
|
1712
|
|
|
|
|
|
|
=head2 manage |
1713
|
|
|
|
|
|
|
|
1714
|
|
|
|
|
|
|
This allows the RSS feeds to be managed along with the templates. |
1715
|
|
|
|
|
|
|
|
1716
|
|
|
|
|
|
|
=head2 view |
1717
|
|
|
|
|
|
|
|
1718
|
|
|
|
|
|
|
This allows the RSS feeds to be viewed. |
1719
|
|
|
|
|
|
|
|
1720
|
|
|
|
|
|
|
=head1 AUTHOR |
1721
|
|
|
|
|
|
|
|
1722
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
1723
|
|
|
|
|
|
|
|
1724
|
|
|
|
|
|
|
=head1 BUGS |
1725
|
|
|
|
|
|
|
|
1726
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
1727
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
1728
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
1729
|
|
|
|
|
|
|
|
1730
|
|
|
|
|
|
|
|
1731
|
|
|
|
|
|
|
|
1732
|
|
|
|
|
|
|
|
1733
|
|
|
|
|
|
|
=head1 SUPPORT |
1734
|
|
|
|
|
|
|
|
1735
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
1736
|
|
|
|
|
|
|
|
1737
|
|
|
|
|
|
|
perldoc ZConf::RSS::GUI |
1738
|
|
|
|
|
|
|
|
1739
|
|
|
|
|
|
|
|
1740
|
|
|
|
|
|
|
You can also look for information at: |
1741
|
|
|
|
|
|
|
|
1742
|
|
|
|
|
|
|
=over 4 |
1743
|
|
|
|
|
|
|
|
1744
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
1745
|
|
|
|
|
|
|
|
1746
|
|
|
|
|
|
|
L |
1747
|
|
|
|
|
|
|
|
1748
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
1749
|
|
|
|
|
|
|
|
1750
|
|
|
|
|
|
|
L |
1751
|
|
|
|
|
|
|
|
1752
|
|
|
|
|
|
|
=item * CPAN Ratings |
1753
|
|
|
|
|
|
|
|
1754
|
|
|
|
|
|
|
L |
1755
|
|
|
|
|
|
|
|
1756
|
|
|
|
|
|
|
=item * Search CPAN |
1757
|
|
|
|
|
|
|
|
1758
|
|
|
|
|
|
|
L |
1759
|
|
|
|
|
|
|
|
1760
|
|
|
|
|
|
|
=back |
1761
|
|
|
|
|
|
|
|
1762
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
1763
|
|
|
|
|
|
|
|
1764
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
1765
|
|
|
|
|
|
|
|
1766
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
1767
|
|
|
|
|
|
|
under the same terms as Perl itself. |
1768
|
|
|
|
|
|
|
|
1769
|
|
|
|
|
|
|
|
1770
|
|
|
|
|
|
|
=cut |
1771
|
|
|
|
|
|
|
|
1772
|
|
|
|
|
|
|
1; # End of ZConf::RSS::GUI |