gio/auto/
debug_controller.rs1use crate::{Initable, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GDebugController")]
29 pub struct DebugController(Interface<ffi::GDebugController, ffi::GDebugControllerInterface>) @requires Initable;
30
31 match fn {
32 type_ => || ffi::g_debug_controller_get_type(),
33 }
34}
35
36impl DebugController {
37 pub const NONE: Option<&'static DebugController> = None;
38}
39
40pub trait DebugControllerExt: IsA<DebugController> + 'static {
46 #[doc(alias = "g_debug_controller_get_debug_enabled")]
52 #[doc(alias = "get_debug_enabled")]
53 #[doc(alias = "debug-enabled")]
54 fn is_debug_enabled(&self) -> bool {
55 unsafe {
56 from_glib(ffi::g_debug_controller_get_debug_enabled(
57 self.as_ref().to_glib_none().0,
58 ))
59 }
60 }
61
62 #[doc(alias = "g_debug_controller_set_debug_enabled")]
66 #[doc(alias = "debug-enabled")]
67 fn set_debug_enabled(&self, debug_enabled: bool) {
68 unsafe {
69 ffi::g_debug_controller_set_debug_enabled(
70 self.as_ref().to_glib_none().0,
71 debug_enabled.into_glib(),
72 );
73 }
74 }
75
76 #[cfg(feature = "v2_72")]
77 #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
78 #[doc(alias = "debug-enabled")]
79 fn connect_debug_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
80 unsafe extern "C" fn notify_debug_enabled_trampoline<
81 P: IsA<DebugController>,
82 F: Fn(&P) + 'static,
83 >(
84 this: *mut ffi::GDebugController,
85 _param_spec: glib::ffi::gpointer,
86 f: glib::ffi::gpointer,
87 ) {
88 unsafe {
89 let f: &F = &*(f as *const F);
90 f(DebugController::from_glib_borrow(this).unsafe_cast_ref())
91 }
92 }
93 unsafe {
94 let f: Box_<F> = Box_::new(f);
95 connect_raw(
96 self.as_ptr() as *mut _,
97 c"notify::debug-enabled".as_ptr(),
98 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
99 notify_debug_enabled_trampoline::<Self, F> as *const (),
100 )),
101 Box_::into_raw(f),
102 )
103 }
104 }
105}
106
107impl<O: IsA<DebugController>> DebugControllerExt for O {}