Skip to main content

gio/auto/
debug_controller.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use 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    /// s needed to dynamically enable or disable debug output.
15    ///
16    /// ## Properties
17    ///
18    ///
19    /// #### `debug-enabled`
20    ///  [`true`] if debug output should be exposed (for example by forwarding it to
21    /// the journal), [`false`] otherwise.
22    ///
23    /// Readable | Writable
24    ///
25    /// # Implements
26    ///
27    /// [`DebugControllerExt`][trait@crate::prelude::DebugControllerExt], [`InitableExt`][trait@crate::prelude::InitableExt]
28    #[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
40/// Trait containing all [`struct@DebugController`] methods.
41///
42/// # Implementors
43///
44/// [`DebugControllerDBus`][struct@crate::DebugControllerDBus], [`DebugController`][struct@crate::DebugController]
45pub trait DebugControllerExt: IsA<DebugController> + 'static {
46    /// Get the value of #GDebugController:debug-enabled.
47    ///
48    /// # Returns
49    ///
50    /// [`true`] if debug output should be exposed, [`false`] otherwise
51    #[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    /// Set the value of #GDebugController:debug-enabled.
63    /// ## `debug_enabled`
64    /// [`true`] if debug output should be exposed, [`false`] otherwise
65    #[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 {}