ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/bin/cv
Revision: 1.25
Committed: Wed Nov 12 19:36:06 2003 UTC (20 years, 8 months ago) by root
Branch: MAIN
Changes since 1.24: +6 -0 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     $w->add (my $s = new_schnauzer);
49     $s->set_dir (File::Spec->curdir);
50 root 1.25 $s->set_geometry_hints;
51 root 1.21 $w->show_all;
52 root 1.25
53 root 1.21 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{h}) {
54     unless ($help) {
55     require Gtk2::PodViewer;
56    
57     $help = new Gtk2::Window;
58     $help->set_title ("CV Help");
59     $help->set_default_size (500, 300);
60     $help->signal_connect (delete_event => sub { $help->hide; 1 });
61    
62     $help->add (my $sw = new Gtk2::ScrolledWindow);
63     $sw->add (my $h = new Gtk2::PodViewer);
64    
65     #binmode DATA, ":utf8";
66     $h->load_string (do { local $/; <DATA> });
67     }
68    
69     $help->show_all;
70 root 1.12 } else {
71 root 1.19 #$mainwin->show_all;
72 root 1.12 $schnauzer->handle_key ($key, $state);
73     }
74    
75     1;
76     }
77    
78 root 1.20 {
79     $viewer = new Gtk2::CV::ImageWindow;
80 root 1.15
81 root 1.20 $viewer->set_title ("CV: Image");
82 root 1.15
83 root 1.20 $viewer->signal_connect (key_press_event => \&std_keys);
84     $viewer->signal_connect (delete_event => sub { main_quit Gtk2 });
85 root 1.13
86 root 1.20 $viewer->signal_connect (button3_press_event => sub {
87     $mainwin->visible
88     ? $mainwin->hide
89     : $mainwin->show_all;
90 root 1.23 1;
91 root 1.20 });
92    
93     $schnauzer = new_schnauzer;
94    
95     $mainwin = new Gtk2::Window;
96     $mainwin->set_title ("CV");
97     $mainwin->add (my $vbox = new Gtk2::VBox);
98 root 1.23 $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; });
99 root 1.20
100     $vbox->add ($schnauzer);
101 root 1.22 $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0);
102 root 1.20 $frame->add (my $hbox = new Gtk2::HBox 0, 0);
103     $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0);
104     $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0);
105 root 1.25
106     $schnauzer->set_geometry_hints;
107 root 1.20 }
108 root 1.12
109     if (@ARGV) {
110 root 1.18 $schnauzer->set_paths (\@ARGV);
111     $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
112 root 1.17 } else {
113 root 1.20 $schnauzer->set_dir (File::Spec->curdir);
114 root 1.19 $mainwin->show_all;
115 root 1.12 }
116    
117     $viewer->show_all;
118    
119     main Gtk2;
120 root 1.21
121     __DATA__
122 root 1.12
123 root 1.11 =head1 NAME
124    
125     cv - a fast gtk+ image viewer modeled after xv
126    
127     =head1 SYNOPSIS
128    
129     cv [file...]
130    
131     =head1 DESCRIPTION
132    
133     None yet.
134    
135     =head2 THE IMAGE WINDOW
136    
137     You can use the following keys in the image window:
138    
139     q quit the program
140     < half the image size
141     > double the image size
142     , shrink the image by 10%
143     . enlarge the image by 10%
144     n reset to normal size
145     m maximize to screensize
146     M maxime to screensize, respecting image aspect
147     u uncrop
148     r set scaling mode to 'nearest' (fastest)
149     s set scaling mode to 'bilinear' (default)
150     S set scaling mode to 'hyper' (slowest)
151     t rotate clockwise 90°
152     T rotate counterclockwise°
153     ctrl-v open a new visual schnauzer window for the current dir
154    
155     The following keys are redirected to the default visual schnauzer window:
156    
157     space next image
158     backspace last image
159    
160     =head2 THE VISUAL SCHNAUZER
161    
162     You can use the following keys in the schnauzer window:
163    
164     space move to and display next image
165     backspace move to and display previous image
166     return display selected picture
167    
168     cursor keys move selection
169     page-up move one page up
170     page-down move one page down
171     home move to first file
172     end move to last file
173    
174 root 1.24 ctrl-d delete selected files WITHOUT ASKING AGAIN
175 root 1.11 ctrl-g generate icons for the selected files
176 root 1.24 ctrl-u update selected (or all) icons if neccessary
177 root 1.11
178 root 1.23 =head1 SECURITY CONSIDERATIONS
179    
180     CV uses Pixbuf to load images. Pixbuf is not considered safe for this
181     purpose, though (from the gtk-2.2 release notes):
182    
183     "While efforts have been made to make gdk-pixbuf robust against invalid
184     images, using gdk-pixbuf to load untrusted data is not recommended, due to
185     the likelyhood that there are additional problems where an invalid image
186     could cause gdk-pixbuf to crash or worse."
187    
188 root 1.11 =head1 BUGS/TODO
189 root 1.23
190     Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names
191     incompatible with utf-8 fails.
192 root 1.11
193     rotate on disk
194     print
195     lots of ui issues
196     save(?)
197     preferences
198 root 1.12 ctrl-u in schnauzer
199     shift-cursor in schnauzer
200 root 1.11
201     =head1 AUTHOR
202    
203     Marc Lehmann <cv@plan9.de>.
204    
205     =cut
206 root 1.1