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
55mod sealed {
56 pub trait Sealed {}
57 impl<T: super::IsA<super::DebugController>> Sealed for T {}
58}
59
60/// Trait containing all [`struct@DebugController`] methods.
61///
62/// # Implementors
63///
64/// [`DebugControllerDBus`][struct@crate::DebugControllerDBus], [`DebugController`][struct@crate::DebugController]
65pub trait DebugControllerExt: IsA<DebugController> + sealed::Sealed + 'static {
66 /// Get the value of #GDebugController:debug-enabled.
67 ///
68 /// # Returns
69 ///
70 /// [`true`] if debug output should be exposed, [`false`] otherwise
71 #[doc(alias = "g_debug_controller_get_debug_enabled")]
72 #[doc(alias = "get_debug_enabled")]
73 #[doc(alias = "debug-enabled")]
74 fn is_debug_enabled(&self) -> bool {
75 unsafe {
76 from_glib(ffi::g_debug_controller_get_debug_enabled(
77 self.as_ref().to_glib_none().0,
78 ))
79 }
80 }
81
82 /// Set the value of #GDebugController:debug-enabled.
83 /// ## `debug_enabled`
84 /// [`true`] if debug output should be exposed, [`false`] otherwise
85 #[doc(alias = "g_debug_controller_set_debug_enabled")]
86 #[doc(alias = "debug-enabled")]
87 fn set_debug_enabled(&self, debug_enabled: bool) {
88 unsafe {
89 ffi::g_debug_controller_set_debug_enabled(
90 self.as_ref().to_glib_none().0,
91 debug_enabled.into_glib(),
92 );
93 }
94 }
95
96 #[cfg(feature = "v2_72")]
97 #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
98 #[doc(alias = "debug-enabled")]
99 fn connect_debug_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
100 unsafe extern "C" fn notify_debug_enabled_trampoline<
101 P: IsA<DebugController>,
102 F: Fn(&P) + 'static,
103 >(
104 this: *mut ffi::GDebugController,
105 _param_spec: glib::ffi::gpointer,
106 f: glib::ffi::gpointer,
107 ) {
108 let f: &F = &*(f as *const F);
109 f(DebugController::from_glib_borrow(this).unsafe_cast_ref())
110 }
111 unsafe {
112 let f: Box_<F> = Box_::new(f);
113 connect_raw(
114 self.as_ptr() as *mut _,
115 b"notify::debug-enabled\0".as_ptr() as *const _,
116 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
117 notify_debug_enabled_trampoline::<Self, F> as *const (),
118 )),
119 Box_::into_raw(f),
120 )
121 }
122 }
123}
124
125impl<O: IsA<DebugController>> DebugControllerExt for O {}