Gtk3/GdkWin32.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 42 CC 1 SCAR 6.9
CC
1
Cov
0%
import
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use Renard::Incunabula::Common::Setup;
2 package Intertangle::API::Gtk3::GdkWin32;
3 # ABSTRACT: Load the GdkWin32 library
4 $Intertangle::API::Gtk3::GdkWin32::VERSION = '0.005';
5 use Glib::Object::Introspection;
6 use FFI::Platypus;
7 use FFI::CheckLib 0.06;
8  
9 my $_GDKWIN32_BASENAME = 'GdkWin32';
10 my $_GDKWIN32_VERSION = '3.0';
11 my $_GDKWIN32_PACKAGE = __PACKAGE__;
12  
13 my @_FLATTEN_ARRAY_REF_RETURN_FOR = qw/
14 /;
15  
16 sub import {
17 Glib::Object::Introspection->setup(
18 basename => $_GDKWIN32_BASENAME,
19 version => $_GDKWIN32_VERSION,
20 package => $_GDKWIN32_PACKAGE,
21 flatten_array_ref_return_for => \@_FLATTEN_ARRAY_REF_RETURN_FOR,
22 );
23  
24 # Need to attach the `gdk_win32_window_get_handle` function.
25 # See bug: The gdk_win32_window_get_handle of GdkWin32Window is not exposed to
26 # introspection <https://gitlab.gnome.org/GNOME/gtk/issues/510>.
27 my $ffi = FFI::Platypus->new;
28 $ffi->lib(find_lib_or_die lib => 'gdk');
29 # HGDIOBJ gdk_win32_window_get_handle (GdkWindow *window);
30 $ffi->attach( gdk_win32_window_get_handle => [ 'opaque' ], 'opaque', sub {
31 my ($xs, $gdk_window) = @_;
32 Gtk3::Gdk::threads_enter();
33 my $hwnd = $xs->( Glib::Object::get_pointer($gdk_window) );
34 Gtk3::Gdk::threads_leave();
35 return $hwnd;
36 });
37 # GdkWindow * gdk_win32_window_foreign_new_for_display (GdkDisplay *display, HWND anid)
38 $ffi->attach(
39 [ gdk_win32_window_foreign_new_for_display => __PACKAGE__ . '::Win32Window::foreign_new_for_display' ]
40 => [ 'opaque', 'opaque' ], 'opaque', sub {
41 my ($xs, $package, $gdk_display, $hwnd) = @_;
42 Gtk3::Gdk::threads_enter();
43 my $gdk_window = $xs->( Glib::Object::get_pointer($gdk_display), $hwnd );
44 Gtk3::Gdk::threads_leave();
45 return Gtk3::Gdk::Window->new_from_pointer($gdk_window);
46 });
47 }
48  
49 1;
50  
51 __END__
52  
53 =pod
54  
55 =encoding UTF-8
56  
57 =head1 NAME
58  
59 Intertangle::API::Gtk3::GdkWin32 - Load the GdkWin32 library
60  
61 =head1 VERSION
62  
63 version 0.005
64  
65 =head1 AUTHOR
66  
67 Zakariyya Mughal <zmughal@cpan.org>
68  
69 =head1 COPYRIGHT AND LICENSE
70  
71 This software is copyright (c) 2017 by Zakariyya Mughal.
72  
73 This is free software; you can redistribute it and/or modify it under
74 the same terms as the Perl 5 programming language system itself.
75  
76 =cut