ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/lib/Gtk2/CV.pm
Revision: 1.31
Committed: Sat Oct 28 23:09:02 2006 UTC (17 years, 8 months ago) by root
Branch: MAIN
Changes since 1.30: +3 -2 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 package Gtk2::CV;
2
3 use Gtk2;
4 use Glib;
5
6 use IO::AIO;
7
8 BEGIN {
9 use XSLoader;
10
11 $VERSION = '1.3';
12
13 XSLoader::load "Gtk2::CV", $VERSION;
14 }
15
16 my $aio_source;
17
18 IO::AIO::min_parallel 32;
19 IO::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.
23 sub 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
35 sub disable_aio {
36 remove Glib::Source $aio_source if $aio_source;
37 undef $aio_source;
38 }
39
40 enable_aio;
41
42 sub find_rcfile($) {
43 my $path;
44
45 for (@INC) {
46 $path = "$_/Gtk2/CV/$_[0]";
47 return $path if -r $path;
48 }
49
50 die "FATAL: can't find required file $_[0]\n";
51 }
52
53 sub require_image($) {
54 new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
55 }
56
57 sub dealpha_compose($) {
58 return $_[0] unless $_[0]->get_has_alpha;
59
60 Gtk2::CV::dealpha_expose $_[0]->composite_color_simple (
61 $_[0]->get_width, $_[0]->get_height,
62 'nearest', 255, 16, 0xffc0c0c0, 0xff606060,
63 )
64 }
65
66 # TODO: make preferences
67 sub dealpha($) {
68 &dealpha_compose
69 }
70
71 1;
72