use crate::{ffi, GcDisplayNotation, GcRepresentation};
use glib::{prelude::*, translate::*};
glib::wrapper! {
#[doc(alias = "ArvGcFloat")]
pub struct GcFloat(Interface<ffi::ArvGcFloat, ffi::ArvGcFloatInterface>);
match fn {
type_ => || ffi::arv_gc_float_get_type(),
}
}
impl GcFloat {
pub const NONE: Option<&'static GcFloat> = None;
}
unsafe impl Send for GcFloat {}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::GcFloat>> Sealed for T {}
}
pub trait GcFloatExt: IsA<GcFloat> + sealed::Sealed + 'static {
#[doc(alias = "arv_gc_float_get_display_notation")]
#[doc(alias = "get_display_notation")]
fn display_notation(&self) -> GcDisplayNotation {
unsafe {
from_glib(ffi::arv_gc_float_get_display_notation(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_gc_float_get_display_precision")]
#[doc(alias = "get_display_precision")]
fn display_precision(&self) -> i64 {
unsafe { ffi::arv_gc_float_get_display_precision(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "arv_gc_float_get_inc")]
#[doc(alias = "get_inc")]
fn inc(&self) -> Result<f64, glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::arv_gc_float_get_inc(self.as_ref().to_glib_none().0, &mut error);
if error.is_null() {
Ok(ret)
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "arv_gc_float_get_max")]
#[doc(alias = "get_max")]
fn max(&self) -> Result<f64, glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::arv_gc_float_get_max(self.as_ref().to_glib_none().0, &mut error);
if error.is_null() {
Ok(ret)
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "arv_gc_float_get_min")]
#[doc(alias = "get_min")]
fn min(&self) -> Result<f64, glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::arv_gc_float_get_min(self.as_ref().to_glib_none().0, &mut error);
if error.is_null() {
Ok(ret)
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "arv_gc_float_get_representation")]
#[doc(alias = "get_representation")]
fn representation(&self) -> GcRepresentation {
unsafe {
from_glib(ffi::arv_gc_float_get_representation(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "arv_gc_float_get_unit")]
#[doc(alias = "get_unit")]
fn unit(&self) -> Option<glib::GString> {
unsafe { from_glib_none(ffi::arv_gc_float_get_unit(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "arv_gc_float_get_value")]
#[doc(alias = "get_value")]
fn value(&self) -> Result<f64, glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::arv_gc_float_get_value(self.as_ref().to_glib_none().0, &mut error);
if error.is_null() {
Ok(ret)
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "arv_gc_float_impose_max")]
fn impose_max(&self, maximum: f64) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let _ =
ffi::arv_gc_float_impose_max(self.as_ref().to_glib_none().0, maximum, &mut error);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "arv_gc_float_impose_min")]
fn impose_min(&self, minimum: f64) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let _ =
ffi::arv_gc_float_impose_min(self.as_ref().to_glib_none().0, minimum, &mut error);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "arv_gc_float_set_value")]
fn set_value(&self, value: f64) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let _ = ffi::arv_gc_float_set_value(self.as_ref().to_glib_none().0, value, &mut error);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
}
impl<O: IsA<GcFloat>> GcFloatExt for O {}