ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/lib/Gtk2/CV.pm
(Generate patch)

Comparing CV/lib/Gtk2/CV.pm (file contents):
Revision 1.3 by root, Mon Nov 3 16:44:19 2003 UTC vs.
Revision 1.23 by root, Wed Sep 7 17:17:39 2005 UTC

1package Gtk2::CV; 1package Gtk2::CV;
2 2
3use XSLoader; 3use Gtk2;
4use Glib;
4 5
5$VERSION = 0.1; 6use IO::AIO;
6 7
7XSLoader::load "Gtk2::CV", $VERSION; 8BEGIN {
9 use XSLoader;
8 10
9use Gtk2; 11 $VERSION = '1.0';
10 12
11sub require_image { 13 XSLoader::load "Gtk2::CV", $VERSION;
14}
15
16my $aio_source;
17
18# we use a low priority to give GUI interactions as high a priority
19# as possible.
20sub 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
28sub disable_aio {
29 remove Glib::Source $aio_source if $aio_source;
30 undef $aio_source;
31}
32
33enable_aio;
34IO::AIO::max_outstanding 128;
35
36sub find_rcfile($) {
12 my $path; 37 my $path;
13 38
14 for (@INC) { 39 for (@INC) {
15 $path = "$_/Gtk2/CV/images/$_[0]"; 40 $path = "$_/Gtk2/CV/$_[0]";
16 last if -r $path; 41 return $path if -r $path;
17 } 42 }
18 43
19 eval { new_from_file Gtk2::Gdk::Pixbuf $path } 44 die "FATAL: can't find required file $_[0]\n";
20 or die "can't find image $_[0] in \@INC"; 45}
46
47sub require_image($) {
48 new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
49}
50
51sub 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 'nearest', 255, 16, 0xffc0c0c0, 0xff606060,
57 )
58}
59
60# TODO: make preferences
61sub dealpha($) {
62 &dealpha_compose
21} 63}
22 64
231; 651;
24 66

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines