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

Comparing CV/bin/cv (file contents):
Revision 1.9 by root, Mon Nov 3 23:34:43 2003 UTC vs.
Revision 1.28 by root, Thu Nov 13 02:03:46 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines