#[cfg(feature = "v1_6")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
use crate::AccentColor;
use crate::{ColorScheme, ffi};
use glib::{
prelude::*,
signal::{SignalHandlerId, connect_raw},
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)) }
}
#[cfg(feature = "v1_7")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
#[doc(alias = "adw_style_manager_get_document_font_name")]
#[doc(alias = "get_document_font_name")]
#[doc(alias = "document-font-name")]
pub fn document_font_name(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::adw_style_manager_get_document_font_name(
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_7")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
#[doc(alias = "adw_style_manager_get_monospace_font_name")]
#[doc(alias = "get_monospace_font_name")]
#[doc(alias = "monospace-font-name")]
pub fn monospace_font_name(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::adw_style_manager_get_monospace_font_name(
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,
) {
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::accent-color".as_ptr(),
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,
) {
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::accent-color-rgba".as_ptr(),
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,
) {
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::color-scheme".as_ptr(),
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,
) {
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::dark".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_dark_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_7")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
#[doc(alias = "document-font-name")]
pub fn connect_document_font_name_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_document_font_name_trampoline<
F: Fn(&StyleManager) + 'static,
>(
this: *mut ffi::AdwStyleManager,
_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::document-font-name".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_document_font_name_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,
) {
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::high-contrast".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_high_contrast_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg(feature = "v1_7")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
#[doc(alias = "monospace-font-name")]
pub fn connect_monospace_font_name_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_monospace_font_name_trampoline<
F: Fn(&StyleManager) + 'static,
>(
this: *mut ffi::AdwStyleManager,
_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::monospace-font-name".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_monospace_font_name_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,
) {
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::system-supports-accent-colors".as_ptr(),
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,
) {
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::system-supports-color-schemes".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_system_supports_color_schemes_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}