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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines