ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/CV/lib/Gtk2/CV.pm
Revision: 1.41
Committed: Thu Oct 28 12:14:23 2010 UTC (15 years, 11 months ago) by root
Branch: MAIN
CVS Tags: rel-1_56
Changes since 1.40: +1 -1 lines
Log Message:
1.56

File Contents

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