… | |
… | |
14 | |
14 | |
15 | my $mainwin; |
15 | my $mainwin; |
16 | my $viewer; |
16 | my $viewer; |
17 | my $schnauzer; |
17 | my $schnauzer; |
18 | my $info; |
18 | my $info; |
|
|
19 | my $help; |
|
|
20 | |
|
|
21 | my $schnauzer_idx = 0; |
19 | |
22 | |
20 | sub new_schnauzer { |
23 | sub new_schnauzer { |
21 | my $s = new Gtk2::CV::Schnauzer; |
24 | my $s = new Gtk2::CV::Schnauzer; |
22 | |
25 | |
23 | $s->signal_connect_after (key_press_event => \&std_keys); |
26 | $s->signal_connect_after (key_press_event => \&std_keys); |
… | |
… | |
34 | |
37 | |
35 | sub std_keys { |
38 | sub std_keys { |
36 | my $key = $_[1]->keyval; |
39 | my $key = $_[1]->keyval; |
37 | my $state = $_[1]->state; |
40 | my $state = $_[1]->state; |
38 | |
41 | |
39 | my $ctrl = grep $_ eq "control-mask", @$state; |
42 | my $ctrl = $state * "control-mask"; |
40 | |
43 | |
41 | if ($key == $Gtk2::Gdk::Keysyms{q}) { |
44 | if ($key == $Gtk2::Gdk::Keysyms{q}) { |
42 | main_quit Gtk2; |
45 | main_quit Gtk2; |
43 | } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) { |
46 | } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) { |
44 | my $w = new Gtk2::Window; |
47 | my $w = new Gtk2::Window; |
45 | $w->add (my $s = new_schnauzer); |
48 | $w->add (my $s = new_schnauzer); |
46 | $s->set_dir (File::Spec->curdir); |
49 | $s->set_dir (File::Spec->curdir); |
|
|
50 | $s->set_geometry_hints; |
47 | $w->show_all |
51 | $w->show_all; |
|
|
52 | |
|
|
53 | } 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; |
48 | } else { |
70 | } else { |
49 | #$mainwin->show_all; |
71 | #$mainwin->show_all; |
50 | $schnauzer->handle_key ($key, $state); |
72 | $schnauzer->handle_key ($key, $state); |
51 | } |
73 | } |
52 | |
74 | |
… | |
… | |
63 | |
85 | |
64 | $viewer->signal_connect (button3_press_event => sub { |
86 | $viewer->signal_connect (button3_press_event => sub { |
65 | $mainwin->visible |
87 | $mainwin->visible |
66 | ? $mainwin->hide |
88 | ? $mainwin->hide |
67 | : $mainwin->show_all; |
89 | : $mainwin->show_all; |
|
|
90 | 1; |
68 | }); |
91 | }); |
69 | |
92 | |
70 | $schnauzer = new_schnauzer; |
93 | $schnauzer = new_schnauzer; |
71 | |
94 | |
72 | $mainwin = new Gtk2::Window; |
95 | $mainwin = new Gtk2::Window; |
73 | $mainwin->set_title ("CV"); |
96 | $mainwin->set_title ("CV"); |
74 | $mainwin->add (my $vbox = new Gtk2::VBox); |
97 | $mainwin->add (my $vbox = new Gtk2::VBox); |
|
|
98 | $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; }); |
75 | |
99 | |
76 | $vbox->add ($schnauzer); |
100 | $vbox->add ($schnauzer); |
77 | $vbox->add (my $frame = new Gtk2::Frame); |
101 | $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0); |
78 | $frame->add (my $hbox = new Gtk2::HBox 0, 0); |
102 | $frame->add (my $hbox = new Gtk2::HBox 0, 0); |
79 | $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0); |
103 | $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0); |
80 | $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0); |
104 | $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0); |
|
|
105 | |
|
|
106 | $schnauzer->set_geometry_hints; |
81 | } |
107 | } |
82 | |
108 | |
83 | if (@ARGV) { |
109 | if (@ARGV) { |
84 | $schnauzer->set_paths (\@ARGV); |
110 | $schnauzer->set_paths (\@ARGV); |
85 | $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); |
111 | $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); |
… | |
… | |
89 | } |
115 | } |
90 | |
116 | |
91 | $viewer->show_all; |
117 | $viewer->show_all; |
92 | |
118 | |
93 | main Gtk2; |
119 | main Gtk2; |
|
|
120 | |
|
|
121 | __DATA__ |
94 | |
122 | |
95 | =head1 NAME |
123 | =head1 NAME |
96 | |
124 | |
97 | cv - a fast gtk+ image viewer modeled after xv |
125 | cv - a fast gtk+ image viewer modeled after xv |
98 | |
126 | |
… | |
… | |
141 | page-up move one page up |
169 | page-up move one page up |
142 | page-down move one page down |
170 | page-down move one page down |
143 | home move to first file |
171 | home move to first file |
144 | end move to last file |
172 | end move to last file |
145 | |
173 | |
|
|
174 | ctrl-d delete selected files WITHOUT ASKING AGAIN |
146 | ctrl-g generate icons for the selected files |
175 | ctrl-g generate icons for the selected files |
147 | ctrl-d delete selected files WITHOUT ASKING AGAIN |
176 | ctrl-u update selected (or all) icons if neccessary |
|
|
177 | |
|
|
178 | =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." |
148 | |
187 | |
149 | =head1 BUGS/TODO |
188 | =head1 BUGS/TODO |
|
|
189 | |
|
|
190 | Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names |
|
|
191 | incompatible with utf-8 fails. |
150 | |
192 | |
151 | rotate on disk |
193 | rotate on disk |
152 | print |
194 | print |
153 | lots of ui issues |
195 | lots of ui issues |
154 | save(?) |
196 | save(?) |