// This file was generated by gir (https://github.com/gtk-rs/gir)
// from ../gir-files
// from ../pps-girs
// DO NOT EDIT

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

glib::wrapper! {
    #[doc(alias = "PpsAnnotationInk")]
    pub struct AnnotationInk(Object<ffi::PpsAnnotationInk, ffi::PpsAnnotationInkClass>) @extends Annotation;

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

impl AnnotationInk {
    #[doc(alias = "pps_annotation_ink_new")]
    pub fn new(page: &impl IsA<Page>) -> AnnotationInk {
        skip_assert_initialized!();
        unsafe {
            Annotation::from_glib_full(ffi::pps_annotation_ink_new(page.as_ref().to_glib_none().0))
                .unsafe_cast()
        }
    }

    #[doc(alias = "pps_annotation_ink_new_highlight")]
    pub fn new_highlight(page: &impl IsA<Page>) -> AnnotationInk {
        skip_assert_initialized!();
        unsafe {
            Annotation::from_glib_full(ffi::pps_annotation_ink_new_highlight(
                page.as_ref().to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }

    #[doc(alias = "pps_annotation_ink_get_highlight")]
    #[doc(alias = "get_highlight")]
    pub fn is_highlight(&self) -> bool {
        unsafe { from_glib(ffi::pps_annotation_ink_get_highlight(self.to_glib_none().0)) }
    }

    #[doc(alias = "pps_annotation_ink_get_ink_list")]
    #[doc(alias = "get_ink_list")]
    #[doc(alias = "ink-list")]
    pub fn ink_list(&self) -> Option<InkList> {
        unsafe { from_glib_none(ffi::pps_annotation_ink_get_ink_list(self.to_glib_none().0)) }
    }

    #[doc(alias = "pps_annotation_ink_get_time_list")]
    #[doc(alias = "get_time_list")]
    pub fn time_list(&self) -> Vec<InkTime> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::pps_annotation_ink_get_time_list(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_annotation_ink_set_ink_list")]
    #[doc(alias = "ink-list")]
    pub fn set_ink_list(&self, ink_list: InkList) {
        unsafe {
            ffi::pps_annotation_ink_set_ink_list(self.to_glib_none().0, ink_list.into_glib_ptr());
        }
    }

    #[doc(alias = "ink-list")]
    pub fn connect_ink_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_ink_list_trampoline<F: Fn(&AnnotationInk) + 'static>(
            this: *mut ffi::PpsAnnotationInk,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                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::ink-list".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_ink_list_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}
