line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gtk2::ImageView::Browser; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21639
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
349
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Gtk2::ImageView; |
7
|
|
|
|
|
|
|
use Gtk2::Ex::Simple::List; |
8
|
|
|
|
|
|
|
use File::MimeInfo::Magic; |
9
|
|
|
|
|
|
|
use Gtk2::Gdk::Keysyms; |
10
|
|
|
|
|
|
|
use Cwd ('abs_path', 'getcwd'); |
11
|
|
|
|
|
|
|
use Image::Size; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Gtk2::ImageView::Browser - A image browser and widget based off of 'Gtk2::ImageView' |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.0.0 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.0.0'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Gtk2::ImageView::Browser; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $ivb = Gtk2::ImageView::Browser->new(); |
31
|
|
|
|
|
|
|
... |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 METHODES |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 new |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $ivb = = Gtk2::ImageView::Browser->new(); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
42
|
|
|
|
|
|
|
my $self={error=>undef, errorString=>undef, widgets=>{}, dotfiles=>0, |
43
|
|
|
|
|
|
|
zoom=>'w'}; |
44
|
|
|
|
|
|
|
bless $self; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 dirchanged |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
A internal function that is called when a directory is double clicked on. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub dirchanged{ |
56
|
|
|
|
|
|
|
my ($sl, $path, $column, $self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my @sel = $sl->get_selected_indices; |
59
|
|
|
|
|
|
|
my $dir=$sl->{data}[$sel[0]][0]; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#sets the directory |
62
|
|
|
|
|
|
|
$self->{dir}=$self->{dir}.'/'.$dir; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#set it to the absolute path |
65
|
|
|
|
|
|
|
$self->{dir}=abs_path($self->{dir}); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$self->setdir($self->{dir}); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 dotfiles |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Determines if it should show files matching /^./ or not. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
If a arguement is given, it will set it to that. The value |
75
|
|
|
|
|
|
|
is a perl boolean. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
With out an arguement, it gets the current setting. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
When the object is originally created, this defaults to 0. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#don't displat dot files |
82
|
|
|
|
|
|
|
$ivb->dotfiles(0); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#displat dot files |
85
|
|
|
|
|
|
|
$ivb->dotfiles(0); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $dotfiles=$ivb->dotfiles(); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub dotfiles{ |
92
|
|
|
|
|
|
|
my $self=$_[0]; |
93
|
|
|
|
|
|
|
my $dotfiles=$_[1]; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
if (defined($dotfiles)) { |
96
|
|
|
|
|
|
|
$self->{dotfiles}=$dotfiles |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
return $self->{dotfiles}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 filechangedA |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
A internal function that is called when a file is double clicked on. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub filechangedA{ |
109
|
|
|
|
|
|
|
my ($sl, $path, $column, $self) = @_; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my @sel = $sl->get_selected_indices; |
112
|
|
|
|
|
|
|
my $file=$sl->{data}[$sel[0]][0]; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$self->{file}=$self->{dir}.'/'.$file; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$self->{widgets}{pixbuf}=Gtk2::Gdk::Pixbuf->new_from_file($self->{file}); |
117
|
|
|
|
|
|
|
$self->{widgets}{view}->set_pixbuf($self->{widgets}{pixbuf}, 1); |
118
|
|
|
|
|
|
|
$self->zoomset; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 filechangedC |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
A internal function that is called when a file selection is changed. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub filechangedC{ |
128
|
|
|
|
|
|
|
my ($sl, $self) = @_; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my @sel = $sl->get_selected_indices; |
131
|
|
|
|
|
|
|
my $file=$sl->{data}[$sel[0]][0]; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
$self->{file}=$self->{dir}.'/'.$file; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$self->{widgets}{pixbuf}=Gtk2::Gdk::Pixbuf->new_from_file($self->{file}); |
136
|
|
|
|
|
|
|
$self->{widgets}{view}->set_pixbuf($self->{widgets}{pixbuf}, 1); |
137
|
|
|
|
|
|
|
$self->zoomset; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 fullscreen |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Minimizes the sidebar, by setting HPaned to a |
143
|
|
|
|
|
|
|
position of 1. If the position of the the HPaned |
144
|
|
|
|
|
|
|
is greater than 1, it sets it to 1, else it sets |
145
|
|
|
|
|
|
|
it to a position of 230. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
$ivb->fullscreen; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub fullscreen{ |
152
|
|
|
|
|
|
|
my $self=$_[0]; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $pos=$self->{widgets}{hpaned}->get_position; |
155
|
|
|
|
|
|
|
print "test\n"; |
156
|
|
|
|
|
|
|
if ($pos > 1) { |
157
|
|
|
|
|
|
|
$self->{widgets}{hpaned}->set_position(1); |
158
|
|
|
|
|
|
|
}else { |
159
|
|
|
|
|
|
|
$self->{widgets}{hpaned}->set_position(230); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 fullscreenA |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Called by the 'f' button. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub fullscreenA{ |
170
|
|
|
|
|
|
|
my $widget=$_[0]; |
171
|
|
|
|
|
|
|
my $self=$_[1]; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$self->fullscreen; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 next |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This causes it to move to the next image. If there is no |
179
|
|
|
|
|
|
|
next image, it goes back to the first one. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
$ivb->next; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub next{ |
186
|
|
|
|
|
|
|
my $self=$_[0]; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my @sel = $self->{widgets}{files}->get_selected_indices; |
189
|
|
|
|
|
|
|
my $index=$sel[0] + 1; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
#go back to the beginning when we reach the end... |
192
|
|
|
|
|
|
|
if (!defined($self->{widgets}{files}->{data}[$index])) { |
193
|
|
|
|
|
|
|
$index=0; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
$self->{widgets}{files}->select($index); |
197
|
|
|
|
|
|
|
my $file=$self->{widgets}{files}->{data}[$index][0]; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
$self->{file}=$self->{dir}.'/'.$file; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
$self->{widgets}{pixbuf}=Gtk2::Gdk::Pixbuf->new_from_file($self->{file}); |
202
|
|
|
|
|
|
|
$self->{widgets}{view}->set_pixbuf($self->{widgets}{pixbuf}, 1); |
203
|
|
|
|
|
|
|
$self->zoomset; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 nextA |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
This is called by the 'n' button. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub nextA{ |
213
|
|
|
|
|
|
|
my $widget=$_[0]; |
214
|
|
|
|
|
|
|
my $self=$_[1]; |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
$self->next; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 resize |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This is called by various things when it is resized. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=cut |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub resize{ |
226
|
|
|
|
|
|
|
my $widget=$_[0]; |
227
|
|
|
|
|
|
|
my $self=$_[1]; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
$self->zoomset; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 run |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
This calls invokes the windows methode and runs it. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
#starts it in the current directory |
237
|
|
|
|
|
|
|
my $ivb->run; |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
#starts it in a different directory |
240
|
|
|
|
|
|
|
my $ivb->run('/arc/pics'); |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=cut |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub run{ |
245
|
|
|
|
|
|
|
my $self=$_[0]; |
246
|
|
|
|
|
|
|
my $dir=$_[1]; |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
$self->errorblank; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Gtk2->init; |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
my $window=$self->window($dir); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
$window->signal_connect('delete-event'=>\&quit); |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Gtk2->main; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head2 prev |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
This causes it to move to the previous image. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
$ivb->prev; |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub prev{ |
268
|
|
|
|
|
|
|
my $self=$_[0]; |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
my @sel = $self->{widgets}{files}->get_selected_indices; |
271
|
|
|
|
|
|
|
my $index=$sel[0] - 1; |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
#go back to the beginning when we reach the end... |
274
|
|
|
|
|
|
|
if (!defined($self->{widgets}{files}->{data}[$index])) { |
275
|
|
|
|
|
|
|
$index=$#{$self->{widgets}{files}->{data}}; |
276
|
|
|
|
|
|
|
$index--; |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
$self->{widgets}{files}->select($index); |
280
|
|
|
|
|
|
|
my $file=$self->{widgets}{files}->{data}[$index][0]; |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# print $#{$self->{widgets}{files}->{data}}."\n"; |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
$self->{file}=$self->{dir}.'/'.$file; |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
$self->{widgets}{pixbuf}=Gtk2::Gdk::Pixbuf->new_from_file($self->{file}); |
287
|
|
|
|
|
|
|
$self->{widgets}{view}->set_pixbuf($self->{widgets}{pixbuf}, 1); |
288
|
|
|
|
|
|
|
$self->zoomset; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head2 prevA |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
This is called by the 'p' button. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=cut |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub prevA{ |
298
|
|
|
|
|
|
|
my $widget=$_[0]; |
299
|
|
|
|
|
|
|
my $self=$_[1]; |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
$self->prev; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=head2 setdir |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
This sets the directory to the specified one. |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
$ivb->setdir('/arc/pics'); |
309
|
|
|
|
|
|
|
if($self->{error}){ |
310
|
|
|
|
|
|
|
print "Error!\n"; |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=cut |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub setdir{ |
316
|
|
|
|
|
|
|
my $self=$_[0]; |
317
|
|
|
|
|
|
|
my $dir=$_[1]; |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
$self->errorblank; |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
if (!-d $dir) { |
322
|
|
|
|
|
|
|
warn('Gtk2-ImageView-Browser setdir:1: The directory "'. |
323
|
|
|
|
|
|
|
$dir.'" does not exist or ist not a directory'); |
324
|
|
|
|
|
|
|
$self->{error}=1; |
325
|
|
|
|
|
|
|
$self->{errorString}='The directory "'.$dir |
326
|
|
|
|
|
|
|
.'" does not exist or ist not a directory'; |
327
|
|
|
|
|
|
|
return undef; |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
#sets the directory |
331
|
|
|
|
|
|
|
$self->{dir}=$dir; |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
$self->{widgets}{direntry}->set_text($self->{dir}); |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
opendir(READDIR, $self->{dir}); |
336
|
|
|
|
|
|
|
my @direntries=readdir(READDIR); |
337
|
|
|
|
|
|
|
closedir(READDIR); |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
if (!$self->{dotfiles}) { |
340
|
|
|
|
|
|
|
@direntries=grep(!/^\./, @direntries); |
341
|
|
|
|
|
|
|
push(@direntries, '..'); |
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
@direntries=sort(@direntries); |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
my @dirs; |
347
|
|
|
|
|
|
|
my @files; |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
my $int=0; |
350
|
|
|
|
|
|
|
while(defined($direntries[$int])) { |
351
|
|
|
|
|
|
|
if (-d $self->{dir}.'/'.$direntries[$int]) { |
352
|
|
|
|
|
|
|
push(@dirs, [$direntries[$int]]); |
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
if (-f $self->{dir}.'/'.$direntries[$int]) { |
355
|
|
|
|
|
|
|
my $type=mimetype($self->{dir}.'/'.$direntries[$int]); |
356
|
|
|
|
|
|
|
if ($type=~/^image\//) { |
357
|
|
|
|
|
|
|
push(@files, [$direntries[$int]]); |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
$int++; |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
@{$self->{widgets}{dirs}->{data}}=@dirs; |
365
|
|
|
|
|
|
|
@{$self->{widgets}{files}->{data}}=@files; |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
if (!defined($files[0][0])) { |
368
|
|
|
|
|
|
|
return undef; |
369
|
|
|
|
|
|
|
} |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
#if we don't set this here, when it becomes unselected |
372
|
|
|
|
|
|
|
#when this is called next and prev will not work |
373
|
|
|
|
|
|
|
$self->{widgets}{files}->select(0); |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
$self->{widgets}{pixbuf}=Gtk2::Gdk::Pixbuf->new_from_file($self->{dir}. |
376
|
|
|
|
|
|
|
'/'.$files[0][0]); |
377
|
|
|
|
|
|
|
$self->{widgets}{view}->set_pixbuf($self->{widgets}{pixbuf}, 1); |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
$self->zoomset; |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
return 1; |
382
|
|
|
|
|
|
|
} |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=head2 quit |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
This is called by the window created by run when it is closed. |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=cut |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
sub quit{ |
391
|
|
|
|
|
|
|
exit 0; |
392
|
|
|
|
|
|
|
} |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=head2 widget |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
This returns the widget that contains it all. |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
If this is called manually, you will need to add the accel stuff |
399
|
|
|
|
|
|
|
to the windows you use for the hot keys to work. |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
#starts it in the current directory |
402
|
|
|
|
|
|
|
my $widget=$ivb->widget(); |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
#starts it in '/arc/pics' |
405
|
|
|
|
|
|
|
my $widget=$ivb->widget('/arc/pics'); |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
#adds the accel stuff to the window for the hot keys to work. |
408
|
|
|
|
|
|
|
$window->add($ivb->{widget}); |
409
|
|
|
|
|
|
|
$window->add_accel_group($ivb->{widgets}{accels}); |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=cut |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
sub widget{ |
414
|
|
|
|
|
|
|
my $self=$_[0]; |
415
|
|
|
|
|
|
|
my $dir=$_[1]; |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
$self->errorblank; |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
if (!defined($dir)) { |
420
|
|
|
|
|
|
|
$dir=getcwd; |
421
|
|
|
|
|
|
|
} |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
my $file; |
424
|
|
|
|
|
|
|
if (-f $dir) { |
425
|
|
|
|
|
|
|
$file=$dir; |
426
|
|
|
|
|
|
|
my $int=1; |
427
|
|
|
|
|
|
|
my @ds=split(/\//, $dir); |
428
|
|
|
|
|
|
|
$dir=''; |
429
|
|
|
|
|
|
|
while ($int < $#ds) { |
430
|
|
|
|
|
|
|
$dir=$dir.'/'.$ds[$int]; |
431
|
|
|
|
|
|
|
$int++; |
432
|
|
|
|
|
|
|
} |
433
|
|
|
|
|
|
|
} |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
if (! -d $dir ) { |
436
|
|
|
|
|
|
|
warn('Gtk2-ImageView-Browser widget:1: The directory "'.$dir.'" does not exist'); |
437
|
|
|
|
|
|
|
$self->{error}=1; |
438
|
|
|
|
|
|
|
$self->{errorString}='The directory "'.$dir.'" does not exist'; |
439
|
|
|
|
|
|
|
return undef; |
440
|
|
|
|
|
|
|
} |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
#save the dir for later use |
443
|
|
|
|
|
|
|
$self->{dir}=$dir; |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
#meh |
446
|
|
|
|
|
|
|
$self->{widgets}{hpaned}=Gtk2::HPaned->new; |
447
|
|
|
|
|
|
|
$self->{widgets}{hpaned}->show; |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
#tip stuff |
450
|
|
|
|
|
|
|
$self->{widgets}{tips}=Gtk2::Tooltips->new; |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
#hot key stuff.. |
453
|
|
|
|
|
|
|
$self->{widgets}{accels}=Gtk2::AccelGroup->new; |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
#this will hold the hpaned and dir entry area |
456
|
|
|
|
|
|
|
$self->{widgets}{vbox}=Gtk2::VBox->new; |
457
|
|
|
|
|
|
|
$self->{widgets}{vbox}->show; |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
#sets up the button hbox |
460
|
|
|
|
|
|
|
$self->{widgets}{bhbox}=Gtk2::HBox->new; |
461
|
|
|
|
|
|
|
$self->{widgets}{bhbox}->show; |
462
|
|
|
|
|
|
|
$self->{widgets}{vbox}->pack_start($self->{widgets}{bhbox}, 0, 0, 0); |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
#sets the zoom button |
465
|
|
|
|
|
|
|
$self->{widgets}{zoombutton}=Gtk2::Button->new(); |
466
|
|
|
|
|
|
|
$self->{widgets}{zoombutton}->show; |
467
|
|
|
|
|
|
|
$self->{widgets}{zoomlabel}=Gtk2::Label->new("z=w"); |
468
|
|
|
|
|
|
|
$self->{widgets}{zoomlabel}->show; |
469
|
|
|
|
|
|
|
$self->{widgets}{zoombutton}->add($self->{widgets}{zoomlabel}); |
470
|
|
|
|
|
|
|
$self->{widgets}{bhbox}->pack_start($self->{widgets}{zoombutton}, 0, 0, 0); |
471
|
|
|
|
|
|
|
$self->{widgets}{zoombutton}->signal_connect("clicked" => \&zoomchange, $self); |
472
|
|
|
|
|
|
|
$self->{widgets}{tips}->set_tip($self->{widgets}{zoombutton}, |
473
|
|
|
|
|
|
|
"change zoom type...\n". |
474
|
|
|
|
|
|
|
"w = zoom to width\n". |
475
|
|
|
|
|
|
|
"f = fit image to window\n". |
476
|
|
|
|
|
|
|
"1 = zoom level set to 1"); |
477
|
|
|
|
|
|
|
$self->{widgets}{zoombutton}->add_accelerator('clicked', $self->{widgets}{accels}, |
478
|
|
|
|
|
|
|
$Gtk2::Gdk::Keysyms{z}, |
479
|
|
|
|
|
|
|
'control-mask', 'visible'); |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
#sets the zoom reset, 'zr', button |
482
|
|
|
|
|
|
|
$self->{widgets}{zrbutton}=Gtk2::Button->new(); |
483
|
|
|
|
|
|
|
$self->{widgets}{zrbutton}->show; |
484
|
|
|
|
|
|
|
$self->{widgets}{zrlabel}=Gtk2::Label->new("zr"); |
485
|
|
|
|
|
|
|
$self->{widgets}{zrlabel}->show; |
486
|
|
|
|
|
|
|
$self->{widgets}{zrbutton}->add($self->{widgets}{zrlabel}); |
487
|
|
|
|
|
|
|
$self->{widgets}{bhbox}->pack_start($self->{widgets}{zrbutton}, 0, 0, 0); |
488
|
|
|
|
|
|
|
$self->{widgets}{zrbutton}->signal_connect("clicked" => \&zoomreset, $self); |
489
|
|
|
|
|
|
|
$self->{widgets}{tips}->set_tip($self->{widgets}{zrbutton}, 'zoom reset'); |
490
|
|
|
|
|
|
|
$self->{widgets}{zrbutton}->add_accelerator('clicked', $self->{widgets}{accels}, |
491
|
|
|
|
|
|
|
$Gtk2::Gdk::Keysyms{r}, |
492
|
|
|
|
|
|
|
'control-mask', 'visible'); |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
#sets the zoom reset, 'n', button |
495
|
|
|
|
|
|
|
$self->{widgets}{nbutton}=Gtk2::Button->new(); |
496
|
|
|
|
|
|
|
$self->{widgets}{nbutton}->show; |
497
|
|
|
|
|
|
|
$self->{widgets}{nlabel}=Gtk2::Label->new("n"); |
498
|
|
|
|
|
|
|
$self->{widgets}{nlabel}->show; |
499
|
|
|
|
|
|
|
$self->{widgets}{nbutton}->add($self->{widgets}{nlabel}); |
500
|
|
|
|
|
|
|
$self->{widgets}{bhbox}->pack_start($self->{widgets}{nbutton}, 0, 0, 0); |
501
|
|
|
|
|
|
|
$self->{widgets}{nbutton}->signal_connect("clicked" => \&nextA, $self); |
502
|
|
|
|
|
|
|
$self->{widgets}{tips}->set_tip($self->{widgets}{nbutton}, 'next'); |
503
|
|
|
|
|
|
|
$self->{widgets}{nbutton}->add_accelerator('clicked', $self->{widgets}{accels}, |
504
|
|
|
|
|
|
|
$Gtk2::Gdk::Keysyms{Down}, |
505
|
|
|
|
|
|
|
'control-mask', 'visible'); |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
#sets the zoom reset, 'p', button |
508
|
|
|
|
|
|
|
$self->{widgets}{pbutton}=Gtk2::Button->new(); |
509
|
|
|
|
|
|
|
$self->{widgets}{pbutton}->show; |
510
|
|
|
|
|
|
|
$self->{widgets}{plabel}=Gtk2::Label->new("p"); |
511
|
|
|
|
|
|
|
$self->{widgets}{plabel}->show; |
512
|
|
|
|
|
|
|
$self->{widgets}{pbutton}->add($self->{widgets}{plabel}); |
513
|
|
|
|
|
|
|
$self->{widgets}{bhbox}->pack_start($self->{widgets}{pbutton}, 0, 0, 0); |
514
|
|
|
|
|
|
|
$self->{widgets}{pbutton}->signal_connect("clicked" => \&prevA, $self); |
515
|
|
|
|
|
|
|
$self->{widgets}{tips}->set_tip($self->{widgets}{pbutton}, 'prev'); |
516
|
|
|
|
|
|
|
$self->{widgets}{pbutton}->add_accelerator('clicked', $self->{widgets}{accels}, |
517
|
|
|
|
|
|
|
$Gtk2::Gdk::Keysyms{Up}, |
518
|
|
|
|
|
|
|
'control-mask', 'visible'); |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
#sets the zoom reset, 'f', button |
521
|
|
|
|
|
|
|
$self->{widgets}{fbutton}=Gtk2::Button->new(); |
522
|
|
|
|
|
|
|
$self->{widgets}{fbutton}->show; |
523
|
|
|
|
|
|
|
$self->{widgets}{flabel}=Gtk2::Label->new("f"); |
524
|
|
|
|
|
|
|
$self->{widgets}{flabel}->show; |
525
|
|
|
|
|
|
|
$self->{widgets}{fbutton}->add($self->{widgets}{flabel}); |
526
|
|
|
|
|
|
|
$self->{widgets}{bhbox}->pack_start($self->{widgets}{fbutton}, 0, 0, 0); |
527
|
|
|
|
|
|
|
$self->{widgets}{fbutton}->signal_connect("clicked" => \&fullscreenA, $self); |
528
|
|
|
|
|
|
|
$self->{widgets}{tips}->set_tip($self->{widgets}{fbutton}, 'fullscreen'); |
529
|
|
|
|
|
|
|
$self->{widgets}{fbutton}->add_accelerator('clicked', $self->{widgets}{accels}, |
530
|
|
|
|
|
|
|
$Gtk2::Gdk::Keysyms{f}, |
531
|
|
|
|
|
|
|
'control-mask', 'visible'); |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
#allows and shows the current directory |
534
|
|
|
|
|
|
|
$self->{widgets}{direntry}=Gtk2::Entry->new; |
535
|
|
|
|
|
|
|
$self->{widgets}{direntry}->show; |
536
|
|
|
|
|
|
|
$self->{widgets}{vbox}->pack_start($self->{widgets}{direntry}, 0, 0, 0); |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
#create and add the image view |
539
|
|
|
|
|
|
|
$self->{widgets}{view}=Gtk2::ImageView->new; |
540
|
|
|
|
|
|
|
$self->{widgets}{view}->show; |
541
|
|
|
|
|
|
|
$self->{widgets}{hpaned}->add2($self->{widgets}{view}); |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
#create and add the hbox that will contain directory and files |
544
|
|
|
|
|
|
|
$self->{widgets}{vpaned}=Gtk2::VPaned->new; |
545
|
|
|
|
|
|
|
$self->{widgets}{vpaned}->show; |
546
|
|
|
|
|
|
|
$self->{widgets}{hpaned}->add1($self->{widgets}{vbox}); |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
#adds the vpaned to the vbox |
549
|
|
|
|
|
|
|
$self->{widgets}{vbox}->pack_start($self->{widgets}{vpaned}, 1, 1, 0); |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
#adds what will hold the directory stuff |
552
|
|
|
|
|
|
|
$self->{widgets}{dirs}=Gtk2::Ex::Simple::List->new('Directories'=>'text'); |
553
|
|
|
|
|
|
|
$self->{widgets}{dirs}->show; |
554
|
|
|
|
|
|
|
$self->{widgets}{dirsscroll}=Gtk2::ScrolledWindow->new; |
555
|
|
|
|
|
|
|
$self->{widgets}{dirsscroll}->show; |
556
|
|
|
|
|
|
|
$self->{widgets}{dirsscroll}->add($self->{widgets}{dirs}); |
557
|
|
|
|
|
|
|
$self->{widgets}{vpaned}->add1($self->{widgets}{dirsscroll}); |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
#adds what will hold the images |
560
|
|
|
|
|
|
|
$self->{widgets}{files}=Gtk2::Ex::Simple::List->new('Images'=>'text'); |
561
|
|
|
|
|
|
|
$self->{widgets}{files}->show; |
562
|
|
|
|
|
|
|
$self->{widgets}{filesscroll}=Gtk2::ScrolledWindow->new; |
563
|
|
|
|
|
|
|
$self->{widgets}{filesscroll}->show; |
564
|
|
|
|
|
|
|
$self->{widgets}{filesscroll}->add($self->{widgets}{files}); |
565
|
|
|
|
|
|
|
$self->{widgets}{vpaned}->add2($self->{widgets}{filesscroll}); |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
#sets the position to something useful for the panned stuff |
568
|
|
|
|
|
|
|
$self->{widgets}{hpaned}->set_position(230); |
569
|
|
|
|
|
|
|
$self->{widgets}{vpaned}->set_position(160); |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
#connect the change signals |
572
|
|
|
|
|
|
|
$self->{widgets}{files}->signal_connect(row_activated =>\&filechangedA, $self); |
573
|
|
|
|
|
|
|
$self->{widgets}{files}->signal_connect('cursor-changed'=>\&filechangedC, $self); |
574
|
|
|
|
|
|
|
$self->{widgets}{dirs}->signal_connect(row_activated =>\&dirchanged, $self); |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
#none of these work... |
577
|
|
|
|
|
|
|
# $self->{widgets}{hpaned}->signal_connect('move-handle'=>\&resize, $self); |
578
|
|
|
|
|
|
|
# $self->{widgets}{hpaned}->signal_connect('toggle-handle-focus'=>\&resize, $self); |
579
|
|
|
|
|
|
|
# $self->{widgets}{hpaned}->signal_connect('accept-position'=>\&resize, $self); |
580
|
|
|
|
|
|
|
# $self->{widgets}{hpaned}->signal_connect('check-resize'=>\&resize, $self); |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
#sets it to the proper directory |
583
|
|
|
|
|
|
|
$self->setdir($self->{dir}); |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
#if there is a file specified, view it... |
586
|
|
|
|
|
|
|
if (defined($file)) { |
587
|
|
|
|
|
|
|
$self->{file}=$file; |
588
|
|
|
|
|
|
|
$self->{widgets}{pixbuf}=Gtk2::Gdk::Pixbuf->new_from_file($file); |
589
|
|
|
|
|
|
|
$self->{widgets}{view}->set_pixbuf($self->{widgets}{pixbuf}, 1); |
590
|
|
|
|
|
|
|
} |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
return $self->{widgets}{hpaned}; |
593
|
|
|
|
|
|
|
} |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=head2 window |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
This retuns a window with the widget in it. |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
#starts it in the current direcotry |
600
|
|
|
|
|
|
|
my $window=$ivb->window(); |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
#starts it in '/arc/pics' |
603
|
|
|
|
|
|
|
my $window=$ivb->window('/arc/pics'); |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=cut |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
sub window{ |
608
|
|
|
|
|
|
|
my $self=$_[0]; |
609
|
|
|
|
|
|
|
my $dir=$_[1]; |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
$self->errorblank; |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
$self->{widget}=$self->widget($dir); |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
$self->{widgets}{window}=Gtk2::Window->new(); |
616
|
|
|
|
|
|
|
#picked as it will fit with in a EEE PC with out using the entire screen |
617
|
|
|
|
|
|
|
$self->{widgets}{window}->resize(700,410); |
618
|
|
|
|
|
|
|
$self->{widgets}{window}->show; |
619
|
|
|
|
|
|
|
$self->{widgets}{window}->add($self->{widget}); |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
$self->{widgets}{window}->add_accel_group($self->{widgets}{accels}); |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
# $self->{widgets}{window}->signal_connect('check-resize'=>\&resize, $self); |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
#we call this here as when we create the widget, it wont |
626
|
|
|
|
|
|
|
#zoom as this has not been called yet |
627
|
|
|
|
|
|
|
$self->zoomset; |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
return $self->{widgets}{window}; |
630
|
|
|
|
|
|
|
} |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=head2 zoomchange |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
This is called when the zoom button is clicked. |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
=cut |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
sub zoomchange{ |
639
|
|
|
|
|
|
|
my $widget=$_[0]; |
640
|
|
|
|
|
|
|
my $self=$_[1]; |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
my @types=('w', 'f', '1'); |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
my $int=0; |
645
|
|
|
|
|
|
|
my $matched=undef; |
646
|
|
|
|
|
|
|
while (defined($types[$int])) { |
647
|
|
|
|
|
|
|
if ($types[$int] eq $self->{zoom}) { |
648
|
|
|
|
|
|
|
$matched=$int; |
649
|
|
|
|
|
|
|
} |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
$int++; |
652
|
|
|
|
|
|
|
} |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
$matched++; |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
if (!defined($types[$matched])) { |
657
|
|
|
|
|
|
|
$matched=0; |
658
|
|
|
|
|
|
|
} |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
$self->{zoom}=$types[$matched]; |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
$self->{widgets}{zoomlabel}->set_label('z='.$self->{zoom}); |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
$self->zoomset($self->{zoom}); |
665
|
|
|
|
|
|
|
} |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=head2 zoomreset |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
This is called by the 'zr' button for resetting the zoom. |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=cut |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
sub zoomreset{ |
675
|
|
|
|
|
|
|
my $widget=$_[0]; |
676
|
|
|
|
|
|
|
my $self=$_[1]; |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
$self->zoomset(); |
679
|
|
|
|
|
|
|
} |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
=head2 zoomget |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
This returns the current zoom type. |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
my $zoom=$ivb->zoomget; |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
=cut |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
sub zoomget{ |
690
|
|
|
|
|
|
|
my $self=$_[0]; |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
return $self->{zoom}; |
693
|
|
|
|
|
|
|
} |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
=head2 zoomset |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
This sets the zoom to a desired type. |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
#sets the zoom type to fit it to width |
700
|
|
|
|
|
|
|
$ivb->zoomset('w') |
701
|
|
|
|
|
|
|
#this only happens if you set it to something it does not support |
702
|
|
|
|
|
|
|
if($ivb->{error}){ |
703
|
|
|
|
|
|
|
print "Error!\n"; |
704
|
|
|
|
|
|
|
} |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
#reset the zoom of the current image to |
707
|
|
|
|
|
|
|
$ivb->zoomset; |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
=cut |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
sub zoomset{ |
712
|
|
|
|
|
|
|
my $self=$_[0]; |
713
|
|
|
|
|
|
|
my $zoom=$_[1]; |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
$self->errorblank; |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
#only do the following if zoom is not set |
718
|
|
|
|
|
|
|
if (defined($zoom)) { |
719
|
|
|
|
|
|
|
my @types=('w', 'f', '1'); |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
my $int=0; |
722
|
|
|
|
|
|
|
my $matched=undef; |
723
|
|
|
|
|
|
|
while (defined($types[$int])) { |
724
|
|
|
|
|
|
|
if ($types[$int] eq $zoom) { |
725
|
|
|
|
|
|
|
$matched=$int; |
726
|
|
|
|
|
|
|
} |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
$int++; |
729
|
|
|
|
|
|
|
} |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
if (!defined($matched)) { |
732
|
|
|
|
|
|
|
warn('Gtk2-ImageView-Browse zoomset:2: Invalid zoom type'); |
733
|
|
|
|
|
|
|
$self->{error}=2; |
734
|
|
|
|
|
|
|
$self->{errorString}='Invalid zoom type.'; |
735
|
|
|
|
|
|
|
return undef; |
736
|
|
|
|
|
|
|
} |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
$self->{zoom}=$types[$matched]; |
739
|
|
|
|
|
|
|
} |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
#if there is no file defined, return... otherwise this errors later on |
742
|
|
|
|
|
|
|
if (!defined($self->{file})) { |
743
|
|
|
|
|
|
|
return 1; |
744
|
|
|
|
|
|
|
} |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
if ($self->{zoom} eq '1') { |
747
|
|
|
|
|
|
|
$self->{widgets}{view}->set_zoom(1.0); |
748
|
|
|
|
|
|
|
return 1; |
749
|
|
|
|
|
|
|
} |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
#this is used by w and f |
752
|
|
|
|
|
|
|
if (!defined($self->{widgets}{window})) { |
753
|
|
|
|
|
|
|
print "windows undef\n"; |
754
|
|
|
|
|
|
|
return undef; |
755
|
|
|
|
|
|
|
} |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
my ($windowX, $windowY) = $self->{widgets}{window}->get_size; |
758
|
|
|
|
|
|
|
my ($imageX, $imageY)=imgsize($self->{file}); |
759
|
|
|
|
|
|
|
my $widgetX=$windowX - $self->{widgets}{hpaned}->get_position; |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
$widgetX=$widgetX - 5; |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
my $zoomX=$widgetX/$imageX; |
764
|
|
|
|
|
|
|
my $zoomY=$windowY/$imageY; |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
if ($self->{zoom} eq 'w') { |
767
|
|
|
|
|
|
|
if (!defined($self->{widgets}{window})) { |
768
|
|
|
|
|
|
|
return undef; |
769
|
|
|
|
|
|
|
} |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
$self->{widgets}{view}->set_zoom($zoomX); |
772
|
|
|
|
|
|
|
return 1; |
773
|
|
|
|
|
|
|
} |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
if ($self->{zoom} eq 'f') { |
776
|
|
|
|
|
|
|
if (($zoomX > 1) && ($zoomY > 1)) { |
777
|
|
|
|
|
|
|
if ($zoomX >= $zoomY) { |
778
|
|
|
|
|
|
|
$self->{widgets}{view}->set_zoom($zoomY); |
779
|
|
|
|
|
|
|
}else { |
780
|
|
|
|
|
|
|
$self->{widgets}{view}->set_zoom($zoomX); |
781
|
|
|
|
|
|
|
} |
782
|
|
|
|
|
|
|
return 1; |
783
|
|
|
|
|
|
|
} |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
$self->{widgets}{pixbuf}=Gtk2::Gdk::Pixbuf->new_from_file($self->{file}); |
786
|
|
|
|
|
|
|
$self->{widgets}{view}->set_pixbuf($self->{widgets}{pixbuf}, 1); |
787
|
|
|
|
|
|
|
return 1; |
788
|
|
|
|
|
|
|
} |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
} |
791
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
=head2 errorblank |
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
This blanks the error storage and is only meant for internal usage. |
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
It does the following. |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
$self->{error}=undef; |
799
|
|
|
|
|
|
|
$self->{errorString}=""; |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
=cut |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
#blanks the error flags |
804
|
|
|
|
|
|
|
sub errorblank{ |
805
|
|
|
|
|
|
|
my $self=$_[0]; |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
$self->{error}=undef; |
808
|
|
|
|
|
|
|
$self->{errorString}=""; |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
return 1; |
811
|
|
|
|
|
|
|
} |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
=head1 ERROR CODES |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
=head2 1 |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
The file path specified does not exist. |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
=head2 2 |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
Invalid zoom type. |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
=head1 HOT KEYS |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
=head2 control+f |
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
Toggle minimizing of the sidebar. |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
=head2 control+r |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
Resize the image to what the zoom level should be. |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
=head2 control+z |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
Cycle zoom types. |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
=head2 control+up |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
Go to the previous image. |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
=head2 control+down |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
Go to the next image. |
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
=head1 ZOOM TYPES |
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
The current level will be displayed to the right of the equals sign |
848
|
|
|
|
|
|
|
on the zoom button or may be fetched using '$ivb->zoomget'. |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
=head2 w |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
This zooms it to the width of the image. |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
=head2 f |
855
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
This zooms the image to fit the window. |
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
=head2 1 |
859
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
This sets the zoom to 1. |
861
|
|
|
|
|
|
|
|
862
|
|
|
|
|
|
|
=head1 AUTHOR |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
=head1 BUGS |
867
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
869
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
870
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
=head1 SUPPORT |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
perldoc Gtk2::ImageView::Browser |
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
You can also look for information at: |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
=over 4 |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
L |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
L |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
=item * CPAN Ratings |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
L |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
=item * Search CPAN |
899
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
L |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
=back |
903
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
906
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
913
|
|
|
|
|
|
|
under the same terms as Perl itself. |
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
=cut |
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
1; # End of Gtk2::ImageView::Browser |