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.32 by root, Sun Oct 31 21:01:40 2004 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) {
112 $_ = Glib::filename_to_unicode $_ for @ARGV;
84 $schnauzer->set_paths (\@ARGV); 113 $schnauzer->set_paths (\@ARGV);
114 $schnauzer->show_all;
85 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); 115 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
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.
160 ctrl-e run an editor ($CV_EDITOR or "gimp") on the current image.
126 161
127The following keys are redirected to the default visual schnauzer window: 162The following keys are redirected to the default visual schnauzer window:
128 163
129 space next image 164 space next image
130 backspace last image 165 backspace last image
141 page-up move one page up 176 page-up move one page up
142 page-down move one page down 177 page-down move one page down
143 home move to first file 178 home move to first file
144 end move to last file 179 end move to last file
145 180
181 ctrl-d delete selected files WITHOUT ASKING AGAIN
146 ctrl-g generate icons for the selected files 182 ctrl-g generate icons for the selected files
147 ctrl-d delete selected files WITHOUT ASKING AGAIN 183 ctrl-u update selected (or all) icons if neccessary
184 ctrl-a select all files
185
186=head1 ENVIRONMENT
187
188=over 4
189
190=item CV_PRINT_DESTINATION
191
192The default (perl-style) destination to use in the print dialog.
193
194=back
195
196=head1 SECURITY CONSIDERATIONS
197
198CV uses Pixbuf to load images. Pixbuf is not considered safe for this
199purpose, though (from the gtk-2.2 release notes):
200
201"While efforts have been made to make gdk-pixbuf robust against invalid
202images, using gdk-pixbuf to load untrusted data is not recommended, due to
203the likelyhood that there are additional problems where an invalid image
204could cause gdk-pixbuf to crash or worse."
148 205
149=head1 BUGS/TODO 206=head1 BUGS/TODO
207
208 Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names
209 incompatible with utf-8 fails.
150 210
151 rotate on disk 211 rotate on disk
152 print 212 print
153 lots of ui issues 213 lots of ui issues
154 save(?) 214 save(?)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines