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