1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
2 | |
2 | |
3 | use Cwd (); |
3 | use Cwd (); |
4 | use Encode (); |
4 | use Encode (); |
|
|
5 | use File::Glob (); |
5 | |
6 | |
6 | use Gtk2 -init; |
7 | use Gtk2 -init; |
7 | use Gtk2::Gdk::Keysyms; |
8 | use Gtk2::Gdk::Keysyms; |
8 | |
9 | |
9 | use Gtk2::CV; |
10 | use Gtk2::CV; |
… | |
… | |
36 | my $s = new Gtk2::CV::Schnauzer; |
37 | my $s = new Gtk2::CV::Schnauzer; |
37 | |
38 | |
38 | $s->signal_connect_after (key_press_event => \&std_keys); |
39 | $s->signal_connect_after (key_press_event => \&std_keys); |
39 | $s->signal_connect (activate => sub { |
40 | $s->signal_connect (activate => sub { |
40 | my $label = sprintf "%s (%d)", |
41 | my $label = sprintf "%s (%d)", |
41 | (File::Spec->splitpath ($_[1]))[2], |
42 | (Glib::filename_display_name +(File::Spec->splitpath ($_[1]))[2]), |
42 | -s $_[1]; |
43 | -s $_[1]; |
43 | $info->set_label ($label); |
44 | $info->set_label ($label); |
44 | $viewer->load_image ($_[1]) if $viewer; # TODO: error, or chose ANY viewer |
45 | $viewer->load_image ($_[1]) if $viewer; # TODO: error, or chose ANY viewer |
45 | }); |
46 | }); |
46 | |
47 | |
… | |
… | |
70 | } else { |
71 | } else { |
71 | &std_keys |
72 | &std_keys |
72 | or $schnauzer->signal_emit (key_press_event => $_[1]) |
73 | or $schnauzer->signal_emit (key_press_event => $_[1]) |
73 | } |
74 | } |
74 | }); |
75 | }); |
|
|
76 | $self->signal_connect (delete_event => sub { $_[0]->destroy; 0 }); |
75 | $self->signal_connect (destroy => sub { |
77 | $self->signal_connect (destroy => sub { |
76 | $viewer = undef if $viewer == $_[0]; |
78 | $viewer = undef if $viewer == $_[0]; |
77 | |
79 | |
78 | main_quit Gtk2 unless --$viewer_count; |
80 | main_quit Gtk2 unless --$viewer_count; |
|
|
81 | |
|
|
82 | 0 |
79 | }); |
83 | }); |
80 | |
84 | |
81 | $self->signal_connect (button3_press_event => sub { |
85 | $self->signal_connect (button3_press_event => sub { |
82 | $mainwin->visible |
86 | $mainwin->visible |
83 | ? $mainwin->hide |
87 | ? $mainwin->hide |
84 | : $mainwin->show_all; |
88 | : $mainwin->show_all; |
|
|
89 | |
85 | 1 |
90 | 1 |
86 | }); |
91 | }); |
87 | |
92 | |
88 | Gtk2::CV::Plugin->call (new_imagewindow => $self); |
93 | Gtk2::CV::Plugin->call (new_imagewindow => $self); |
89 | |
94 | |
… | |
… | |
99 | if ($key == $Gtk2::Gdk::Keysyms{q}) { |
104 | if ($key == $Gtk2::Gdk::Keysyms{q}) { |
100 | $viewer->destroy; |
105 | $viewer->destroy; |
101 | } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) { |
106 | } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) { |
102 | my $w = new Gtk2::Window; |
107 | my $w = new Gtk2::Window; |
103 | |
108 | |
|
|
109 | $w->set_role ("schnauzer"); |
104 | $w->set_title ("CV: Schnauzer"); |
110 | $w->set_title ("CV: Schnauzer"); |
105 | $w->add (my $s = new_schnauzer); |
111 | $w->add (my $s = new_schnauzer); |
106 | $s->set_dir (File::Spec->curdir); |
112 | $s->set_dir (File::Spec->curdir); |
107 | $s->set_geometry_hints; |
113 | $s->set_geometry_hints; |
108 | $w->show_all; |
114 | $w->show_all; |
109 | |
115 | |
110 | } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{h}) { |
116 | } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{h}) { |
111 | unless ($help) { |
117 | unless ($help) { |
112 | require Gtk2::PodViewer; |
118 | require Gtk2::Ex::PodViewer; |
113 | |
119 | |
114 | $help = new Gtk2::Window; |
120 | $help = new Gtk2::Window; |
|
|
121 | $help->set_role ("help"); |
115 | $help->set_title ("CV: Help"); |
122 | $help->set_title ("CV: Help"); |
116 | $help->set_default_size (500, 300); |
123 | $help->set_default_size (500, 300); |
117 | $help->signal_connect (delete_event => sub { $help->hide; 1 }); |
124 | $help->signal_connect (delete_event => sub { $help->hide; 1 }); |
118 | |
125 | |
119 | $help->add (my $sw = new Gtk2::ScrolledWindow); |
126 | $help->add (my $sw = new Gtk2::ScrolledWindow); |
120 | $sw->add (my $h = new Gtk2::PodViewer); |
127 | $sw->add (my $h = new Gtk2::Ex::PodViewer); |
121 | |
128 | |
122 | #binmode DATA, ":utf8"; |
129 | #binmode DATA, ":utf8"; |
123 | $h->load_string (do { local $/; <DATA> }); |
130 | $h->load_string (do { local $/; <DATA> }); |
124 | } |
131 | } |
125 | |
132 | |
… | |
… | |
136 | $::cur_viewer = $viewer; |
143 | $::cur_viewer = $viewer; |
137 | |
144 | |
138 | $schnauzer = new_schnauzer; |
145 | $schnauzer = new_schnauzer; |
139 | |
146 | |
140 | $mainwin = new Gtk2::Window; |
147 | $mainwin = new Gtk2::Window; |
|
|
148 | $mainwin->set_role ("main"); |
141 | $mainwin->set_title ("CV"); |
149 | $mainwin->set_title ("CV"); |
142 | $mainwin->add (my $vbox = new Gtk2::VBox); |
150 | $mainwin->add (my $vbox = new Gtk2::VBox); |
143 | $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1 }); |
151 | $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1 }); |
144 | |
152 | |
145 | $vbox->add ($schnauzer); |
153 | $vbox->add ($schnauzer); |
… | |
… | |
153 | |
161 | |
154 | $schnauzer->set_geometry_hints; |
162 | $schnauzer->set_geometry_hints; |
155 | } |
163 | } |
156 | |
164 | |
157 | if (@ARGV) { |
165 | if (@ARGV) { |
158 | @ARGV == 1 && -d $ARGV[0] |
166 | my $show_first = sub { |
159 | ? $schnauzer->set_dir (Glib::filename_to_unicode shift) |
|
|
160 | : $schnauzer->set_paths ([map Glib::filename_to_unicode $_, @ARGV]); |
|
|
161 | $schnauzer->show_all; |
167 | $schnauzer->show_all; |
162 | $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); |
168 | $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); |
|
|
169 | $viewer->show_all; |
|
|
170 | }; |
|
|
171 | |
|
|
172 | if (@ARGV == 1 && $ARGV[0] eq "-0r") { |
|
|
173 | local $/; |
|
|
174 | $schnauzer->set_paths ([split /\x00/, <STDIN>], 1, $show_first); |
|
|
175 | } elsif (@ARGV == 1 && -d $ARGV[0]) { |
|
|
176 | $schnauzer->set_dir (shift, $show_first); |
|
|
177 | } else { |
|
|
178 | if ($ARGV[0] eq "-g") { |
|
|
179 | shift @ARGV; |
|
|
180 | @ARGV = map +(File::Glob::bsd_glob $_, File::Glob::GLOB_BRACE | File::Glob::GLOB_QUOTE), @ARGV; |
|
|
181 | } |
|
|
182 | $schnauzer->set_paths ([@ARGV], 1, $show_first); |
|
|
183 | } |
163 | } else { |
184 | } else { |
164 | $schnauzer->set_dir (File::Spec->curdir); |
185 | $schnauzer->set_dir (File::Spec->curdir, sub { |
165 | $mainwin->show_all; |
186 | $mainwin->show_all; |
166 | } |
|
|
167 | |
|
|
168 | $viewer->show_all; |
187 | $viewer->show_all; |
|
|
188 | }); |
|
|
189 | } |
169 | |
190 | |
170 | main Gtk2; |
191 | main Gtk2; |
|
|
192 | |
|
|
193 | Gtk2::CV::flush_aio; |
171 | |
194 | |
172 | __DATA__ |
195 | __DATA__ |
173 | |
196 | |
174 | =encoding utf-8 |
197 | =encoding utf-8 |
175 | |
198 | |
… | |
… | |
292 | r set scaling mode to 'nearest' (fastest) |
315 | r set scaling mode to 'nearest' (fastest) |
293 | s set scaling mode to 'bilinear' (default) |
316 | s set scaling mode to 'bilinear' (default) |
294 | shift-s set scaling mode to 'hyper' (slowest) |
317 | shift-s set scaling mode to 'hyper' (slowest) |
295 | t rotate clockwise 90° |
318 | t rotate clockwise 90° |
296 | T rotate counterclockwise° |
319 | T rotate counterclockwise° |
|
|
320 | a apply all rotations loslessly to a jpeg file (using exiftran) |
297 | ctrl-v open a new visual schnauzer window for the current dir |
321 | ctrl-v open a new visual schnauzer window for the current dir |
|
|
322 | ctrl-c clone the current image window |
298 | ctrl-e run an editor ($CV_EDITOR or "gimp") on the current image |
323 | ctrl-e run an editor ($CV_EDITOR or "gimp") on the current image |
299 | ctrl-p fire up the print dialog |
324 | ctrl-p fire up the print dialog |
300 | escape cancel a crop action |
325 | escape cancel a crop action |
301 | |
326 | |
302 | And when playing movies, these additional keys are active: |
327 | And when playing movies, these additional keys are active: |
… | |
… | |
319 | Left-clicking into the image window will let you crop the image (usually |
344 | Left-clicking into the image window will let you crop the image (usually |
320 | to zoom into large images that CV scales down). |
345 | to zoom into large images that CV scales down). |
321 | |
346 | |
322 | =head2 THE VISUAL SCHNAUZER |
347 | =head2 THE VISUAL SCHNAUZER |
323 | |
348 | |
|
|
349 | Any image-loading action in a schnauzer window acts on the |
|
|
350 | "last-recently-activated" imagewindow, which currently is simply the last |
|
|
351 | image window that received a keypress. |
|
|
352 | |
324 | You can use the following keys in the schnauzer window: |
353 | You can use the following keys in the schnauzer window: |
325 | |
354 | |
326 | ctrl-space, |
355 | ctrl-space, |
327 | space move to and display next image |
356 | space move to and display next image |
328 | ctrl-backspace, |
357 | ctrl-backspace, |
… | |
… | |
340 | ctrl-shift-a select all files currently displayed in the schnauzer window |
369 | ctrl-shift-a select all files currently displayed in the schnauzer window |
341 | ctrl-d delete selected files WITHOUT ASKING AGAIN |
370 | ctrl-d delete selected files WITHOUT ASKING AGAIN |
342 | ctrl-g force generation of thumbnais for the selected files |
371 | ctrl-g force generation of thumbnais for the selected files |
343 | ctrl-s rescan current direcory or files updates/deletes etc. |
372 | ctrl-s rescan current direcory or files updates/deletes etc. |
344 | ctrl-u update selected (or all) icons if neccessary |
373 | ctrl-u update selected (or all) icons if neccessary |
345 | ctrl-l don't use, will become a plug-in eventually |
374 | ctrl-- unselected thumbnailed images |
|
|
375 | ctrl-+ keep only thumbnailed images, deselect others |
346 | |
376 | |
347 | ^ go to parent directory (caret). |
377 | ^ go to parent directory (caret). |
348 | |
378 | |
349 | 0-9, |
379 | 0-9, |
350 | a-z find the first filename beginning with this letter |
380 | a-z find the first filename beginning with this letter |
… | |
… | |
409 | =item CV_EDITOR |
439 | =item CV_EDITOR |
410 | |
440 | |
411 | The program that gets executed when the user presses C<CTRL-e> in the |
441 | The program that gets executed when the user presses C<CTRL-e> in the |
412 | Schnauzer or image window. The default is C<gimp>. |
442 | Schnauzer or image window. The default is C<gimp>. |
413 | |
443 | |
|
|
444 | =item CV_AUDIO_PLAYER |
|
|
445 | |
|
|
446 | Program used to play all sorts of audio (wav, aif, mp3, ogg...), default "play". |
|
|
447 | Will be called like C<< $CV_AUDIO_PLAYER -- <path> >>. |
|
|
448 | |
414 | =item CV_PRINT_DESTINATION |
449 | =item CV_PRINT_DESTINATION |
415 | |
450 | |
416 | The default (perl-style) destination to use in the print dialog. |
451 | The default (perl-style) destination to use in the print dialog. |
417 | |
452 | |
418 | =item CV_TRASHCAN |
453 | =item CV_TRASHCAN |