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