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

Comparing CV/bin/cv (file contents):
Revision 1.20 by root, Fri Nov 7 14:01:45 2003 UTC vs.
Revision 1.29 by root, Fri Nov 14 00:38:43 2003 UTC

14 14
15my $mainwin; 15my $mainwin;
16my $viewer; 16my $viewer;
17my $schnauzer; 17my $schnauzer;
18my $info; 18my $info;
19my $help;
20
21my $schnauzer_idx = 0;
19 22
20sub new_schnauzer { 23sub new_schnauzer {
21 my $s = new Gtk2::CV::Schnauzer; 24 my $s = new Gtk2::CV::Schnauzer;
22 25
23 $s->signal_connect_after (key_press_event => \&std_keys); 26 $s->signal_connect_after (key_press_event => \&std_keys);
34 37
35sub std_keys { 38sub std_keys {
36 my $key = $_[1]->keyval; 39 my $key = $_[1]->keyval;
37 my $state = $_[1]->state; 40 my $state = $_[1]->state;
38 41
39 my $ctrl = grep $_ eq "control-mask", @$state; 42 my $ctrl = $state * "control-mask";
40 43
41 if ($key == $Gtk2::Gdk::Keysyms{q}) { 44 if ($key == $Gtk2::Gdk::Keysyms{q}) {
42 main_quit Gtk2; 45 main_quit Gtk2;
43 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) { 46 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) {
44 my $w = new Gtk2::Window; 47 my $w = new Gtk2::Window;
48
49 $w->set_title ("CV: Schnauzer");
45 $w->add (my $s = new_schnauzer); 50 $w->add (my $s = new_schnauzer);
46 $s->set_dir (File::Spec->curdir); 51 $s->set_dir (File::Spec->curdir);
52 $s->set_geometry_hints;
47 $w->show_all 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;
48 } else { 72 } else {
49 #$mainwin->show_all; 73 #$mainwin->show_all;
50 $schnauzer->handle_key ($key, $state); 74 $schnauzer->handle_key ($key, $state);
51 } 75 }
52 76
63 87
64 $viewer->signal_connect (button3_press_event => sub { 88 $viewer->signal_connect (button3_press_event => sub {
65 $mainwin->visible 89 $mainwin->visible
66 ? $mainwin->hide 90 ? $mainwin->hide
67 : $mainwin->show_all; 91 : $mainwin->show_all;
92 1;
68 }); 93 });
69 94
70 $schnauzer = new_schnauzer; 95 $schnauzer = new_schnauzer;
71 96
72 $mainwin = new Gtk2::Window; 97 $mainwin = new Gtk2::Window;
73 $mainwin->set_title ("CV"); 98 $mainwin->set_title ("CV");
74 $mainwin->add (my $vbox = new Gtk2::VBox); 99 $mainwin->add (my $vbox = new Gtk2::VBox);
100 $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; });
75 101
76 $vbox->add ($schnauzer); 102 $vbox->add ($schnauzer);
77 $vbox->add (my $frame = new Gtk2::Frame); 103 $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0);
78 $frame->add (my $hbox = new Gtk2::HBox 0, 0); 104 $frame->add (my $hbox = new Gtk2::HBox 0, 0);
79 $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0); 105 $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0);
80 $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0); 106 $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0);
107
108 $schnauzer->set_geometry_hints;
81} 109}
82 110
83if (@ARGV) { 111if (@ARGV) {
84 $schnauzer->set_paths (\@ARGV); 112 $schnauzer->set_paths (\@ARGV);
85 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); 113 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
114
115 $viewer->load_image ($ARGV[0]);
86} else { 116} else {
87 $schnauzer->set_dir (File::Spec->curdir); 117 $schnauzer->set_dir (File::Spec->curdir);
88 $mainwin->show_all; 118 $mainwin->show_all;
89} 119}
90 120
91$viewer->show_all; 121$viewer->show_all;
92 122
93main Gtk2; 123main Gtk2;
124
125__DATA__
94 126
95=head1 NAME 127=head1 NAME
96 128
97cv - a fast gtk+ image viewer modeled after xv 129cv - a fast gtk+ image viewer modeled after xv
98 130
114 , shrink the image by 10% 146 , shrink the image by 10%
115 . enlarge the image by 10% 147 . enlarge the image by 10%
116 n reset to normal size 148 n reset to normal size
117 m maximize to screensize 149 m maximize to screensize
118 M maxime to screensize, respecting image aspect 150 M maxime to screensize, respecting image aspect
151 ctrl-m toggle maxpect-always mode
119 u uncrop 152 u uncrop
120 r set scaling mode to 'nearest' (fastest) 153 r set scaling mode to 'nearest' (fastest)
121 s set scaling mode to 'bilinear' (default) 154 s set scaling mode to 'bilinear' (default)
122 S set scaling mode to 'hyper' (slowest) 155 S set scaling mode to 'hyper' (slowest)
123 t rotate clockwise 90° 156 t rotate clockwise 90°
124 T rotate counterclockwise° 157 T rotate counterclockwise°
125 ctrl-v open a new visual schnauzer window for the current dir 158 ctrl-v open a new visual schnauzer window for the current dir
159 ctrl-s rescan visual schnauzer files for updates/deletes etc.
126 160
127The following keys are redirected to the default visual schnauzer window: 161The following keys are redirected to the default visual schnauzer window:
128 162
129 space next image 163 space next image
130 backspace last image 164 backspace last image
141 page-up move one page up 175 page-up move one page up
142 page-down move one page down 176 page-down move one page down
143 home move to first file 177 home move to first file
144 end move to last file 178 end move to last file
145 179
180 ctrl-d delete selected files WITHOUT ASKING AGAIN
146 ctrl-g generate icons for the selected files 181 ctrl-g generate icons for the selected files
147 ctrl-d delete selected files WITHOUT ASKING AGAIN 182 ctrl-u update selected (or all) icons if neccessary
183
184=head1 ENVIRONMENT
185
186=over 4
187
188=item CV_PRINT_DESTINATION
189
190The default (perl-style) destination to use in the print dialog.
191
192=back
193
194=head1 SECURITY CONSIDERATIONS
195
196CV uses Pixbuf to load images. Pixbuf is not considered safe for this
197purpose, though (from the gtk-2.2 release notes):
198
199"While efforts have been made to make gdk-pixbuf robust against invalid
200images, using gdk-pixbuf to load untrusted data is not recommended, due to
201the likelyhood that there are additional problems where an invalid image
202could cause gdk-pixbuf to crash or worse."
148 203
149=head1 BUGS/TODO 204=head1 BUGS/TODO
205
206 Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names
207 incompatible with utf-8 fails.
150 208
151 rotate on disk 209 rotate on disk
152 print 210 print
153 lots of ui issues 211 lots of ui issues
154 save(?) 212 save(?)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines