gio/auto/
debug_controller.rs1use crate::{ffi, Initable};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GDebugController")]
15 pub struct DebugController(Interface<ffi::GDebugController, ffi::GDebugControllerInterface>) @requires Initable;
16
17 match fn {
18 type_ => || ffi::g_debug_controller_get_type(),
19 }
20}
21
22impl DebugController {
23 pub const NONE: Option<&'static DebugController> = None;
24}
25
26pub trait DebugControllerExt: IsA<DebugController> + 'static {
27 #[doc(alias = "g_debug_controller_get_debug_enabled")]
28 #[doc(alias = "get_debug_enabled")]
29 #[doc(alias = "debug-enabled")]
30 fn is_debug_enabled(&self) -> bool {
31 unsafe {
32 from_glib(ffi::g_debug_controller_get_debug_enabled(
33 self.as_ref().to_glib_none().0,
34 ))
35 }
36 }
37
38 #[doc(alias = "g_debug_controller_set_debug_enabled")]
39 #[doc(alias = "debug-enabled")]
40 fn set_debug_enabled(&self, debug_enabled: bool) {
41 unsafe {
42 ffi::g_debug_controller_set_debug_enabled(
43 self.as_ref().to_glib_none().0,
44 debug_enabled.into_glib(),
45 );
46 }
47 }
48
49 #[cfg(feature = "v2_72")]
50 #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
51 #[doc(alias = "debug-enabled")]
52 fn connect_debug_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
53 unsafe extern "C" fn notify_debug_enabled_trampoline<
54 P: IsA<DebugController>,
55 F: Fn(&P) + 'static,
56 >(
57 this: *mut ffi::GDebugController,
58 _param_spec: glib::ffi::gpointer,
59 f: glib::ffi::gpointer,
60 ) {
61 let f: &F = &*(f as *const F);
62 f(DebugController::from_glib_borrow(this).unsafe_cast_ref())
63 }
64 unsafe {
65 let f: Box_<F> = Box_::new(f);
66 connect_raw(
67 self.as_ptr() as *mut _,
68 c"notify::debug-enabled".as_ptr() as *const _,
69 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
70 notify_debug_enabled_trampoline::<Self, F> as *const (),
71 )),
72 Box_::into_raw(f),
73 )
74 }
75 }
76}
77
78impl<O: IsA<DebugController>> DebugControllerExt for O {}