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::{ffi, Initable};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// `GDebugController` is an interface to expose control of debugging features and
15    /// debug output.
16    ///
17    /// It is implemented on Linux using [`DebugControllerDBus`][crate::DebugControllerDBus], which
18    /// exposes a D-Bus interface to allow authenticated peers to control debug
19    /// features in this process.
20    ///
21    /// Whether debug output is enabled is exposed as
22    /// [`debug-enabled`][struct@crate::DebugController#debug-enabled]. This controls
23    /// `log_set_debug_enabled()` by default. Application code may
24    /// connect to the [`notify`][struct@crate::glib::Object#notify] signal for it
25    /// to control other parts of its debug infrastructure as necessary.
26    ///
27    /// If your application or service is using the default GLib log writer function,
28    /// creating one of the built-in implementations of `GDebugController` should be
29    /// all that’s needed to dynamically enable or disable debug output.
30    ///
31    /// ## Properties
32    ///
33    ///
34    /// #### `debug-enabled`
35    ///  [`true`] if debug output should be exposed (for example by forwarding it to
36    /// the journal), [`false`] otherwise.
37    ///
38    /// Readable | Writeable
39    ///
40    /// # Implements
41    ///
42    /// [`DebugControllerExt`][trait@crate::prelude::DebugControllerExt], [`InitableExt`][trait@crate::prelude::InitableExt]
43    #[doc(alias = "GDebugController")]
44    pub struct DebugController(Interface<ffi::GDebugController, ffi::GDebugControllerInterface>) @requires Initable;
45
46    match fn {
47        type_ => || ffi::g_debug_controller_get_type(),
48    }
49}
50
51impl DebugController {
52    pub const NONE: Option<&'static DebugController> = None;
53}
54
55/// Trait containing all [`struct@DebugController`] methods.
56///
57/// # Implementors
58///
59/// [`DebugControllerDBus`][struct@crate::DebugControllerDBus], [`DebugController`][struct@crate::DebugController]
60pub trait DebugControllerExt: IsA<DebugController> + 'static {
61    /// Get the value of #GDebugController:debug-enabled.
62    ///
63    /// # Returns
64    ///
65    /// [`true`] if debug output should be exposed, [`false`] otherwise
66    #[doc(alias = "g_debug_controller_get_debug_enabled")]
67    #[doc(alias = "get_debug_enabled")]
68    #[doc(alias = "debug-enabled")]
69    fn is_debug_enabled(&self) -> bool {
70        unsafe {
71            from_glib(ffi::g_debug_controller_get_debug_enabled(
72                self.as_ref().to_glib_none().0,
73            ))
74        }
75    }
76
77    /// Set the value of #GDebugController:debug-enabled.
78    /// ## `debug_enabled`
79    /// [`true`] if debug output should be exposed, [`false`] otherwise
80    #[doc(alias = "g_debug_controller_set_debug_enabled")]
81    #[doc(alias = "debug-enabled")]
82    fn set_debug_enabled(&self, debug_enabled: bool) {
83        unsafe {
84            ffi::g_debug_controller_set_debug_enabled(
85                self.as_ref().to_glib_none().0,
86                debug_enabled.into_glib(),
87            );
88        }
89    }
90
91    #[cfg(feature = "v2_72")]
92    #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
93    #[doc(alias = "debug-enabled")]
94    fn connect_debug_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
95        unsafe extern "C" fn notify_debug_enabled_trampoline<
96            P: IsA<DebugController>,
97            F: Fn(&P) + 'static,
98        >(
99            this: *mut ffi::GDebugController,
100            _param_spec: glib::ffi::gpointer,
101            f: glib::ffi::gpointer,
102        ) {
103            let f: &F = &*(f as *const F);
104            f(DebugController::from_glib_borrow(this).unsafe_cast_ref())
105        }
106        unsafe {
107            let f: Box_<F> = Box_::new(f);
108            connect_raw(
109                self.as_ptr() as *mut _,
110                c"notify::debug-enabled".as_ptr() as *const _,
111                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
112                    notify_debug_enabled_trampoline::<Self, F> as *const (),
113                )),
114                Box_::into_raw(f),
115            )
116        }
117    }
118}
119
120impl<O: IsA<DebugController>> DebugControllerExt for O {}