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

use crate::{ffi, Rectangle};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct Mapping(Boxed<ffi::PpsMapping>);

    match fn {
        copy => |ptr| ffi::pps_mapping_copy(ptr),
        free => |ptr| ffi::pps_mapping_free(ptr),
        type_ => || ffi::pps_mapping_get_type(),
    }
}

impl Mapping {
    #[doc(alias = "pps_mapping_new")]
    pub fn new() -> Mapping {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::pps_mapping_new()) }
    }

    #[doc(alias = "pps_mapping_get_area")]
    #[doc(alias = "get_area")]
    pub fn area(&mut self) -> Option<Rectangle> {
        unsafe { from_glib_none(ffi::pps_mapping_get_area(self.to_glib_none_mut().0)) }
    }

    #[doc(alias = "pps_mapping_get_data")]
    #[doc(alias = "get_data")]
    pub fn data(&self) -> Option<glib::Object> {
        unsafe { from_glib_none(ffi::pps_mapping_get_data(self.to_glib_none().0)) }
    }

    #[doc(alias = "pps_mapping_set_area")]
    pub fn set_area(&mut self, area: Rectangle) {
        unsafe {
            ffi::pps_mapping_set_area(self.to_glib_none_mut().0, area.into_glib_ptr());
        }
    }

    #[doc(alias = "pps_mapping_set_data")]
    pub fn set_data(&mut self, data: impl IsA<glib::Object>) {
        unsafe {
            ffi::pps_mapping_set_data(self.to_glib_none_mut().0, data.upcast().into_glib_ptr());
        }
    }
}

impl Default for Mapping {
    fn default() -> Self {
        Self::new()
    }
}
