ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/bin/cv
(Generate patch)

Comparing CV/bin/cv (file contents):
Revision 1.20 by root, Fri Nov 7 14:01:45 2003 UTC vs.
Revision 1.36 by root, Sat Feb 12 17:23:41 2005 UTC

14 14
15my $mainwin; 15my $mainwin;
16my $viewer; 16my $viewer;
17my $schnauzer; 17my $schnauzer;
18my $info; 18my $info;
19my $help;
20
21my $schnauzer_idx = 0;
19 22
20sub new_schnauzer { 23sub new_schnauzer {
21 my $s = new Gtk2::CV::Schnauzer; 24 my $s = new Gtk2::CV::Schnauzer;
22 25
23 $s->signal_connect_after (key_press_event => \&std_keys); 26 $s->signal_connect_after (key_press_event => \&std_keys);
34 37
35sub std_keys { 38sub std_keys {
36 my $key = $_[1]->keyval; 39 my $key = $_[1]->keyval;
37 my $state = $_[1]->state; 40 my $state = $_[1]->state;
38 41
39 my $ctrl = grep $_ eq "control-mask", @$state; 42 my $ctrl = $state * "control-mask";
40 43
41 if ($key == $Gtk2::Gdk::Keysyms{q}) { 44 if ($key == $Gtk2::Gdk::Keysyms{q}) {
42 main_quit Gtk2; 45 main_quit Gtk2;
43 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) { 46 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) {
44 my $w = new Gtk2::Window; 47 my $w = new Gtk2::Window;
48
49 $w->set_title ("CV: Schnauzer");
45 $w->add (my $s = new_schnauzer); 50 $w->add (my $s = new_schnauzer);
46 $s->set_dir (File::Spec->curdir); 51 $s->set_dir (File::Spec->curdir);
52 $s->set_geometry_hints;
47 $w->show_all 53 $w->show_all;
54
55 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{h}) {
56 unless ($help) {
57 require Gtk2::PodViewer;
58
59 $help = new Gtk2::Window;
60 $help->set_title ("CV: Help");
61 $help->set_default_size (500, 300);
62 $help->signal_connect (delete_event => sub { $help->hide; 1 });
63
64 $help->add (my $sw = new Gtk2::ScrolledWindow);
65 $sw->add (my $h = new Gtk2::PodViewer);
66
67 #binmode DATA, ":utf8";
68 $h->load_string (do { local $/; <DATA> });
69 }
70
71 $help->show_all;
48 } else { 72 } else {
49 #$mainwin->show_all; 73 #$mainwin->show_all;
50 $schnauzer->handle_key ($key, $state); 74 $schnauzer->handle_key ($key, $state);
51 } 75 }
52 76
63 87
64 $viewer->signal_connect (button3_press_event => sub { 88 $viewer->signal_connect (button3_press_event => sub {
65 $mainwin->visible 89 $mainwin->visible
66 ? $mainwin->hide 90 ? $mainwin->hide
67 : $mainwin->show_all; 91 : $mainwin->show_all;
92 1;
68 }); 93 });
69 94
70 $schnauzer = new_schnauzer; 95 $schnauzer = new_schnauzer;
71 96
72 $mainwin = new Gtk2::Window; 97 $mainwin = new Gtk2::Window;
73 $mainwin->set_title ("CV"); 98 $mainwin->set_title ("CV");
74 $mainwin->add (my $vbox = new Gtk2::VBox); 99 $mainwin->add (my $vbox = new Gtk2::VBox);
100 $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; });
75 101
76 $vbox->add ($schnauzer); 102 $vbox->add ($schnauzer);
77 $vbox->add (my $frame = new Gtk2::Frame); 103 $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0);
78 $frame->add (my $hbox = new Gtk2::HBox 0, 0); 104 $frame->add (my $hbox = new Gtk2::HBox 0, 0);
79 $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0); 105 $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0);
80 $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0); 106 $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0);
107
108 $schnauzer->set_geometry_hints;
81} 109}
82 110
83if (@ARGV) { 111if (@ARGV) {
84 $schnauzer->set_paths (\@ARGV); 112 $schnauzer->set_paths ([map Glib::filename_to_unicode $_, @ARGV]);
113 $schnauzer->show_all;
85 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); 114 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
86} else { 115} else {
87 $schnauzer->set_dir (File::Spec->curdir); 116 $schnauzer->set_dir (File::Spec->curdir);
88 $mainwin->show_all; 117 $mainwin->show_all;
118 $viewer->show_all;
89} 119}
90 120
91$viewer->show_all; 121$viewer->show_all;
92 122
93main Gtk2; 123main Gtk2;
124
125__DATA__
94 126
95=head1 NAME 127=head1 NAME
96 128
97cv - a fast gtk+ image viewer modeled after xv 129cv - a fast gtk+ image viewer modeled after xv
98 130
114 , shrink the image by 10% 146 , shrink the image by 10%
115 . enlarge the image by 10% 147 . enlarge the image by 10%
116 n reset to normal size 148 n reset to normal size
117 m maximize to screensize 149 m maximize to screensize
118 M maxime to screensize, respecting image aspect 150 M maxime to screensize, respecting image aspect
151 ctrl-m toggle maxpect-always mode
119 u uncrop 152 u uncrop
120 r set scaling mode to 'nearest' (fastest) 153 r set scaling mode to 'nearest' (fastest)
121 s set scaling mode to 'bilinear' (default) 154 s set scaling mode to 'bilinear' (default)
122 S set scaling mode to 'hyper' (slowest) 155 S set scaling mode to 'hyper' (slowest)
123 t rotate clockwise 90° 156 t rotate clockwise 90°
124 T rotate counterclockwise° 157 T rotate counterclockwise°
125 ctrl-v open a new visual schnauzer window for the current dir 158 ctrl-v open a new visual schnauzer window for the current dir
159 ctrl-s rescan visual schnauzer files for updates/deletes etc.
160 ctrl-e run an editor ($CV_EDITOR or "gimp") on the current image.
161
162And when playing movies, these additional keys are active:
163
164 left rewind by 10 seconds
165 right forward by 10 seconds
166 down rewind by 60 seconds
167 up forward by 60 seconds
168 pg_up rewind by 600 seconds
169 pg_down forward by 600 seconds
170 o toggle on-screen display
171 p pause/unpause
172 escape stop playing
173 9 turn volume down
174 0 turn volume up
126 175
127The following keys are redirected to the default visual schnauzer window: 176The following keys are redirected to the default visual schnauzer window:
128 177
129 space next image 178 space next image
130 backspace last image 179 backspace last image
141 page-up move one page up 190 page-up move one page up
142 page-down move one page down 191 page-down move one page down
143 home move to first file 192 home move to first file
144 end move to last file 193 end move to last file
145 194
195 ctrl-d delete selected files WITHOUT ASKING AGAIN
146 ctrl-g generate icons for the selected files 196 ctrl-g generate icons for the selected files
147 ctrl-d delete selected files WITHOUT ASKING AGAIN 197 ctrl-u update selected (or all) icons if neccessary
198 ctrl-a select all files
199
200=head1 ENVIRONMENT
201
202=over 4
203
204=item CV_PRINT_DESTINATION
205
206The default (perl-style) destination to use in the print dialog.
207
208=back
209
210=head1 SECURITY CONSIDERATIONS
211
212CV uses Pixbuf to load images. Pixbuf is not considered safe for this
213purpose, though (from the gtk-2.2 release notes):
214
215"While efforts have been made to make gdk-pixbuf robust against invalid
216images, using gdk-pixbuf to load untrusted data is not recommended, due to
217the likelyhood that there are additional problems where an invalid image
218could cause gdk-pixbuf to crash or worse."
148 219
149=head1 BUGS/TODO 220=head1 BUGS/TODO
221
222 Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names
223 incompatible with utf-8 fails.
150 224
151 rotate on disk 225 rotate on disk
152 print 226 print
153 lots of ui issues 227 lots of ui issues
154 save(?) 228 save(?)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines