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; |
… | |
… | |
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 | }); |
34 | |
40 | |
|
|
41 | Gtk2::CV::Plugin->call (new_schnauzer => $s); |
|
|
42 | |
35 | $s; |
43 | $s; |
36 | } |
44 | } |
37 | |
45 | |
38 | sub std_keys { |
46 | sub std_keys { |
39 | my $key = $_[1]->keyval; |
47 | my $key = $_[1]->keyval; |
… | |
… | |
68 | $h->load_string (do { local $/; <DATA> }); |
76 | $h->load_string (do { local $/; <DATA> }); |
69 | } |
77 | } |
70 | |
78 | |
71 | $help->show_all; |
79 | $help->show_all; |
72 | } else { |
80 | } else { |
73 | #$mainwin->show_all; |
81 | return 0; |
74 | $schnauzer->handle_key ($key, $state); |
|
|
75 | } |
82 | } |
76 | |
83 | |
77 | 1; |
84 | 1 |
78 | } |
85 | } |
79 | |
86 | |
80 | { |
87 | { |
81 | $viewer = new Gtk2::CV::ImageWindow; |
88 | $viewer = new Gtk2::CV::ImageWindow; |
82 | |
89 | |
83 | $viewer->set_title ("CV: Image"); |
90 | $viewer->set_title ("CV: Image"); |
84 | |
91 | |
85 | $viewer->signal_connect (key_press_event => \&std_keys); |
92 | $viewer->signal_connect (key_press_event => sub { |
|
|
93 | &std_keys |
|
|
94 | or $schnauzer->signal_emit (key_press_event => $_[1]) |
|
|
95 | }); |
86 | $viewer->signal_connect (delete_event => sub { main_quit Gtk2 }); |
96 | $viewer->signal_connect (delete_event => sub { main_quit Gtk2 }); |
87 | |
97 | |
88 | $viewer->signal_connect (button3_press_event => sub { |
98 | $viewer->signal_connect (button3_press_event => sub { |
89 | $mainwin->visible |
99 | $mainwin->visible |
90 | ? $mainwin->hide |
100 | ? $mainwin->hide |
91 | : $mainwin->show_all; |
101 | : $mainwin->show_all; |
92 | 1; |
102 | 1; |
93 | }); |
103 | }); |
94 | |
104 | |
|
|
105 | Gtk2::CV::Plugin->call (new_imagewindow => $viewer); |
|
|
106 | |
95 | $schnauzer = new_schnauzer; |
107 | $schnauzer = new_schnauzer; |
96 | |
108 | |
97 | $mainwin = new Gtk2::Window; |
109 | $mainwin = new Gtk2::Window; |
98 | $mainwin->set_title ("CV"); |
110 | $mainwin->set_title ("CV"); |
99 | $mainwin->add (my $vbox = new Gtk2::VBox); |
111 | $mainwin->add (my $vbox = new Gtk2::VBox); |
100 | $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; }); |
112 | $mainwin->signal_connect (delete_event => sub { $mainwin->hide; 1; }); |
101 | |
113 | |
102 | $vbox->add ($schnauzer); |
114 | $vbox->add ($schnauzer); |
103 | $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0); |
115 | $vbox->pack_end (my $frame = new Gtk2::Frame, 0, 0, 0); |
104 | $frame->add (my $hbox = new Gtk2::HBox 0, 0); |
116 | $frame->add (my $hbox = new Gtk2::HBox 0, 0); |
105 | $hbox->pack_start ((new Gtk2::Label "Info"), 0, 0, 0); |
117 | $hbox->pack_start ((new Gtk2::Label "Info: "), 0, 0, 0); |
106 | $hbox->pack_start (($info = new Gtk2::Label), 1, 1, 0); |
118 | $hbox->pack_end (my $labelwindow = new Gtk2::EventBox, 1, 1, 0); |
|
|
119 | $labelwindow->add ($info = new Gtk2::Label); |
|
|
120 | $labelwindow->signal_connect_after (size_request => sub { $_[1]->width (0); 0 }); |
|
|
121 | $info->set (selectable => 1, xalign => 0, justify => "left"); |
107 | |
122 | |
108 | $schnauzer->set_geometry_hints; |
123 | $schnauzer->set_geometry_hints; |
109 | } |
124 | } |
110 | |
125 | |
111 | if (@ARGV) { |
126 | if (@ARGV) { |
112 | $_ = Glib::filename_to_unicode $_ for @ARGV; |
127 | $schnauzer->set_paths ([map Glib::filename_to_unicode $_, @ARGV]); |
113 | $schnauzer->set_paths (\@ARGV); |
|
|
114 | $schnauzer->show_all; |
128 | $schnauzer->show_all; |
115 | $viewer->show_all; |
|
|
116 | $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); |
129 | $schnauzer->handle_key ($Gtk2::Gdk::Keysyms{space}, []); |
117 | } else { |
130 | } else { |
118 | $schnauzer->set_dir (File::Spec->curdir); |
131 | $schnauzer->set_dir (File::Spec->curdir); |
119 | $mainwin->show_all; |
132 | $mainwin->show_all; |
120 | $viewer->show_all; |
133 | $viewer->show_all; |
121 | } |
134 | } |
|
|
135 | |
|
|
136 | $viewer->show_all; |
122 | |
137 | |
123 | main Gtk2; |
138 | main Gtk2; |
124 | |
139 | |
125 | __DATA__ |
140 | __DATA__ |
126 | |
141 | |
… | |
… | |
199 | |
214 | |
200 | =head1 ENVIRONMENT |
215 | =head1 ENVIRONMENT |
201 | |
216 | |
202 | =over 4 |
217 | =over 4 |
203 | |
218 | |
|
|
219 | =item CV_EDITOR |
|
|
220 | |
|
|
221 | The program that gets executed when the user presses C<CTRL-e> in the |
|
|
222 | Schnauzer or image window. The default is C<gimp>. |
|
|
223 | |
204 | =item CV_PRINT_DESTINATION |
224 | =item CV_PRINT_DESTINATION |
205 | |
225 | |
206 | The default (perl-style) destination to use in the print dialog. |
226 | The default (perl-style) destination to use in the print dialog. |
|
|
227 | |
|
|
228 | =item CV_TRASHCAN |
|
|
229 | |
|
|
230 | When set, must point to a directory where all files that are deleted are |
|
|
231 | moved to. If unset, files that are deleted are really being deleted. |
207 | |
232 | |
208 | =back |
233 | =back |
209 | |
234 | |
210 | =head1 SECURITY CONSIDERATIONS |
235 | =head1 SECURITY CONSIDERATIONS |
211 | |
236 | |