use crate::{ffi, RGBColor};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "HeDesktop")]
pub struct Desktop(Object<ffi::HeDesktop, ffi::HeDesktopClass>);
match fn {
type_ => || ffi::he_desktop_get_type(),
}
}
impl Desktop {
pub const NONE: Option<&'static Desktop> = None;
#[doc(alias = "he_desktop_new")]
pub fn new() -> Desktop {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::he_desktop_new()) }
}
pub fn builder() -> DesktopBuilder {
DesktopBuilder::new()
}
}
impl Default for Desktop {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct DesktopBuilder {
builder: glib::object::ObjectBuilder<'static, Desktop>,
}
impl DesktopBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
pub fn accent_color(self, accent_color: &RGBColor) -> Self {
Self {
builder: self.builder.property("accent-color", accent_color),
}
}
pub fn font_weight(self, font_weight: f64) -> Self {
Self {
builder: self.builder.property("font-weight", font_weight),
}
}
pub fn roundness(self, roundness: f64) -> Self {
Self {
builder: self.builder.property("roundness", roundness),
}
}
pub fn contrast(self, contrast: f64) -> Self {
Self {
builder: self.builder.property("contrast", contrast),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> Desktop {
self.builder.build()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Desktop>> Sealed for T {}
}
pub trait DesktopExt: IsA<Desktop> + sealed::Sealed + 'static {
#[doc(alias = "he_desktop_get_accent_color")]
#[doc(alias = "get_accent_color")]
fn accent_color(&self) -> Option<RGBColor> {
unsafe {
from_glib_none(ffi::he_desktop_get_accent_color(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "he_desktop_get_font_weight")]
#[doc(alias = "get_font_weight")]
fn font_weight(&self) -> f64 {
unsafe { ffi::he_desktop_get_font_weight(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "he_desktop_set_font_weight")]
fn set_font_weight(&self, value: f64) {
unsafe {
ffi::he_desktop_set_font_weight(self.as_ref().to_glib_none().0, value);
}
}
#[doc(alias = "he_desktop_get_roundness")]
#[doc(alias = "get_roundness")]
fn roundness(&self) -> f64 {
unsafe { ffi::he_desktop_get_roundness(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "he_desktop_set_roundness")]
fn set_roundness(&self, value: f64) {
unsafe {
ffi::he_desktop_set_roundness(self.as_ref().to_glib_none().0, value);
}
}
#[doc(alias = "he_desktop_get_contrast")]
#[doc(alias = "get_contrast")]
fn contrast(&self) -> f64 {
unsafe { ffi::he_desktop_get_contrast(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "he_desktop_set_contrast")]
fn set_contrast(&self, value: f64) {
unsafe {
ffi::he_desktop_set_contrast(self.as_ref().to_glib_none().0, value);
}
}
#[doc(alias = "accent-color")]
fn set_accent_color(&self, accent_color: Option<&RGBColor>) {
ObjectExt::set_property(self.as_ref(), "accent-color", accent_color)
}
#[doc(alias = "prefers-color-scheme")]
fn connect_prefers_color_scheme_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_prefers_color_scheme_trampoline<
P: IsA<Desktop>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeDesktop,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Desktop::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::prefers-color-scheme\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_prefers_color_scheme_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "ensor-scheme")]
fn connect_ensor_scheme_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_ensor_scheme_trampoline<
P: IsA<Desktop>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeDesktop,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Desktop::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::ensor-scheme\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_ensor_scheme_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "accent-color")]
fn connect_accent_color_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_accent_color_trampoline<
P: IsA<Desktop>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeDesktop,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Desktop::from_glib_borrow(this).unsafe_cast_ref())
}
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::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "font-weight")]
fn connect_font_weight_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_font_weight_trampoline<P: IsA<Desktop>, F: Fn(&P) + 'static>(
this: *mut ffi::HeDesktop,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Desktop::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::font-weight\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_font_weight_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "roundness")]
fn connect_roundness_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_roundness_trampoline<P: IsA<Desktop>, F: Fn(&P) + 'static>(
this: *mut ffi::HeDesktop,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Desktop::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::roundness\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_roundness_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "contrast")]
fn connect_contrast_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_contrast_trampoline<P: IsA<Desktop>, F: Fn(&P) + 'static>(
this: *mut ffi::HeDesktop,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Desktop::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::contrast\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_contrast_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Desktop>> DesktopExt for O {}