ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/bin/cv
Revision: 1.34
Committed: Mon Feb 7 13:52:30 2005 UTC (19 years, 4 months ago) by root
Branch: MAIN
Changes since 1.33: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/opt/bin/perl
2
3 use Gtk2 -init;
4 use Gtk2::Gdk::Keysyms;
5
6 use Gtk2::CV::ImageWindow;
7 use Gtk2::CV::Schnauzer;
8
9 use Gtk2::CV;
10
11 Gtk2::Rc->parse (Gtk2::CV::find_rcfile "gtkrc");
12
13 use File::Spec;
14
15 my $mainwin;
16 my $viewer;
17 my $schnauzer;
18 my $info;
19 my $help;
20
21 my $schnauzer_idx = 0;
22
23 sub new_schnauzer {
24 my $s = new Gtk2::CV::Schnauzer;
25
26 $s->signal_connect_after (key_press_event => \&std_keys);
27 $s->signal_connect (activate => sub {
28 my $label = sprintf "%s (%d)",
29 (File::Spec->splitpath ($_[1]))[2],
30 -s $_[1];
31 $info->set_label ($label);
32 $viewer->load_image ($_[1]);
33 });
34
35 $s;
36 }
37
38 sub std_keys {
39 my $key = $_[1]->keyval;
40 my $state = $_[1]->state;
41
42 my $ctrl = $state * "control-mask";
43
44 if ($key == $Gtk2::Gdk::Keysyms{q}) {
45 main_quit Gtk2;
46 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) {
47 my $w = new Gtk2::Window;
48
49 $w->set_title ("CV: Schnauzer");
50 $w->add (my $s = new_schnauzer);
51 $s->set_dir (File::Spec->curdir);
52 $s->set_geometry_hints;
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;
72 } else {
73 #$mainwin->show_all;
74 $schnauzer->handle_key ($key, $state);
75 }
76
77 1;
78 }
79
80 {
81 $viewer = new Gtk2::CV::ImageWindow;
82
83 $viewer->set_title ("CV: Image");
84
85 $viewer->signal_connect (key_press_event => \&std_keys);
86 $viewer->signal_connect (delete_event => sub { main_quit Gtk2 });
87
88 $viewer->signal_connect (button3_press_event => sub {
89 $mainwin->visible
90 ? $mainwin->hide
91 : $mainwin->show_all;
92 1;
93 });
94
95 $schnauzer = new_schnauzer;
96
97 $mainwin = new Gtk2::Window;
98 $mainwin->set_title ("CV");
99 $mainwin->add (my $vbox = new Gtk2::VBox);
100 $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; });
101
102 $vbox->add ($schnauzer);
103 $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0);
104 $frame->add (my $hbox = new Gtk2::HBox 0, 0);
105 $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0);
106 $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0);
107
108 $schnauzer->set_geometry_hints;
109 }
110
111 if (@ARGV) {
112 $_ = Glib::filename_to_unicode $_ for @ARGV;
113 $schnauzer->set_paths (\@ARGV);
114 $schnauzer->show_all;
115 $viewer->show_all;
116 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
117 } else {
118 $schnauzer->set_dir (File::Spec->curdir);
119 $mainwin->show_all;
120 $viewer->show_all;
121 }
122
123 main Gtk2;
124
125 __DATA__
126
127 =head1 NAME
128
129 cv - a fast gtk+ image viewer modeled after xv
130
131 =head1 SYNOPSIS
132
133 cv [file...]
134
135 =head1 DESCRIPTION
136
137 None yet.
138
139 =head2 THE IMAGE WINDOW
140
141 You can use the following keys in the image window:
142
143 q quit the program
144 < half the image size
145 > double the image size
146 , shrink the image by 10%
147 . enlarge the image by 10%
148 n reset to normal size
149 m maximize to screensize
150 M maxime to screensize, respecting image aspect
151 ctrl-m toggle maxpect-always mode
152 u uncrop
153 r set scaling mode to 'nearest' (fastest)
154 s set scaling mode to 'bilinear' (default)
155 S set scaling mode to 'hyper' (slowest)
156 t rotate clockwise 90°
157 T rotate counterclockwise°
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
162 And 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
175
176 The following keys are redirected to the default visual schnauzer window:
177
178 space next image
179 backspace last image
180
181 =head2 THE VISUAL SCHNAUZER
182
183 You can use the following keys in the schnauzer window:
184
185 space move to and display next image
186 backspace move to and display previous image
187 return display selected picture
188
189 cursor keys move selection
190 page-up move one page up
191 page-down move one page down
192 home move to first file
193 end move to last file
194
195 ctrl-d delete selected files WITHOUT ASKING AGAIN
196 ctrl-g generate icons for the selected files
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
206 The default (perl-style) destination to use in the print dialog.
207
208 =back
209
210 =head1 SECURITY CONSIDERATIONS
211
212 CV uses Pixbuf to load images. Pixbuf is not considered safe for this
213 purpose, though (from the gtk-2.2 release notes):
214
215 "While efforts have been made to make gdk-pixbuf robust against invalid
216 images, using gdk-pixbuf to load untrusted data is not recommended, due to
217 the likelyhood that there are additional problems where an invalid image
218 could cause gdk-pixbuf to crash or worse."
219
220 =head1 BUGS/TODO
221
222 Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names
223 incompatible with utf-8 fails.
224
225 rotate on disk
226 print
227 lots of ui issues
228 save(?)
229 preferences
230 ctrl-u in schnauzer
231 shift-cursor in schnauzer
232
233 =head1 AUTHOR
234
235 Marc Lehmann <cv@plan9.de>.
236
237 =cut
238