gdk4-macos 0.10.3

Rust bindings of the GDK4 macos library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "GdkMacosSurface")]
    pub struct MacosSurface(Object<ffi::GdkMacosSurface, ffi::GdkMacosSurfaceClass>) @extends gdk::Surface;

    match fn {
        type_ => || ffi::gdk_macos_surface_get_type(),
    }
}

impl MacosSurface {
    #[doc(alias = "native")]
    pub fn connect_native_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_native_trampoline<F: Fn(&MacosSurface) + 'static>(
            this: *mut ffi::GdkMacosSurface,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::native".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_native_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}