ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/bin/cv
Revision: 1.25
Committed: Wed Nov 12 19:36:06 2003 UTC (20 years, 8 months ago) by root
Branch: MAIN
Changes since 1.24: +6 -0 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 $w->add (my $s = new_schnauzer);
49 $s->set_dir (File::Spec->curdir);
50 $s->set_geometry_hints;
51 $w->show_all;
52
53 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{h}) {
54 unless ($help) {
55 require Gtk2::PodViewer;
56
57 $help = new Gtk2::Window;
58 $help->set_title ("CV Help");
59 $help->set_default_size (500, 300);
60 $help->signal_connect (delete_event => sub { $help->hide; 1 });
61
62 $help->add (my $sw = new Gtk2::ScrolledWindow);
63 $sw->add (my $h = new Gtk2::PodViewer);
64
65 #binmode DATA, ":utf8";
66 $h->load_string (do { local $/; <DATA> });
67 }
68
69 $help->show_all;
70 } else {
71 #$mainwin->show_all;
72 $schnauzer->handle_key ($key, $state);
73 }
74
75 1;
76 }
77
78 {
79 $viewer = new Gtk2::CV::ImageWindow;
80
81 $viewer->set_title ("CV: Image");
82
83 $viewer->signal_connect (key_press_event => \&std_keys);
84 $viewer->signal_connect (delete_event => sub { main_quit Gtk2 });
85
86 $viewer->signal_connect (button3_press_event => sub {
87 $mainwin->visible
88 ? $mainwin->hide
89 : $mainwin->show_all;
90 1;
91 });
92
93 $schnauzer = new_schnauzer;
94
95 $mainwin = new Gtk2::Window;
96 $mainwin->set_title ("CV");
97 $mainwin->add (my $vbox = new Gtk2::VBox);
98 $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; });
99
100 $vbox->add ($schnauzer);
101 $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0);
102 $frame->add (my $hbox = new Gtk2::HBox 0, 0);
103 $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0);
104 $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0);
105
106 $schnauzer->set_geometry_hints;
107 }
108
109 if (@ARGV) {
110 $schnauzer->set_paths (\@ARGV);
111 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
112 } else {
113 $schnauzer->set_dir (File::Spec->curdir);
114 $mainwin->show_all;
115 }
116
117 $viewer->show_all;
118
119 main Gtk2;
120
121 __DATA__
122
123 =head1 NAME
124
125 cv - a fast gtk+ image viewer modeled after xv
126
127 =head1 SYNOPSIS
128
129 cv [file...]
130
131 =head1 DESCRIPTION
132
133 None yet.
134
135 =head2 THE IMAGE WINDOW
136
137 You can use the following keys in the image window:
138
139 q quit the program
140 < half the image size
141 > double the image size
142 , shrink the image by 10%
143 . enlarge the image by 10%
144 n reset to normal size
145 m maximize to screensize
146 M maxime to screensize, respecting image aspect
147 u uncrop
148 r set scaling mode to 'nearest' (fastest)
149 s set scaling mode to 'bilinear' (default)
150 S set scaling mode to 'hyper' (slowest)
151 t rotate clockwise 90°
152 T rotate counterclockwise°
153 ctrl-v open a new visual schnauzer window for the current dir
154
155 The following keys are redirected to the default visual schnauzer window:
156
157 space next image
158 backspace last image
159
160 =head2 THE VISUAL SCHNAUZER
161
162 You can use the following keys in the schnauzer window:
163
164 space move to and display next image
165 backspace move to and display previous image
166 return display selected picture
167
168 cursor keys move selection
169 page-up move one page up
170 page-down move one page down
171 home move to first file
172 end move to last file
173
174 ctrl-d delete selected files WITHOUT ASKING AGAIN
175 ctrl-g generate icons for the selected files
176 ctrl-u update selected (or all) icons if neccessary
177
178 =head1 SECURITY CONSIDERATIONS
179
180 CV uses Pixbuf to load images. Pixbuf is not considered safe for this
181 purpose, though (from the gtk-2.2 release notes):
182
183 "While efforts have been made to make gdk-pixbuf robust against invalid
184 images, using gdk-pixbuf to load untrusted data is not recommended, due to
185 the likelyhood that there are additional problems where an invalid image
186 could cause gdk-pixbuf to crash or worse."
187
188 =head1 BUGS/TODO
189
190 Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names
191 incompatible with utf-8 fails.
192
193 rotate on disk
194 print
195 lots of ui issues
196 save(?)
197 preferences
198 ctrl-u in schnauzer
199 shift-cursor in schnauzer
200
201 =head1 AUTHOR
202
203 Marc Lehmann <cv@plan9.de>.
204
205 =cut
206