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

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

glib::wrapper! {
    #[doc(alias = "PpsAnnotation")]
    pub struct Annotation(Object<ffi::PpsAnnotation, ffi::PpsAnnotationClass>);

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

impl Annotation {
    pub const NONE: Option<&'static Annotation> = None;
}

pub trait AnnotationExt: IsA<Annotation> + 'static {
    #[doc(alias = "pps_annotation_equal")]
    fn equal(&self, other: &impl IsA<Annotation>) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_equal(
                self.as_ref().to_glib_none().0,
                other.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_annotation_get_annotation_type")]
    #[doc(alias = "get_annotation_type")]
    fn annotation_type(&self) -> AnnotationType {
        unsafe {
            from_glib(ffi::pps_annotation_get_annotation_type(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_annotation_get_area")]
    #[doc(alias = "get_area")]
    fn area(&self) -> Rectangle {
        unsafe {
            let mut area = Rectangle::uninitialized();
            ffi::pps_annotation_get_area(self.as_ref().to_glib_none().0, area.to_glib_none_mut().0);
            area
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_get_border_width")]
    #[doc(alias = "get_border_width")]
    #[doc(alias = "border-width")]
    fn border_width(&self) -> f64 {
        unsafe { ffi::pps_annotation_get_border_width(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "pps_annotation_get_contents")]
    #[doc(alias = "get_contents")]
    fn contents(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::pps_annotation_get_contents(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_get_hidden")]
    #[doc(alias = "get_hidden")]
    #[doc(alias = "hidden")]
    fn is_hidden(&self) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_get_hidden(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_annotation_get_modified")]
    #[doc(alias = "get_modified")]
    fn modified(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::pps_annotation_get_modified(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_annotation_get_name")]
    #[doc(alias = "get_name")]
    fn name(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::pps_annotation_get_name(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "pps_annotation_get_page")]
    #[doc(alias = "get_page")]
    fn page(&self) -> Option<Page> {
        unsafe { from_glib_none(ffi::pps_annotation_get_page(self.as_ref().to_glib_none().0)) }
    }

    #[doc(alias = "pps_annotation_get_page_index")]
    #[doc(alias = "get_page_index")]
    fn page_index(&self) -> u32 {
        unsafe { ffi::pps_annotation_get_page_index(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "pps_annotation_get_rgba")]
    #[doc(alias = "get_rgba")]
    fn rgba(&self) -> gdk::RGBA {
        unsafe {
            let mut rgba = gdk::RGBA::uninitialized();
            ffi::pps_annotation_get_rgba(self.as_ref().to_glib_none().0, rgba.to_glib_none_mut().0);
            rgba
        }
    }

    //#[doc(alias = "pps_annotation_get_value_last_property")]
    //#[doc(alias = "get_value_last_property")]
    //fn value_last_property(&self, value: /*Ignored*/&mut glib::Value) {
    //    unsafe { TODO: call ffi:pps_annotation_get_value_last_property() }
    //}

    #[doc(alias = "pps_annotation_set_area")]
    #[doc(alias = "area")]
    fn set_area(&self, area: &Rectangle) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_set_area(
                self.as_ref().to_glib_none().0,
                area.to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_set_border_width")]
    #[doc(alias = "border-width")]
    fn set_border_width(&self, width: f64) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_set_border_width(
                self.as_ref().to_glib_none().0,
                width,
            ))
        }
    }

    #[doc(alias = "pps_annotation_set_contents")]
    #[doc(alias = "contents")]
    fn set_contents(&self, contents: &str) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_set_contents(
                self.as_ref().to_glib_none().0,
                contents.to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_set_hidden")]
    #[doc(alias = "hidden")]
    fn set_hidden(&self, hidden: bool) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_set_hidden(
                self.as_ref().to_glib_none().0,
                hidden.into_glib(),
            ))
        }
    }

    #[doc(alias = "pps_annotation_set_modified")]
    #[doc(alias = "modified")]
    fn set_modified(&self, modified: &str) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_set_modified(
                self.as_ref().to_glib_none().0,
                modified.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_annotation_set_modified_from_time_t")]
    fn set_modified_from_time_t(&self, utime: libc::time_t) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_set_modified_from_time_t(
                self.as_ref().to_glib_none().0,
                utime,
            ))
        }
    }

    #[doc(alias = "pps_annotation_set_name")]
    #[doc(alias = "name")]
    fn set_name(&self, name: &str) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_set_name(
                self.as_ref().to_glib_none().0,
                name.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_annotation_set_rgba")]
    #[doc(alias = "rgba")]
    fn set_rgba(&self, rgba: &gdk::RGBA) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_set_rgba(
                self.as_ref().to_glib_none().0,
                rgba.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "area")]
    fn connect_area_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_area_trampoline<P: IsA<Annotation>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsAnnotation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Annotation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::area".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_area_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "border-width")]
    fn connect_border_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_border_width_trampoline<
            P: IsA<Annotation>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::PpsAnnotation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Annotation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::border-width".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_border_width_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "contents")]
    fn connect_contents_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_contents_trampoline<P: IsA<Annotation>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsAnnotation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Annotation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::contents".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_contents_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "hidden")]
    fn connect_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_hidden_trampoline<P: IsA<Annotation>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsAnnotation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Annotation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::hidden".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_hidden_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "modified")]
    fn connect_modified_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_modified_trampoline<P: IsA<Annotation>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsAnnotation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Annotation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::modified".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_modified_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "name")]
    fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_name_trampoline<P: IsA<Annotation>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsAnnotation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Annotation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::name".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_name_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "rgba")]
    fn connect_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_rgba_trampoline<P: IsA<Annotation>, F: Fn(&P) + 'static>(
            this: *mut ffi::PpsAnnotation,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(Annotation::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::rgba".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_rgba_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<Annotation>> AnnotationExt for O {}
