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.2 by root, Mon Nov 3 01:27:37 2003 UTC vs.
Revision 1.33 by root, Sat Mar 17 13:12:20 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines