alsactl 0.8.0

API binding for alsactl library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi, ElemInfoCommon, ElemInfoSingleArray};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// An object to express information for integer type of element.
    ///
    /// A `GObject::Object` derived object class for integer type of element.
    ///
    /// The object wraps `struct snd_ctl_elem_info` in UAPI of Linux sound subsystem.
    ///
    /// ## Properties
    ///
    ///
    /// #### `value-max`
    ///  The maximum value of element in value array for the element.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `value-min`
    ///  The minimum value of element in value array for the element.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `value-step`
    ///  The step value of element in value array for the element.
    ///
    /// Readable | Writeable
    /// <details><summary><h4>ElemInfoCommon</h4></summary>
    ///
    ///
    /// #### `access`
    ///  The access permission for the element with [`ElemAccessFlag`][crate::ElemAccessFlag].
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `elem-id`
    ///  The identifier of element.
    ///
    /// Readable
    ///
    ///
    /// #### `elem-type`
    ///  The type of element, one of [`ElemType`][crate::ElemType].
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `owner`
    ///  The value of PID for process to own the element.
    ///
    /// Readable
    /// </details>
    /// <details><summary><h4>ElemInfoSingleArray</h4></summary>
    ///
    ///
    /// #### `value-count`
    ///  The count of elements in value array of the element.
    ///
    /// Readable | Writeable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`ElemInfoIntegerExt`][trait@crate::prelude::ElemInfoIntegerExt], [`ElemInfoCommonExt`][trait@crate::prelude::ElemInfoCommonExt], [`ElemInfoSingleArrayExt`][trait@crate::prelude::ElemInfoSingleArrayExt]
    #[doc(alias = "ALSACtlElemInfoInteger")]
    pub struct ElemInfoInteger(Object<ffi::ALSACtlElemInfoInteger, ffi::ALSACtlElemInfoIntegerClass>) @implements ElemInfoCommon, ElemInfoSingleArray;

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

impl ElemInfoInteger {
    pub const NONE: Option<&'static ElemInfoInteger> = None;

    /// Allocate and return an instance of [`ElemInfoInteger`][crate::ElemInfoInteger].
    ///
    /// # Returns
    ///
    /// An instance of [`ElemInfoInteger`][crate::ElemInfoInteger].
    #[doc(alias = "alsactl_elem_info_integer_new")]
    pub fn new() -> ElemInfoInteger {
        unsafe { from_glib_full(ffi::alsactl_elem_info_integer_new()) }
    }
}

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

/// Trait containing all [`struct@ElemInfoInteger`] methods.
///
/// # Implementors
///
/// [`ElemInfoInteger`][struct@crate::ElemInfoInteger]
pub trait ElemInfoIntegerExt: IsA<ElemInfoInteger> + 'static {
    /// The maximum value of element in value array for the element.
    #[doc(alias = "value-max")]
    fn value_max(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "value-max")
    }

    /// The maximum value of element in value array for the element.
    #[doc(alias = "value-max")]
    fn set_value_max(&self, value_max: i32) {
        ObjectExt::set_property(self.as_ref(), "value-max", value_max)
    }

    /// The minimum value of element in value array for the element.
    #[doc(alias = "value-min")]
    fn value_min(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "value-min")
    }

    /// The minimum value of element in value array for the element.
    #[doc(alias = "value-min")]
    fn set_value_min(&self, value_min: i32) {
        ObjectExt::set_property(self.as_ref(), "value-min", value_min)
    }

    /// The step value of element in value array for the element.
    #[doc(alias = "value-step")]
    fn value_step(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "value-step")
    }

    /// The step value of element in value array for the element.
    #[doc(alias = "value-step")]
    fn set_value_step(&self, value_step: i32) {
        ObjectExt::set_property(self.as_ref(), "value-step", value_step)
    }

    #[doc(alias = "value-max")]
    fn connect_value_max_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_value_max_trampoline<
            P: IsA<ElemInfoInteger>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSACtlElemInfoInteger,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(ElemInfoInteger::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::value-max".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_value_max_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "value-min")]
    fn connect_value_min_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_value_min_trampoline<
            P: IsA<ElemInfoInteger>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSACtlElemInfoInteger,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(ElemInfoInteger::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::value-min".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_value_min_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "value-step")]
    fn connect_value_step_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_value_step_trampoline<
            P: IsA<ElemInfoInteger>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSACtlElemInfoInteger,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(ElemInfoInteger::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::value-step".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_value_step_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<ElemInfoInteger>> ElemInfoIntegerExt for O {}