// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
#![allow(deprecated)]

#[cfg(feature = "v4_6")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
use crate::SymbolicPaintable;
use crate::ffi;
use glib::{
    prelude::*,
    signal::{SignalHandlerId, connect_raw},
    translate::*,
};
use std::boxed::Box as Box_;

#[cfg(feature = "v4_6")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
glib::wrapper! {
    #[doc(alias = "GtkIconPaintable")]
    pub struct IconPaintable(Object<ffi::GtkIconPaintable, ffi::GtkIconPaintableClass>) @implements gdk::Paintable, SymbolicPaintable;

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

#[cfg(not(any(feature = "v4_6")))]
glib::wrapper! {
    #[doc(alias = "GtkIconPaintable")]
    pub struct IconPaintable(Object<ffi::GtkIconPaintable, ffi::GtkIconPaintableClass>) @implements gdk::Paintable;

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

impl IconPaintable {
    #[doc(alias = "gtk_icon_paintable_new_for_file")]
    #[doc(alias = "new_for_file")]
    pub fn for_file(file: &impl IsA<gio::File>, size: i32, scale: i32) -> IconPaintable {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gtk_icon_paintable_new_for_file(
                file.as_ref().to_glib_none().0,
                size,
                scale,
            ))
        }
    }

    #[doc(alias = "gtk_icon_paintable_get_file")]
    #[doc(alias = "get_file")]
    pub fn file(&self) -> Option<gio::File> {
        unsafe { from_glib_full(ffi::gtk_icon_paintable_get_file(self.to_glib_none().0)) }
    }

    #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_icon_paintable_get_icon_name")]
    #[doc(alias = "get_icon_name")]
    #[doc(alias = "icon-name")]
    pub fn icon_name(&self) -> Option<std::path::PathBuf> {
        unsafe { from_glib_none(ffi::gtk_icon_paintable_get_icon_name(self.to_glib_none().0)) }
    }

    #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_icon_paintable_is_symbolic")]
    #[doc(alias = "is-symbolic")]
    pub fn is_symbolic(&self) -> bool {
        unsafe { from_glib(ffi::gtk_icon_paintable_is_symbolic(self.to_glib_none().0)) }
    }

    #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
    #[doc(alias = "is-symbolic")]
    pub fn set_is_symbolic(&self, is_symbolic: bool) {
        ObjectExt::set_property(self, "is-symbolic", is_symbolic)
    }

    pub fn scale(&self) -> i32 {
        ObjectExt::property(self, "scale")
    }

    pub fn set_scale(&self, scale: i32) {
        ObjectExt::set_property(self, "scale", scale)
    }

    pub fn size(&self) -> i32 {
        ObjectExt::property(self, "size")
    }

    pub fn set_size(&self, size: i32) {
        ObjectExt::set_property(self, "size", size)
    }

    #[cfg_attr(feature = "v4_20", deprecated = "Since 4.20")]
    #[doc(alias = "is-symbolic")]
    pub fn connect_is_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_is_symbolic_trampoline<F: Fn(&IconPaintable) + 'static>(
            this: *mut ffi::GtkIconPaintable,
            _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::is-symbolic".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_is_symbolic_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

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

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