1 | package Gtk2::CV; |
1 | package Gtk2::CV; |
2 | |
2 | |
3 | use XSLoader; |
3 | use Gtk2; |
|
|
4 | use Glib; |
4 | |
5 | |
5 | $VERSION = "0.14"; |
6 | use IO::AIO; |
6 | |
7 | |
7 | XSLoader::load "Gtk2::CV", $VERSION; |
8 | BEGIN { |
|
|
9 | use XSLoader; |
8 | |
10 | |
9 | use Gtk2; |
11 | $VERSION = '1.3'; |
|
|
12 | |
|
|
13 | XSLoader::load "Gtk2::CV", $VERSION; |
|
|
14 | } |
|
|
15 | |
|
|
16 | my $aio_source; |
|
|
17 | |
|
|
18 | # we use a low priority to give GUI interactions as high a priority |
|
|
19 | # as possible. |
|
|
20 | sub enable_aio { |
|
|
21 | $aio_source ||= |
|
|
22 | add_watch Glib::IO IO::AIO::poll_fileno, |
|
|
23 | in => sub { IO::AIO::poll_cb; 1 }, |
|
|
24 | undef, |
|
|
25 | &Glib::G_PRIORITY_LOW; |
|
|
26 | } |
|
|
27 | |
|
|
28 | sub disable_aio { |
|
|
29 | remove Glib::Source $aio_source if $aio_source; |
|
|
30 | undef $aio_source; |
|
|
31 | } |
|
|
32 | |
|
|
33 | enable_aio; |
10 | |
34 | |
11 | sub find_rcfile($) { |
35 | sub find_rcfile($) { |
12 | my $path; |
36 | my $path; |
13 | |
37 | |
14 | for (@INC) { |
38 | for (@INC) { |
… | |
… | |
21 | |
45 | |
22 | sub require_image($) { |
46 | sub require_image($) { |
23 | new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]"; |
47 | new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]"; |
24 | } |
48 | } |
25 | |
49 | |
|
|
50 | sub dealpha_compose($) { |
|
|
51 | return $_[0] unless $_[0]->get_has_alpha; |
|
|
52 | |
|
|
53 | Gtk2::CV::dealpha_expose $_[0]->composite_color_simple ( |
|
|
54 | $_[0]->get_width, $_[0]->get_height, |
|
|
55 | 'nearest', 255, 16, 0xffc0c0c0, 0xff606060, |
|
|
56 | ) |
|
|
57 | } |
|
|
58 | |
|
|
59 | # TODO: make preferences |
|
|
60 | sub dealpha($) { |
|
|
61 | &dealpha_compose |
|
|
62 | } |
|
|
63 | |
26 | 1; |
64 | 1; |
27 | |
65 | |