1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
|
|
2 | |
|
|
3 | use Cwd (); |
|
|
4 | use Encode (); |
2 | |
5 | |
3 | use Gtk2 -init; |
6 | use Gtk2 -init; |
4 | use Gtk2::Gdk::Keysyms; |
7 | use Gtk2::Gdk::Keysyms; |
5 | |
8 | |
6 | use Gtk2::CV::ImageWindow; |
9 | use Gtk2::CV::ImageWindow; |
… | |
… | |
9 | use Gtk2::CV; |
12 | use Gtk2::CV; |
10 | |
13 | |
11 | Gtk2::Rc->parse (Gtk2::CV::find_rcfile "gtkrc"); |
14 | Gtk2::Rc->parse (Gtk2::CV::find_rcfile "gtkrc"); |
12 | |
15 | |
13 | use File::Spec; |
16 | use File::Spec; |
|
|
17 | |
|
|
18 | require Gtk2::CV::Plugin; |
|
|
19 | require "$ENV{HOME}/.cvrc" if -r "$ENV{HOME}/.cvrc"; |
14 | |
20 | |
15 | my $mainwin; |
21 | my $mainwin; |
16 | my $viewer; |
22 | my $viewer; |
17 | my $schnauzer; |
23 | my $schnauzer; |
18 | my $info; |
24 | my $info; |
… | |
… | |
29 | (File::Spec->splitpath ($_[1]))[2], |
35 | (File::Spec->splitpath ($_[1]))[2], |
30 | -s $_[1]; |
36 | -s $_[1]; |
31 | $info->set_label ($label); |
37 | $info->set_label ($label); |
32 | $viewer->load_image ($_[1]); |
38 | $viewer->load_image ($_[1]); |
33 | }); |
39 | }); |
|
|
40 | $s->signal_connect (chdir => sub { |
|
|
41 | my ($self, $dir) = @_; |
|
|
42 | |
|
|
43 | my $path = Cwd::abs_path $dir; |
|
|
44 | |
|
|
45 | $self->realize; |
|
|
46 | $self->window->property_change ( |
|
|
47 | Gtk2::Gdk::Atom->intern ("_X_CWD", 0), |
|
|
48 | Gtk2::Gdk::Atom->intern ("UTF8_STRING", 0), |
|
|
49 | Gtk2::Gdk::CHARS, 'replace', |
|
|
50 | Encode::encode_utf8 $path, |
|
|
51 | ); |
|
|
52 | }); |
|
|
53 | |
|
|
54 | Gtk2::CV::Plugin->call (new_schnauzer => $s); |
34 | |
55 | |
35 | $s; |
56 | $s; |
36 | } |
57 | } |
37 | |
58 | |
38 | sub std_keys { |
59 | sub std_keys { |
… | |
… | |
68 | $h->load_string (do { local $/; <DATA> }); |
89 | $h->load_string (do { local $/; <DATA> }); |
69 | } |
90 | } |
70 | |
91 | |
71 | $help->show_all; |
92 | $help->show_all; |
72 | } else { |
93 | } else { |
73 | #$mainwin->show_all; |
94 | return 0; |
74 | $schnauzer->handle_key ($key, $state); |
|
|
75 | } |
95 | } |
76 | |
96 | |
77 | 1; |
97 | 1 |
78 | } |
98 | } |
79 | |
99 | |
80 | { |
100 | { |
81 | $viewer = new Gtk2::CV::ImageWindow; |
101 | $viewer = new Gtk2::CV::ImageWindow; |
82 | |
102 | |
83 | $viewer->set_title ("CV: Image"); |
103 | $viewer->set_title ("CV: Image"); |
84 | |
104 | |
85 | $viewer->signal_connect (key_press_event => \&std_keys); |
105 | $viewer->signal_connect (key_press_event => sub { |
|
|
106 | &std_keys |
|
|
107 | or $schnauzer->signal_emit (key_press_event => $_[1]) |
|
|
108 | }); |
86 | $viewer->signal_connect (delete_event => sub { main_quit Gtk2 }); |
109 | $viewer->signal_connect (delete_event => sub { main_quit Gtk2 }); |
87 | |
110 | |
88 | $viewer->signal_connect (button3_press_event => sub { |
111 | $viewer->signal_connect (button3_press_event => sub { |
89 | $mainwin->visible |
112 | $mainwin->visible |
90 | ? $mainwin->hide |
113 | ? $mainwin->hide |
91 | : $mainwin->show_all; |
114 | : $mainwin->show_all; |
92 | 1; |
115 | 1; |
93 | }); |
116 | }); |
94 | |
117 | |
|
|
118 | Gtk2::CV::Plugin->call (new_imagewindow => $viewer); |
|
|
119 | |
95 | $schnauzer = new_schnauzer; |
120 | $schnauzer = new_schnauzer; |
96 | |
121 | |
97 | $mainwin = new Gtk2::Window; |
122 | $mainwin = new Gtk2::Window; |
98 | $mainwin->set_title ("CV"); |
123 | $mainwin->set_title ("CV"); |
99 | $mainwin->add (my $vbox = new Gtk2::VBox); |
124 | $mainwin->add (my $vbox = new Gtk2::VBox); |
… | |
… | |
102 | $vbox->add ($schnauzer); |
127 | $vbox->add ($schnauzer); |
103 | $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0); |
128 | $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0); |
104 | $frame->add (my $hbox = new Gtk2::HBox 0, 0); |
129 | $frame->add (my $hbox = new Gtk2::HBox 0, 0); |
105 | $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0); |
130 | $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0); |
106 | $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0); |
131 | $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0); |
|
|
132 | $info->set (wrap => 1); |
107 | |
133 | |
108 | $schnauzer->set_geometry_hints; |
134 | $schnauzer->set_geometry_hints; |
109 | } |
135 | } |
110 | |
136 | |
111 | if (@ARGV) { |
137 | if (@ARGV) { |
112 | $_ = Glib::filename_to_unicode $_ for @ARGV; |
138 | $schnauzer->set_paths ([map Glib::filename_to_unicode $_, @ARGV]); |
113 | $schnauzer->set_paths (\@ARGV); |
|
|
114 | $schnauzer->show_all; |
139 | $schnauzer->show_all; |
115 | $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); |
140 | $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); |
116 | } else { |
141 | } else { |
117 | $schnauzer->set_dir (File::Spec->curdir); |
142 | $schnauzer->set_dir (File::Spec->curdir); |
118 | $mainwin->show_all; |
143 | $mainwin->show_all; |
… | |
… | |
200 | |
225 | |
201 | =head1 ENVIRONMENT |
226 | =head1 ENVIRONMENT |
202 | |
227 | |
203 | =over 4 |
228 | =over 4 |
204 | |
229 | |
|
|
230 | =item CV_EDITOR |
|
|
231 | |
|
|
232 | The program that gets executed when the user presses C<CTRL-e> in the |
|
|
233 | Schnauzer or image window. The default is C<gimp>. |
|
|
234 | |
205 | =item CV_PRINT_DESTINATION |
235 | =item CV_PRINT_DESTINATION |
206 | |
236 | |
207 | The default (perl-style) destination to use in the print dialog. |
237 | The default (perl-style) destination to use in the print dialog. |
|
|
238 | |
|
|
239 | =item CV_TRASHCAN |
|
|
240 | |
|
|
241 | When set, must point to a directory where all files that are deleted are |
|
|
242 | moved to. If unset, files that are deleted are really being deleted. |
208 | |
243 | |
209 | =back |
244 | =back |
210 | |
245 | |
211 | =head1 SECURITY CONSIDERATIONS |
246 | =head1 SECURITY CONSIDERATIONS |
212 | |
247 | |