ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/CV/lib/Gtk2/CV.pm
Revision: 1.44
Committed: Wed Jul 19 01:43:11 2017 UTC (9 years, 2 months ago) by root
Branch: MAIN
Changes since 1.43: +3 -1 lines
Log Message:
*** empty log message ***

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.44 our $VERSION = '1.61';
13 root 1.13
14 root 1.20 XSLoader::load "Gtk2::CV", $VERSION;
15     }
16 root 1.14
17 root 1.44 our $MPLAYER = $ENV{CV_MPLAYER} || "mpv";
18    
19 root 1.43 our $FAST_TMP = -w "/run/shm" ? "/run/shm"
20     : -w "/dev/shm" ? "/dev/shm"
21     : "/tmp";
22    
23 root 1.17 my $aio_source;
24    
25 root 1.30 IO::AIO::min_parallel 32;
26 root 1.35 IO::AIO::max_poll_reqs 2;
27 root 1.30
28 root 1.28 # we use a low priority watcher to give GUI interactions as high a priority
29 root 1.19 # as possible.
30 root 1.17 sub enable_aio {
31     $aio_source ||=
32     add_watch Glib::IO IO::AIO::poll_fileno,
33 root 1.28 in => sub {
34 root 1.42 IO::AIO::poll_cb;
35 root 1.28 1
36     },
37     undef,
38     &Glib::G_PRIORITY_LOW;
39 root 1.17 }
40    
41     sub disable_aio {
42 root 1.18 remove Glib::Source $aio_source if $aio_source;
43 root 1.17 undef $aio_source;
44     }
45    
46 root 1.32 sub flush_aio {
47     enable_aio;
48     IO::AIO::flush;
49     }
50    
51 root 1.17 enable_aio;
52 root 1.2
53 root 1.9 sub find_rcfile($) {
54 root 1.2 my $path;
55    
56     for (@INC) {
57 root 1.4 $path = "$_/Gtk2/CV/$_[0]";
58     return $path if -r $path;
59 root 1.2 }
60    
61 root 1.4 die "FATAL: can't find required file $_[0]\n";
62     }
63    
64 root 1.9 sub require_image($) {
65 root 1.4 new_from_file Gtk2::Gdk::Pixbuf find_rcfile "images/$_[0]";
66 root 1.2 }
67    
68 root 1.20 sub dealpha_compose($) {
69     return $_[0] unless $_[0]->get_has_alpha;
70    
71     Gtk2::CV::dealpha_expose $_[0]->composite_color_simple (
72     $_[0]->get_width, $_[0]->get_height,
73 root 1.22 'nearest', 255, 16, 0xffc0c0c0, 0xff606060,
74 root 1.20 )
75     }
76    
77     # TODO: make preferences
78     sub dealpha($) {
79     &dealpha_compose
80     }
81    
82 root 1.1 1;
83