ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/bin/cv
(Generate patch)

Comparing CV/bin/cv (file contents):
Revision 1.19 by root, Fri Nov 7 04:03:03 2003 UTC vs.
Revision 1.23 by root, Wed Nov 12 00:59:02 2003 UTC

8 8
9use Gtk2::CV; 9use Gtk2::CV;
10 10
11Gtk2::Rc->parse (Gtk2::CV::find_rcfile "gtkrc"); 11Gtk2::Rc->parse (Gtk2::CV::find_rcfile "gtkrc");
12 12
13use File::Spec;
14
15my $mainwin;
13my $viewer; 16my $viewer;
14my $schnauzer; 17my $schnauzer;
18my $info;
19my $help;
15 20
16sub new_schnauzer { 21sub new_schnauzer {
17 my $w = new Gtk2::Window;
18 $w->add (my $s = new Gtk2::CV::Schnauzer); 22 my $s = new Gtk2::CV::Schnauzer;
19 23
20 $s->signal_connect (activate => sub { $viewer->load_image ($_[1]) });
21 $s->signal_connect_after (key_press_event => \&std_keys); 24 $s->signal_connect_after (key_press_event => \&std_keys);
25 $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 });
22 32
23 $s; 33 $s;
24} 34}
25
26$schnauzer = new_schnauzer;
27
28my $mainwin = $schnauzer->get_toplevel;
29 35
30sub std_keys { 36sub std_keys {
31 my $key = $_[1]->keyval; 37 my $key = $_[1]->keyval;
32 my $state = $_[1]->state; 38 my $state = $_[1]->state;
33 39
34 my $ctrl = grep $_ eq "control-mask", @$state; 40 my $ctrl = $state * "control-mask";
35 41
36 if ($key == $Gtk2::Gdk::Keysyms{q}) { 42 if ($key == $Gtk2::Gdk::Keysyms{q}) {
37 main_quit Gtk2; 43 main_quit Gtk2;
38 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) { 44 } elsif ($ctrl && $key == $Gtk2::Gdk::Keysyms{v}) {
45 my $w = new Gtk2::Window;
39 my $s = new_schnauzer; 46 $w->add (my $s = new_schnauzer);
40 $s->set_dir ("."); 47 $s->set_dir (File::Spec->curdir);
41 $s->get_toplevel->show_all 48 $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;
42 } else { 66 } else {
43 #$mainwin->show_all; 67 #$mainwin->show_all;
44 $schnauzer->handle_key ($key, $state); 68 $schnauzer->handle_key ($key, $state);
45 } 69 }
46 70
47 1; 71 1;
48} 72}
49 73
74{
50$viewer = new Gtk2::CV::ImageWindow; 75 $viewer = new Gtk2::CV::ImageWindow;
51 76
52$viewer->set_title ("CV"); 77 $viewer->set_title ("CV: Image");
53 78
54$viewer->signal_connect (key_press_event => \&std_keys); 79 $viewer->signal_connect (key_press_event => \&std_keys);
55$viewer->signal_connect (delete_event => sub { main_quit Gtk2 }); 80 $viewer->signal_connect (delete_event => sub { main_quit Gtk2 });
56 81
57$viewer->signal_connect (button3_press_event => sub { 82 $viewer->signal_connect (button3_press_event => sub {
58 $mainwin->visible 83 $mainwin->visible
59 ? $mainwin->hide 84 ? $mainwin->hide
60 : $mainwin->show_all; 85 : $mainwin->show_all;
61}); 86 1;
87 });
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 $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; });
95
96 $vbox->add ($schnauzer);
97 $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0);
98 $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}
62 102
63if (@ARGV) { 103if (@ARGV) {
64 $schnauzer->set_paths (\@ARGV); 104 $schnauzer->set_paths (\@ARGV);
65 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); 105 $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []);
66} else { 106} else {
67 $schnauzer->set_dir ("."); 107 $schnauzer->set_dir (File::Spec->curdir);
68 $mainwin->show_all; 108 $mainwin->show_all;
69} 109}
70 110
71$viewer->show_all; 111$viewer->show_all;
72 112
73main Gtk2; 113main Gtk2;
114
115__DATA__
74 116
75=head1 NAME 117=head1 NAME
76 118
77cv - a fast gtk+ image viewer modeled after xv 119cv - a fast gtk+ image viewer modeled after xv
78 120
124 end move to last file 166 end move to last file
125 167
126 ctrl-g generate icons for the selected files 168 ctrl-g generate icons for the selected files
127 ctrl-d delete selected files WITHOUT ASKING AGAIN 169 ctrl-d delete selected files WITHOUT ASKING AGAIN
128 170
171=head1 SECURITY CONSIDERATIONS
172
173CV uses Pixbuf to load images. Pixbuf is not considered safe for this
174purpose, though (from the gtk-2.2 release notes):
175
176"While efforts have been made to make gdk-pixbuf robust against invalid
177images, using gdk-pixbuf to load untrusted data is not recommended, due to
178the likelyhood that there are additional problems where an invalid image
179could cause gdk-pixbuf to crash or worse."
180
129=head1 BUGS/TODO 181=head1 BUGS/TODO
182
183 Pixbuf doesn't honor G_BROKEN_FILENAMES, so accessing files with names
184 incompatible with utf-8 fails.
130 185
131 rotate on disk 186 rotate on disk
132 print 187 print
133 lots of ui issues 188 lots of ui issues
134 save(?) 189 save(?)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines