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

Comparing CV/bin/cv (file contents):
Revision 1.26 by root, Wed Nov 12 20:22:34 2003 UTC vs.
Revision 1.43 by root, Tue Jun 28 21:26:04 2005 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3use Cwd ();
4use Encode ();
2 5
3use Gtk2 -init; 6use Gtk2 -init;
4use Gtk2::Gdk::Keysyms; 7use Gtk2::Gdk::Keysyms;
5 8
6use Gtk2::CV::ImageWindow; 9use Gtk2::CV::ImageWindow;
9use Gtk2::CV; 12use Gtk2::CV;
10 13
11Gtk2::Rc->parse (Gtk2::CV::find_rcfile "gtkrc"); 14Gtk2::Rc->parse (Gtk2::CV::find_rcfile "gtkrc");
12 15
13use File::Spec; 16use File::Spec;
17
18require Gtk2::CV::Plugin;
19require "$ENV{HOME}/.cvrc" if -r "$ENV{HOME}/.cvrc";
14 20
15my $mainwin; 21my $mainwin;
16my $viewer; 22my $viewer;
17my $schnauzer; 23my $schnauzer;
18my $info; 24my $info;
29 (File::Spec->splitpath ($_[1]))[2], 35 (File::Spec->splitpath ($_[1]))[2],
30 -s $_[1]; 36 -s $_[1];
31 $info->set_label ($label); 37 $info->set_label ($label);
32 $viewer->load_image ($_[1]); 38 $viewer->load_image ($_[1]);
33 }); 39 });
40 $s->signal_connect (chdir => sub {
41 my ($self, $dir) = @_;
42
43 my $path = Cwd::abs_path $dir;
44
45 $self->realize;
46 $self->window->property_change (
47 Gtk2::Gdk::Atom->intern ("_X_CWD", 0),
48 Gtk2::Gdk::Atom->intern ("UTF8_STRING", 0),
49 Gtk2::Gdk::CHARS, 'replace',
50 Encode::encode_utf8 $path,
51 );
52 });
53
54 Gtk2::CV::Plugin->call (new_schnauzer => $s);
34 55
35 $s; 56 $s;
36} 57}
37 58
38sub std_keys { 59sub std_keys {
68 $h->load_string (do { local $/; <DATA> }); 89 $h->load_string (do { local $/; <DATA> });
69 } 90 }
70 91
71 $help->show_all; 92 $help->show_all;
72 } else { 93 } else {
73 #$mainwin->show_all; 94 return 0;
74 $schnauzer->handle_key ($key, $state);
75 } 95 }
76 96
77 1; 97 1
78} 98}
79 99
80{ 100{
81 $viewer = new Gtk2::CV::ImageWindow; 101 $viewer = new Gtk2::CV::ImageWindow;
82 102
83 $viewer->set_title ("CV: Image"); 103 $viewer->set_title ("CV: Image");
84 104
85 $viewer->signal_connect (key_press_event => \&std_keys); 105 $viewer->signal_connect (key_press_event => sub {
106 &std_keys
107 or $schnauzer->signal_emit (key_press_event => $_[1])
108 });
86 $viewer->signal_connect (delete_event => sub { main_quit Gtk2 }); 109 $viewer->signal_connect (delete_event => sub { main_quit Gtk2 });
87 110
88 $viewer->signal_connect (button3_press_event => sub { 111 $viewer->signal_connect (button3_press_event => sub {
89 $mainwin->visible 112 $mainwin->visible
90 ? $mainwin->hide 113 ? $mainwin->hide
91 : $mainwin->show_all; 114 : $mainwin->show_all;
92 1; 115 1;
93 }); 116 });
94 117
118 Gtk2::CV::Plugin->call (new_imagewindow => $viewer);
119
95 $schnauzer = new_schnauzer; 120 $schnauzer = new_schnauzer;
96 121
97 $mainwin = new Gtk2::Window; 122 $mainwin = new Gtk2::Window;
98 $mainwin->set_title ("CV"); 123 $mainwin->set_title ("CV");
99 $mainwin->add (my $vbox = new Gtk2::VBox); 124 $mainwin->add (my $vbox = new Gtk2::VBox);
102 $vbox->add ($schnauzer); 127 $vbox->add ($schnauzer);
103 $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0); 128 $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0);
104 $frame->add (my $hbox = new Gtk2::HBox 0, 0); 129 $frame->add (my $hbox = new Gtk2::HBox 0, 0);
105 $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0); 130 $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0);
106 $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0); 131 $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0);
132 $info->set (wrap => 1);
107 133
108 $schnauzer->set_geometry_hints; 134 $schnauzer->set_geometry_hints;
109} 135}
110 136
111if (@ARGV) { 137if (@ARGV) {
112 $schnauzer->set_paths (\@ARGV); 138 $schnauzer->set_paths ([map Glib::filename_to_unicode $_, @ARGV]);
139 $schnauzer->show_all;
113 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); 140 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
114} else { 141} else {
115 $schnauzer->set_dir (File::Spec->curdir); 142 $schnauzer->set_dir (File::Spec->curdir);
116 $mainwin->show_all; 143 $mainwin->show_all;
144 $viewer->show_all;
117} 145}
118 146
119$viewer->show_all; 147$viewer->show_all;
120 148
121main Gtk2; 149main Gtk2;
152 s set scaling mode to 'bilinear' (default) 180 s set scaling mode to 'bilinear' (default)
153 S set scaling mode to 'hyper' (slowest) 181 S set scaling mode to 'hyper' (slowest)
154 t rotate clockwise 90° 182 t rotate clockwise 90°
155 T rotate counterclockwise° 183 T rotate counterclockwise°
156 ctrl-v open a new visual schnauzer window for the current dir 184 ctrl-v open a new visual schnauzer window for the current dir
185 ctrl-s rescan visual schnauzer files for updates/deletes etc.
186 ctrl-e run an editor ($CV_EDITOR or "gimp") on the current image.
187
188And when playing movies, these additional keys are active:
189
190 left rewind by 10 seconds
191 right forward by 10 seconds
192 down rewind by 60 seconds
193 up forward by 60 seconds
194 pg_up rewind by 600 seconds
195 pg_down forward by 600 seconds
196 o toggle on-screen display
197 p pause/unpause
198 escape stop playing
199 9 turn volume down
200 0 turn volume up
157 201
158The following keys are redirected to the default visual schnauzer window: 202The following keys are redirected to the default visual schnauzer window:
159 203
160 space next image 204 space next image
161 backspace last image 205 backspace last image
175 end move to last file 219 end move to last file
176 220
177 ctrl-d delete selected files WITHOUT ASKING AGAIN 221 ctrl-d delete selected files WITHOUT ASKING AGAIN
178 ctrl-g generate icons for the selected files 222 ctrl-g generate icons for the selected files
179 ctrl-u update selected (or all) icons if neccessary 223 ctrl-u update selected (or all) icons if neccessary
224 ctrl-a select all files
225
226=head1 ENVIRONMENT
227
228=over 4
229
230=item CV_EDITOR
231
232The program that gets executed when the user presses C<CTRL-e> in the
233Schnauzer or image window. The default is C<gimp>.
234
235=item CV_PRINT_DESTINATION
236
237The default (perl-style) destination to use in the print dialog.
238
239=item CV_TRASHCAN
240
241When set, must point to a directory where all files that are deleted are
242moved to. If unset, files that are deleted are really being deleted.
243
244=back
180 245
181=head1 SECURITY CONSIDERATIONS 246=head1 SECURITY CONSIDERATIONS
182 247
183CV uses Pixbuf to load images. Pixbuf is not considered safe for this 248CV uses Pixbuf to load images. Pixbuf is not considered safe for this
184purpose, though (from the gtk-2.2 release notes): 249purpose, though (from the gtk-2.2 release notes):

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines