ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/lib/Gtk2/CV.pm
Revision: 1.32
Committed: Thu Nov 2 00:09:15 2006 UTC (17 years, 8 months ago) by root
Branch: MAIN
Changes since 1.31: +5 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
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.30 IO::AIO::min_parallel 32;
19 root 1.31 IO::AIO::max_poll_time 0.01;
20 root 1.30
21 root 1.28 # we use a low priority watcher to give GUI interactions as high a priority
22 root 1.19 # as possible.
23 root 1.17 sub enable_aio {
24     $aio_source ||=
25     add_watch Glib::IO IO::AIO::poll_fileno,
26 root 1.28 in => sub {
27 root 1.31 eval { IO::AIO::poll_cb };
28     warn $@ if $@;#d#
29 root 1.28 1
30     },
31     undef,
32     &Glib::G_PRIORITY_LOW;
33 root 1.17 }
34    
35     sub disable_aio {
36 root 1.18 remove Glib::Source $aio_source if $aio_source;
37 root 1.17 undef $aio_source;
38     }
39    
40 root 1.32 sub flush_aio {
41     enable_aio;
42     IO::AIO::flush;
43     }
44    
45 root 1.17 enable_aio;
46 root 1.2
47 root 1.9 sub find_rcfile($) {
48 root 1.2 my $path;
49    
50     for (@INC) {
51 root 1.4 $path = "$_/Gtk2/CV/$_[0]";
52     return $path if -r $path;
53 root 1.2 }
54    
55 root 1.4 die "FATAL: can't find required file $_[0]\n";
56     }
57    
58 root 1.9 sub require_image($) {
59 root 1.4 new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
60 root 1.2 }
61    
62 root 1.20 sub 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 root 1.22 'nearest', 255, 16, 0xffc0c0c0, 0xff606060,
68 root 1.20 )
69     }
70    
71     # TODO: make preferences
72     sub dealpha($) {
73     &dealpha_compose
74     }
75    
76 root 1.1 1;
77