ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/bin/cv
Revision: 1.35
Committed: Tue Feb 8 02:54:59 2005 UTC (19 years, 5 months ago) by root
Branch: MAIN
Changes since 1.34: +2 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2    
3 root 1.12 use Gtk2 -init;
4     use Gtk2::Gdk::Keysyms;
5    
6     use Gtk2::CV::ImageWindow;
7     use Gtk2::CV::Schnauzer;
8    
9 root 1.16 use Gtk2::CV;
10    
11     Gtk2::Rc->parse (Gtk2::CV::find_rcfile "gtkrc");
12    
13 root 1.20 use File::Spec;
14    
15     my $mainwin;
16 root 1.12 my $viewer;
17     my $schnauzer;
18 root 1.20 my $info;
19 root 1.21 my $help;
20 root 1.12
21 root 1.25 my $schnauzer_idx = 0;
22    
23 root 1.12 sub new_schnauzer {
24 root 1.20 my $s = new Gtk2::CV::Schnauzer;
25 root 1.12
26     $s->signal_connect_after (key_press_event => \&std_keys);
27 root 1.20 $s->signal_connect (activate => sub {
28     my $label = sprintf "%s (%d)",
29     (File::Spec->splitpath ($_[1]))[2],
30     -s $_[1];
31     $info->set_label ($label);
32     $viewer->load_image ($_[1]);
33     });
34 root 1.12
35     $s;
36     }
37    
38     sub std_keys {
39     my $key = $_[1]->keyval;
40     my $state = $_[1]->state;
41    
42 root 1.21 my $ctrl = $state * "control-mask";
43 root 1.12
44     if ($key == $Gtk2::Gdk::Keysyms{q}) {
45     main_quit Gtk2;
46     } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) {
47 root 1.20 my $w = new Gtk2::Window;
48 root 1.26
49     $w->set_title ("CV: Schnauzer");
50 root 1.20 $w->add (my $s = new_schnauzer);
51     $s->set_dir (File::Spec->curdir);
52 root 1.25 $s->set_geometry_hints;
53 root 1.21 $w->show_all;
54 root 1.25
55 root 1.21 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{h}) {
56     unless ($help) {
57     require Gtk2::PodViewer;
58    
59     $help = new Gtk2::Window;
60 root 1.26 $help->set_title ("CV: Help");
61 root 1.21 $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;
72 root 1.12 } else {
73 root 1.19 #$mainwin->show_all;
74 root 1.12 $schnauzer->handle_key ($key, $state);
75     }
76    
77     1;
78     }
79    
80 root 1.20 {
81     $viewer = new Gtk2::CV::ImageWindow;
82 root 1.15
83 root 1.20 $viewer->set_title ("CV: Image");
84 root 1.15
85 root 1.20 $viewer->signal_connect (key_press_event => \&std_keys);
86     $viewer->signal_connect (delete_event => sub { main_quit Gtk2 });
87 root 1.13
88 root 1.20 $viewer->signal_connect (button3_press_event => sub {
89     $mainwin->visible
90     ? $mainwin->hide
91     : $mainwin->show_all;
92 root 1.23 1;
93 root 1.20 });
94    
95     $schnauzer = new_schnauzer;
96    
97     $mainwin = new Gtk2::Window;
98     $mainwin->set_title ("CV");
99     $mainwin->add (my $vbox = new Gtk2::VBox);
100 root 1.23 $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; });
101 root 1.20
102     $vbox->add ($schnauzer);
103 root 1.22 $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0);
104 root 1.20 $frame->add (my $hbox = new Gtk2::HBox 0, 0);
105     $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0);
106     $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0);
107 root 1.25
108     $schnauzer->set_geometry_hints;
109 root 1.20 }
110 root 1.12
111     if (@ARGV) {
112 root 1.30 $_ = Glib::filename_to_unicode $_ for @ARGV;
113 root 1.18 $schnauzer->set_paths (\@ARGV);
114 root 1.31 $schnauzer->show_all;
115 root 1.18 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
116 root 1.17 } else {
117 root 1.20 $schnauzer->set_dir (File::Spec->curdir);
118 root 1.19 $mainwin->show_all;
119 root 1.34 $viewer->show_all;
120 root 1.12 }
121    
122 root 1.35 $viewer->show_all;
123    
124 root 1.12 main Gtk2;
125 root 1.21
126     __DATA__
127 root 1.12
128 root 1.11 =head1 NAME
129    
130     cv - a fast gtk+ image viewer modeled after xv
131    
132     =head1 SYNOPSIS
133    
134     cv [file...]
135    
136     =head1 DESCRIPTION
137    
138     None yet.
139    
140     =head2 THE IMAGE WINDOW
141    
142     You can use the following keys in the image window:
143    
144     q quit the program
145     < half the image size
146     > double the image size
147     , shrink the image by 10%
148     . enlarge the image by 10%
149     n reset to normal size
150     m maximize to screensize
151     M maxime to screensize, respecting image aspect
152 root 1.26 ctrl-m toggle maxpect-always mode
153 root 1.11 u uncrop
154     r set scaling mode to 'nearest' (fastest)
155     s set scaling mode to 'bilinear' (default)
156     S set scaling mode to 'hyper' (slowest)
157     t rotate clockwise 90°
158     T rotate counterclockwise°
159     ctrl-v open a new visual schnauzer window for the current dir
160 root 1.28 ctrl-s rescan visual schnauzer files for updates/deletes etc.
161 root 1.31 ctrl-e run an editor ($CV_EDITOR or "gimp") on the current image.
162 root 1.11
163 root 1.33 And when playing movies, these additional keys are active:
164    
165     left rewind by 10 seconds
166     right forward by 10 seconds
167     down rewind by 60 seconds
168     up forward by 60 seconds
169     pg_up rewind by 600 seconds
170     pg_down forward by 600 seconds
171     o toggle on-screen display
172     p pause/unpause
173     escape stop playing
174     9 turn volume down
175     0 turn volume up
176    
177 root 1.11 The following keys are redirected to the default visual schnauzer window:
178    
179     space next image
180     backspace last image
181    
182     =head2 THE VISUAL SCHNAUZER
183    
184     You can use the following keys in the schnauzer window:
185    
186     space move to and display next image
187     backspace move to and display previous image
188     return display selected picture
189    
190     cursor keys move selection
191     page-up move one page up
192     page-down move one page down
193     home move to first file
194     end move to last file
195    
196 root 1.24 ctrl-d delete selected files WITHOUT ASKING AGAIN
197 root 1.11 ctrl-g generate icons for the selected files
198 root 1.24 ctrl-u update selected (or all) icons if neccessary
199 root 1.32 ctrl-a select all files
200 root 1.11
201 root 1.27 =head1 ENVIRONMENT
202    
203     =over 4
204    
205     =item CV_PRINT_DESTINATION
206    
207     The default (perl-style) destination to use in the print dialog.
208    
209     =back
210    
211 root 1.23 =head1 SECURITY CONSIDERATIONS
212    
213     CV uses Pixbuf to load images. Pixbuf is not considered safe for this
214     purpose, though (from the gtk-2.2 release notes):
215    
216     "While efforts have been made to make gdk-pixbuf robust against invalid
217     images, using gdk-pixbuf to load untrusted data is not recommended, due to
218     the likelyhood that there are additional problems where an invalid image
219     could cause gdk-pixbuf to crash or worse."
220    
221 root 1.11 =head1 BUGS/TODO
222 root 1.23
223     Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names
224     incompatible with utf-8 fails.
225 root 1.11
226     rotate on disk
227     print
228     lots of ui issues
229     save(?)
230     preferences
231 root 1.12 ctrl-u in schnauzer
232     shift-cursor in schnauzer
233 root 1.11
234     =head1 AUTHOR
235    
236     Marc Lehmann <cv@plan9.de>.
237    
238     =cut
239 root 1.1