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

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

glib::wrapper! {
    #[doc(alias = "AdwStyleManager")]
    pub struct StyleManager(Object<ffi::AdwStyleManager, ffi::AdwStyleManagerClass>);

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

impl StyleManager {
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "adw_style_manager_get_accent_color")]
    #[doc(alias = "get_accent_color")]
    #[doc(alias = "accent-color")]
    pub fn accent_color(&self) -> AccentColor {
        unsafe {
            from_glib(ffi::adw_style_manager_get_accent_color(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "adw_style_manager_get_accent_color_rgba")]
    #[doc(alias = "get_accent_color_rgba")]
    #[doc(alias = "accent-color-rgba")]
    pub fn accent_color_rgba(&self) -> gdk::RGBA {
        unsafe {
            from_glib_full(ffi::adw_style_manager_get_accent_color_rgba(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "adw_style_manager_get_color_scheme")]
    #[doc(alias = "get_color_scheme")]
    #[doc(alias = "color-scheme")]
    pub fn color_scheme(&self) -> ColorScheme {
        unsafe {
            from_glib(ffi::adw_style_manager_get_color_scheme(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "adw_style_manager_get_dark")]
    #[doc(alias = "get_dark")]
    #[doc(alias = "dark")]
    pub fn is_dark(&self) -> bool {
        unsafe { from_glib(ffi::adw_style_manager_get_dark(self.to_glib_none().0)) }
    }

    #[doc(alias = "adw_style_manager_get_display")]
    #[doc(alias = "get_display")]
    pub fn display(&self) -> Option<gdk::Display> {
        unsafe { from_glib_none(ffi::adw_style_manager_get_display(self.to_glib_none().0)) }
    }

    #[doc(alias = "adw_style_manager_get_high_contrast")]
    #[doc(alias = "get_high_contrast")]
    #[doc(alias = "high-contrast")]
    pub fn is_high_contrast(&self) -> bool {
        unsafe {
            from_glib(ffi::adw_style_manager_get_high_contrast(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "adw_style_manager_get_system_supports_accent_colors")]
    #[doc(alias = "get_system_supports_accent_colors")]
    #[doc(alias = "system-supports-accent-colors")]
    pub fn is_system_supports_accent_colors(&self) -> bool {
        unsafe {
            from_glib(ffi::adw_style_manager_get_system_supports_accent_colors(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "adw_style_manager_get_system_supports_color_schemes")]
    #[doc(alias = "get_system_supports_color_schemes")]
    #[doc(alias = "system-supports-color-schemes")]
    pub fn system_supports_color_schemes(&self) -> bool {
        unsafe {
            from_glib(ffi::adw_style_manager_get_system_supports_color_schemes(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "adw_style_manager_set_color_scheme")]
    #[doc(alias = "color-scheme")]
    pub fn set_color_scheme(&self, color_scheme: ColorScheme) {
        unsafe {
            ffi::adw_style_manager_set_color_scheme(
                self.to_glib_none().0,
                color_scheme.into_glib(),
            );
        }
    }

    #[doc(alias = "adw_style_manager_get_default")]
    #[doc(alias = "get_default")]
    #[allow(clippy::should_implement_trait)]
    pub fn default() -> StyleManager {
        assert_initialized_main_thread!();
        unsafe { from_glib_none(ffi::adw_style_manager_get_default()) }
    }

    #[doc(alias = "adw_style_manager_get_for_display")]
    #[doc(alias = "get_for_display")]
    pub fn for_display(display: &gdk::Display) -> StyleManager {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_none(ffi::adw_style_manager_get_for_display(
                display.to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "accent-color")]
    pub fn connect_accent_color_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_accent_color_trampoline<F: Fn(&StyleManager) + 'static>(
            this: *mut ffi::AdwStyleManager,
            _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 _,
                b"notify::accent-color\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_accent_color_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "accent-color-rgba")]
    pub fn connect_accent_color_rgba_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_accent_color_rgba_trampoline<F: Fn(&StyleManager) + 'static>(
            this: *mut ffi::AdwStyleManager,
            _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 _,
                b"notify::accent-color-rgba\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_accent_color_rgba_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "color-scheme")]
    pub fn connect_color_scheme_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_color_scheme_trampoline<F: Fn(&StyleManager) + 'static>(
            this: *mut ffi::AdwStyleManager,
            _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 _,
                b"notify::color-scheme\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_color_scheme_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "dark")]
    pub fn connect_dark_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_dark_trampoline<F: Fn(&StyleManager) + 'static>(
            this: *mut ffi::AdwStyleManager,
            _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 _,
                b"notify::dark\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_dark_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "high-contrast")]
    pub fn connect_high_contrast_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_high_contrast_trampoline<F: Fn(&StyleManager) + 'static>(
            this: *mut ffi::AdwStyleManager,
            _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 _,
                b"notify::high-contrast\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_high_contrast_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "system-supports-accent-colors")]
    pub fn connect_system_supports_accent_colors_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_system_supports_accent_colors_trampoline<
            F: Fn(&StyleManager) + 'static,
        >(
            this: *mut ffi::AdwStyleManager,
            _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 _,
                b"notify::system-supports-accent-colors\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_system_supports_accent_colors_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "system-supports-color-schemes")]
    pub fn connect_system_supports_color_schemes_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_system_supports_color_schemes_trampoline<
            F: Fn(&StyleManager) + 'static,
        >(
            this: *mut ffi::AdwStyleManager,
            _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 _,
                b"notify::system-supports-color-schemes\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_system_supports_color_schemes_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}
