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.30 by root, Mon Nov 17 04:04:49 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) {
112 $_ = Glib::filename_to_unicode $_ for @ARGV;
84 $schnauzer->set_paths (\@ARGV); 113 $schnauzer->set_paths (\@ARGV);
85 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); 114 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
115
116 $viewer->load_image ($ARGV[0]);
86} else { 117} else {
87 $schnauzer->set_dir (File::Spec->curdir); 118 $schnauzer->set_dir (File::Spec->curdir);
88 $mainwin->show_all; 119 $mainwin->show_all;
89} 120}
90 121
91$viewer->show_all; 122$viewer->show_all;
92 123
93main Gtk2; 124main Gtk2;
125
126__DATA__
94 127
95=head1 NAME 128=head1 NAME
96 129
97cv - a fast gtk+ image viewer modeled after xv 130cv - a fast gtk+ image viewer modeled after xv
98 131
114 , shrink the image by 10% 147 , shrink the image by 10%
115 . enlarge the image by 10% 148 . enlarge the image by 10%
116 n reset to normal size 149 n reset to normal size
117 m maximize to screensize 150 m maximize to screensize
118 M maxime to screensize, respecting image aspect 151 M maxime to screensize, respecting image aspect
152 ctrl-m toggle maxpect-always mode
119 u uncrop 153 u uncrop
120 r set scaling mode to 'nearest' (fastest) 154 r set scaling mode to 'nearest' (fastest)
121 s set scaling mode to 'bilinear' (default) 155 s set scaling mode to 'bilinear' (default)
122 S set scaling mode to 'hyper' (slowest) 156 S set scaling mode to 'hyper' (slowest)
123 t rotate clockwise 90° 157 t rotate clockwise 90°
124 T rotate counterclockwise° 158 T rotate counterclockwise°
125 ctrl-v open a new visual schnauzer window for the current dir 159 ctrl-v open a new visual schnauzer window for the current dir
160 ctrl-s rescan visual schnauzer files for updates/deletes etc.
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
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."
148 204
149=head1 BUGS/TODO 205=head1 BUGS/TODO
206
207 Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names
208 incompatible with utf-8 fails.
150 209
151 rotate on disk 210 rotate on disk
152 print 211 print
153 lots of ui issues 212 lots of ui issues
154 save(?) 213 save(?)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines