1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
// This file was generated by gir (https://github.com/gtk-rs/gir)
// DO NOT EDIT
use crate::{Properties};
use glib::{translate::*};
glib::wrapper! {
#[doc(alias = "WpState")]
pub struct State(Object<ffi::WpState, ffi::WpStateClass>);
match fn {
type_ => || ffi::wp_state_get_type(),
}
}
impl State {
#[doc(alias = "wp_state_new")]
pub fn new(name: &str) -> State {
unsafe {
from_glib_full(ffi::wp_state_new(name.to_glib_none().0))
}
}
#[doc(alias = "wp_state_clear")]
pub fn clear(&self) {
unsafe {
ffi::wp_state_clear(self.to_glib_none().0);
}
}
#[doc(alias = "wp_state_get_location")]
#[doc(alias = "get_location")]
pub fn location(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::wp_state_get_location(self.to_glib_none().0))
}
}
#[doc(alias = "wp_state_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::wp_state_get_name(self.to_glib_none().0))
}
}
#[doc(alias = "wp_state_load")]
pub fn load(&self) -> Option<Properties> {
unsafe {
from_glib_full(ffi::wp_state_load(self.to_glib_none().0))
}
}
#[doc(alias = "wp_state_save")]
pub fn save(&self, props: &Properties) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::wp_state_save(self.to_glib_none().0, props.to_glib_none().0, &mut error);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
}