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