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.12 |
|
20 |
|
|
sub new_schnauzer { |
21 |
root |
1.20 |
my $s = new Gtk2::CV::Schnauzer; |
22 |
root |
1.12 |
|
23 |
|
|
$s->signal_connect_after (key_press_event => \&std_keys); |
24 |
root |
1.20 |
$s->signal_connect (activate => sub { |
25 |
|
|
my $label = sprintf "%s (%d)", |
26 |
|
|
(File::Spec->splitpath ($_[1]))[2], |
27 |
|
|
-s $_[1]; |
28 |
|
|
$info->set_label ($label); |
29 |
|
|
$viewer->load_image ($_[1]); |
30 |
|
|
}); |
31 |
root |
1.12 |
|
32 |
|
|
$s; |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
sub std_keys { |
36 |
|
|
my $key = $_[1]->keyval; |
37 |
|
|
my $state = $_[1]->state; |
38 |
|
|
|
39 |
|
|
my $ctrl = grep $_ eq "control-mask", @$state; |
40 |
|
|
|
41 |
|
|
if ($key == $Gtk2::Gdk::Keysyms{q}) { |
42 |
|
|
main_quit Gtk2; |
43 |
|
|
} elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) { |
44 |
root |
1.20 |
my $w = new Gtk2::Window; |
45 |
|
|
$w->add (my $s = new_schnauzer); |
46 |
|
|
$s->set_dir (File::Spec->curdir); |
47 |
|
|
$w->show_all |
48 |
root |
1.12 |
} else { |
49 |
root |
1.19 |
#$mainwin->show_all; |
50 |
root |
1.12 |
$schnauzer->handle_key ($key, $state); |
51 |
|
|
} |
52 |
|
|
|
53 |
|
|
1; |
54 |
|
|
} |
55 |
|
|
|
56 |
root |
1.20 |
{ |
57 |
|
|
$viewer = new Gtk2::CV::ImageWindow; |
58 |
root |
1.15 |
|
59 |
root |
1.20 |
$viewer->set_title ("CV: Image"); |
60 |
root |
1.15 |
|
61 |
root |
1.20 |
$viewer->signal_connect (key_press_event => \&std_keys); |
62 |
|
|
$viewer->signal_connect (delete_event => sub { main_quit Gtk2 }); |
63 |
root |
1.13 |
|
64 |
root |
1.20 |
$viewer->signal_connect (button3_press_event => sub { |
65 |
|
|
$mainwin->visible |
66 |
|
|
? $mainwin->hide |
67 |
|
|
: $mainwin->show_all; |
68 |
|
|
}); |
69 |
|
|
|
70 |
|
|
$schnauzer = new_schnauzer; |
71 |
|
|
|
72 |
|
|
$mainwin = new Gtk2::Window; |
73 |
|
|
$mainwin->set_title ("CV"); |
74 |
|
|
$mainwin->add (my $vbox = new Gtk2::VBox); |
75 |
|
|
|
76 |
|
|
$vbox->add ($schnauzer); |
77 |
|
|
$vbox->add (my $frame = new Gtk2::Frame); |
78 |
|
|
$frame->add (my $hbox = new Gtk2::HBox 0, 0); |
79 |
|
|
$hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0); |
80 |
|
|
$hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0); |
81 |
|
|
} |
82 |
root |
1.12 |
|
83 |
|
|
if (@ARGV) { |
84 |
root |
1.18 |
$schnauzer->set_paths (\@ARGV); |
85 |
|
|
$schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); |
86 |
root |
1.17 |
} else { |
87 |
root |
1.20 |
$schnauzer->set_dir (File::Spec->curdir); |
88 |
root |
1.19 |
$mainwin->show_all; |
89 |
root |
1.12 |
} |
90 |
|
|
|
91 |
|
|
$viewer->show_all; |
92 |
|
|
|
93 |
|
|
main Gtk2; |
94 |
|
|
|
95 |
root |
1.11 |
=head1 NAME |
96 |
|
|
|
97 |
|
|
cv - a fast gtk+ image viewer modeled after xv |
98 |
|
|
|
99 |
|
|
=head1 SYNOPSIS |
100 |
|
|
|
101 |
|
|
cv [file...] |
102 |
|
|
|
103 |
|
|
=head1 DESCRIPTION |
104 |
|
|
|
105 |
|
|
None yet. |
106 |
|
|
|
107 |
|
|
=head2 THE IMAGE WINDOW |
108 |
|
|
|
109 |
|
|
You can use the following keys in the image window: |
110 |
|
|
|
111 |
|
|
q quit the program |
112 |
|
|
< half the image size |
113 |
|
|
> double the image size |
114 |
|
|
, shrink the image by 10% |
115 |
|
|
. enlarge the image by 10% |
116 |
|
|
n reset to normal size |
117 |
|
|
m maximize to screensize |
118 |
|
|
M maxime to screensize, respecting image aspect |
119 |
|
|
u uncrop |
120 |
|
|
r set scaling mode to 'nearest' (fastest) |
121 |
|
|
s set scaling mode to 'bilinear' (default) |
122 |
|
|
S set scaling mode to 'hyper' (slowest) |
123 |
|
|
t rotate clockwise 90° |
124 |
|
|
T rotate counterclockwise° |
125 |
|
|
ctrl-v open a new visual schnauzer window for the current dir |
126 |
|
|
|
127 |
|
|
The following keys are redirected to the default visual schnauzer window: |
128 |
|
|
|
129 |
|
|
space next image |
130 |
|
|
backspace last image |
131 |
|
|
|
132 |
|
|
=head2 THE VISUAL SCHNAUZER |
133 |
|
|
|
134 |
|
|
You can use the following keys in the schnauzer window: |
135 |
|
|
|
136 |
|
|
space move to and display next image |
137 |
|
|
backspace move to and display previous image |
138 |
|
|
return display selected picture |
139 |
|
|
|
140 |
|
|
cursor keys move selection |
141 |
|
|
page-up move one page up |
142 |
|
|
page-down move one page down |
143 |
|
|
home move to first file |
144 |
|
|
end move to last file |
145 |
|
|
|
146 |
|
|
ctrl-g generate icons for the selected files |
147 |
|
|
ctrl-d delete selected files WITHOUT ASKING AGAIN |
148 |
|
|
|
149 |
|
|
=head1 BUGS/TODO |
150 |
|
|
|
151 |
|
|
rotate on disk |
152 |
|
|
print |
153 |
|
|
lots of ui issues |
154 |
|
|
save(?) |
155 |
|
|
preferences |
156 |
root |
1.12 |
ctrl-u in schnauzer |
157 |
|
|
shift-cursor in schnauzer |
158 |
root |
1.11 |
|
159 |
|
|
=head1 AUTHOR |
160 |
|
|
|
161 |
|
|
Marc Lehmann <cv@plan9.de>. |
162 |
|
|
|
163 |
|
|
=cut |
164 |
root |
1.1 |
|