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

use std::boxed::Box as Box_;

use glib::prelude::*;
use glib::signal::{connect_raw, SignalHandlerId};
use glib::translate::*;

use crate::ffi;

glib::wrapper! {
    #[doc(alias = "GlyEncodedImage")]
    pub struct EncodedImage(Object<ffi::GlyEncodedImage, ffi::GlyEncodedImageClass>);

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

impl EncodedImage {
    #[doc(alias = "gly_encoded_image_get_data")]
    #[doc(alias = "get_data")]
    pub fn data(&self) -> glib::Bytes {
        unsafe { from_glib_full(ffi::gly_encoded_image_get_data(self.to_glib_none().0)) }
    }

    #[doc(alias = "data")]
    pub fn connect_data_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_data_trampoline<F: Fn(&EncodedImage) + 'static>(
            this: *mut ffi::GlyEncodedImage,
            _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::data".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_data_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}
