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

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

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

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

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

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::AnnotationMarkup>> Sealed for T {}
}

pub trait AnnotationMarkupExt: IsA<AnnotationMarkup> + sealed::Sealed + 'static {
    #[doc(alias = "pps_annotation_markup_can_have_popup")]
    #[doc(alias = "can-have-popup")]
    fn can_have_popup(&self) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_markup_can_have_popup(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

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

    #[doc(alias = "pps_annotation_markup_get_opacity")]
    #[doc(alias = "get_opacity")]
    fn opacity(&self) -> f64 {
        unsafe { ffi::pps_annotation_markup_get_opacity(self.as_ref().to_glib_none().0) }
    }

    #[doc(alias = "pps_annotation_markup_get_popup_is_open")]
    #[doc(alias = "get_popup_is_open")]
    #[doc(alias = "popup-is-open")]
    fn is_popup_is_open(&self) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_markup_get_popup_is_open(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "pps_annotation_markup_get_rectangle")]
    #[doc(alias = "get_rectangle")]
    fn rectangle(&self, pps_rect: &mut Rectangle) {
        unsafe {
            ffi::pps_annotation_markup_get_rectangle(
                self.as_ref().to_glib_none().0,
                pps_rect.to_glib_none_mut().0,
            );
        }
    }

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

    #[doc(alias = "pps_annotation_markup_set_has_popup")]
    #[doc(alias = "has-popup")]
    fn set_has_popup(&self, has_popup: bool) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_markup_set_has_popup(
                self.as_ref().to_glib_none().0,
                has_popup.into_glib(),
            ))
        }
    }

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

    #[doc(alias = "pps_annotation_markup_set_opacity")]
    #[doc(alias = "opacity")]
    fn set_opacity(&self, opacity: f64) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_markup_set_opacity(
                self.as_ref().to_glib_none().0,
                opacity,
            ))
        }
    }

    #[doc(alias = "pps_annotation_markup_set_popup_is_open")]
    #[doc(alias = "popup-is-open")]
    fn set_popup_is_open(&self, is_open: bool) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_markup_set_popup_is_open(
                self.as_ref().to_glib_none().0,
                is_open.into_glib(),
            ))
        }
    }

    #[doc(alias = "pps_annotation_markup_set_rectangle")]
    #[doc(alias = "rectangle")]
    fn set_rectangle(&self, pps_rect: &Rectangle) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_markup_set_rectangle(
                self.as_ref().to_glib_none().0,
                pps_rect.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "can-have-popup")]
    fn connect_can_have_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_can_have_popup_trampoline<
            P: IsA<AnnotationMarkup>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::PpsAnnotationMarkup,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AnnotationMarkup::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::can-have-popup\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_can_have_popup_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "has-popup")]
    fn connect_has_popup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_has_popup_trampoline<
            P: IsA<AnnotationMarkup>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::PpsAnnotationMarkup,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AnnotationMarkup::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::has-popup\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_has_popup_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

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

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

    #[doc(alias = "popup-is-open")]
    fn connect_popup_is_open_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_popup_is_open_trampoline<
            P: IsA<AnnotationMarkup>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::PpsAnnotationMarkup,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AnnotationMarkup::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::popup-is-open\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_popup_is_open_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

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

impl<O: IsA<AnnotationMarkup>> AnnotationMarkupExt for O {}
