libhelium 0.12.0

Rust bindings for libhelium
Documentation
// 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

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()) }
    }

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`Desktop`] objects.
    ///
    /// This method returns an instance of [`DesktopBuilder`](crate::builders::DesktopBuilder) which can be used to create [`Desktop`] objects.
    pub fn builder() -> DesktopBuilder {
        DesktopBuilder::new()
    }
}

impl Default for Desktop {
    fn default() -> Self {
        Self::new()
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`Desktop`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[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 prefers_color_scheme(self, prefers_color_scheme: /*Ignored*/DesktopColorScheme) -> Self {
    //    Self { builder: self.builder.property("prefers-color-scheme", prefers_color_scheme), }
    //}

    //pub fn ensor_scheme(self, ensor_scheme: /*Ignored*/DesktopEnsorScheme) -> Self {
    //    Self { builder: self.builder.property("ensor-scheme", ensor_scheme), }
    //}

    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),
        }
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`Desktop`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> Desktop {
        assert_initialized_main_thread!();
        self.builder.build()
    }
}

pub trait DesktopExt: IsA<Desktop> + 'static {
    //#[doc(alias = "he_desktop_get_prefers_color_scheme")]
    //#[doc(alias = "get_prefers_color_scheme")]
    //fn prefers_color_scheme(&self) -> /*Ignored*/DesktopColorScheme {
    //    unsafe { TODO: call ffi:he_desktop_get_prefers_color_scheme() }
    //}

    //#[doc(alias = "he_desktop_set_prefers_color_scheme")]
    //fn set_prefers_color_scheme(&self, value: /*Ignored*/DesktopColorScheme) {
    //    unsafe { TODO: call ffi:he_desktop_set_prefers_color_scheme() }
    //}

    //#[doc(alias = "he_desktop_get_ensor_scheme")]
    //#[doc(alias = "get_ensor_scheme")]
    //fn ensor_scheme(&self) -> /*Ignored*/DesktopEnsorScheme {
    //    unsafe { TODO: call ffi:he_desktop_get_ensor_scheme() }
    //}

    #[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 = "ensor-scheme")]
    //fn set_ensor_scheme(&self, ensor_scheme: /*Ignored*/DesktopEnsorScheme) {
    //    ObjectExt::set_property(self.as_ref(),"ensor-scheme", ensor_scheme)
    //}

    #[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 _,
                c"notify::prefers-color-scheme".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 _,
                c"notify::ensor-scheme".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 _,
                c"notify::accent-color".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 _,
                c"notify::font-weight".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 _,
                c"notify::roundness".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 _,
                c"notify::contrast".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 {}