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