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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
// 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 glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, fmt, mem::transmute};
glib::wrapper! {
///
///
/// ## Properties
///
///
/// #### `state`
/// Readable | Writeable
///
/// # Implements
///
/// [`StateMachineExt`][trait@crate::prelude::StateMachineExt], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::BuildableExt`]
#[doc(alias = "DzlStateMachine")]
pub struct StateMachine(Object<ffi::DzlStateMachine, ffi::DzlStateMachineClass>) @implements gtk::Buildable;
match fn {
type_ => || ffi::dzl_state_machine_get_type(),
}
}
impl StateMachine {
pub const NONE: Option<&'static StateMachine> = None;
#[doc(alias = "dzl_state_machine_new")]
pub fn new() -> StateMachine {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::dzl_state_machine_new()) }
}
//#[doc(alias = "dzl_state_machine_buildable_iface_init")]
//pub fn buildable_iface_init(iface: /*Ignored*/&mut gtk::BuildableIface) {
// unsafe { TODO: call ffi:dzl_state_machine_buildable_iface_init() }
//}
}
impl Default for StateMachine {
fn default() -> Self {
Self::new()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::StateMachine>> Sealed for T {}
}
/// Trait containing all [`struct@StateMachine`] methods.
///
/// # Implementors
///
/// [`StateMachine`][struct@crate::StateMachine]
pub trait StateMachineExt: IsA<StateMachine> + sealed::Sealed + 'static {
//#[doc(alias = "dzl_state_machine_add_binding")]
//fn add_binding(&self, state: &str, source_object: /*Unimplemented*/Option<Basic: Pointer>, source_property: &str, target_object: /*Unimplemented*/Option<Basic: Pointer>, target_property: &str, flags: glib::BindingFlags) {
// unsafe { TODO: call ffi:dzl_state_machine_add_binding() }
//}
//#[doc(alias = "dzl_state_machine_add_property")]
//fn add_property(&self, state: &str, object: /*Unimplemented*/Option<Basic: Pointer>, property: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
// unsafe { TODO: call ffi:dzl_state_machine_add_property() }
//}
//#[doc(alias = "dzl_state_machine_add_property_valist")]
//fn add_property_valist(&self, state: &str, object: /*Unimplemented*/Option<Basic: Pointer>, property: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
// unsafe { TODO: call ffi:dzl_state_machine_add_property_valist() }
//}
//#[doc(alias = "dzl_state_machine_add_propertyv")]
//fn add_propertyv(&self, state: &str, object: /*Unimplemented*/Option<Basic: Pointer>, property: &str, value: &glib::Value) {
// unsafe { TODO: call ffi:dzl_state_machine_add_propertyv() }
//}
#[doc(alias = "dzl_state_machine_add_style")]
fn add_style(&self, state: &str, widget: &impl IsA<gtk::Widget>, style: &str) {
unsafe {
ffi::dzl_state_machine_add_style(
self.as_ref().to_glib_none().0,
state.to_glib_none().0,
widget.as_ref().to_glib_none().0,
style.to_glib_none().0,
);
}
}
//#[doc(alias = "dzl_state_machine_connect_object")]
//fn connect_object<P: Fn() + 'static>(&self, state: &str, source: /*Unimplemented*/Option<Basic: Pointer>, detailed_signal: &str, callback: P, user_data: /*Unimplemented*/Option<Basic: Pointer>, flags: glib::ConnectFlags) {
// unsafe { TODO: call ffi:dzl_state_machine_connect_object() }
//}
/// Creates a new [`gio::Action`][crate::gio::Action] with the name of `name`.
///
/// Setting the state of this action will toggle the state of the state machine.
/// You should use [`glib::Variant::new_string()`][crate::glib::Variant::new_string()] or similar to create the state.
/// ## `name`
/// the name of the action.
///
/// # Returns
///
/// A newly created [`gio::Action`][crate::gio::Action].
#[doc(alias = "dzl_state_machine_create_action")]
fn create_action(&self, name: &str) -> Option<gio::Action> {
unsafe {
from_glib_full(ffi::dzl_state_machine_create_action(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
))
}
}
/// Gets the [`state`][struct@crate::StateMachine#state] property. This is the name of the
/// current state of the machine.
///
/// # Returns
///
/// The current state of the machine.
#[doc(alias = "dzl_state_machine_get_state")]
#[doc(alias = "get_state")]
fn state(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::dzl_state_machine_get_state(
self.as_ref().to_glib_none().0,
))
}
}
/// Checks to see if the current state of the [`StateMachine`][crate::StateMachine] matches `state`.
/// ## `state`
/// the name of the state to check
///
/// # Returns
///
/// [`true`] if `self` is currently set to `state`.
#[cfg(feature = "v3_28")]
#[cfg_attr(docsrs, doc(cfg(feature = "v3_28")))]
#[doc(alias = "dzl_state_machine_is_state")]
fn is_state(&self, state: Option<&str>) -> bool {
unsafe {
from_glib(ffi::dzl_state_machine_is_state(
self.as_ref().to_glib_none().0,
state.to_glib_none().0,
))
}
}
/// Sets the [`state`][struct@crate::StateMachine#state] property.
///
/// Registered state transformations will be applied during the state
/// transformation.
///
/// If the transition results in a cyclic operation, the state will stop at
/// the last state before the cycle was detected.
#[doc(alias = "dzl_state_machine_set_state")]
fn set_state(&self, state: &str) {
unsafe {
ffi::dzl_state_machine_set_state(
self.as_ref().to_glib_none().0,
state.to_glib_none().0,
);
}
}
#[doc(alias = "state")]
fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_state_trampoline<P: IsA<StateMachine>, F: Fn(&P) + 'static>(
this: *mut ffi::DzlStateMachine,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(StateMachine::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::state\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_state_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<StateMachine>> StateMachineExt for O {}
impl fmt::Display for StateMachine {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("StateMachine")
}
}