ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/bin/cv
Revision: 1.21
Committed: Sat Nov 8 01:00:08 2003 UTC (20 years, 8 months ago) by root
Branch: MAIN
Changes since 1.20: +22 -2 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     });
87    
88     $schnauzer = new_schnauzer;
89    
90     $mainwin = new Gtk2::Window;
91     $mainwin->set_title ("CV");
92     $mainwin->add (my $vbox = new Gtk2::VBox);
93    
94     $vbox->add ($schnauzer);
95     $vbox->add (my $frame = new Gtk2::Frame);
96     $frame->add (my $hbox = new Gtk2::HBox 0, 0);
97     $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0);
98     $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0);
99     }
100 root 1.12
101     if (@ARGV) {
102 root 1.18 $schnauzer->set_paths (\@ARGV);
103     $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
104 root 1.17 } else {
105 root 1.20 $schnauzer->set_dir (File::Spec->curdir);
106 root 1.19 $mainwin->show_all;
107 root 1.12 }
108    
109     $viewer->show_all;
110    
111     main Gtk2;
112 root 1.21
113     __DATA__
114 root 1.12
115 root 1.11 =head1 NAME
116    
117     cv - a fast gtk+ image viewer modeled after xv
118    
119     =head1 SYNOPSIS
120    
121     cv [file...]
122    
123     =head1 DESCRIPTION
124    
125     None yet.
126    
127     =head2 THE IMAGE WINDOW
128    
129     You can use the following keys in the image window:
130    
131     q quit the program
132     < half the image size
133     > double the image size
134     , shrink the image by 10%
135     . enlarge the image by 10%
136     n reset to normal size
137     m maximize to screensize
138     M maxime to screensize, respecting image aspect
139     u uncrop
140     r set scaling mode to 'nearest' (fastest)
141     s set scaling mode to 'bilinear' (default)
142     S set scaling mode to 'hyper' (slowest)
143     t rotate clockwise 90°
144     T rotate counterclockwise°
145     ctrl-v open a new visual schnauzer window for the current dir
146    
147     The following keys are redirected to the default visual schnauzer window:
148    
149     space next image
150     backspace last image
151    
152     =head2 THE VISUAL SCHNAUZER
153    
154     You can use the following keys in the schnauzer window:
155    
156     space move to and display next image
157     backspace move to and display previous image
158     return display selected picture
159    
160     cursor keys move selection
161     page-up move one page up
162     page-down move one page down
163     home move to first file
164     end move to last file
165    
166     ctrl-g generate icons for the selected files
167     ctrl-d delete selected files WITHOUT ASKING AGAIN
168    
169     =head1 BUGS/TODO
170    
171     rotate on disk
172     print
173     lots of ui issues
174     save(?)
175     preferences
176 root 1.12 ctrl-u in schnauzer
177     shift-cursor in schnauzer
178 root 1.11
179     =head1 AUTHOR
180    
181     Marc Lehmann <cv@plan9.de>.
182    
183     =cut
184 root 1.1