gio/auto/
debug_controller_dbus.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, Cancellable, DBusConnection, DBusMethodInvocation, DebugController, Initable};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GDebugControllerDBus")]
16    pub struct DebugControllerDBus(Object<ffi::GDebugControllerDBus, ffi::GDebugControllerDBusClass>) @implements DebugController, Initable;
17
18    match fn {
19        type_ => || ffi::g_debug_controller_dbus_get_type(),
20    }
21}
22
23impl DebugControllerDBus {
24    pub const NONE: Option<&'static DebugControllerDBus> = None;
25
26    #[doc(alias = "g_debug_controller_dbus_new")]
27    pub fn new(
28        connection: &DBusConnection,
29        cancellable: Option<&impl IsA<Cancellable>>,
30    ) -> Result<Option<DebugControllerDBus>, glib::Error> {
31        unsafe {
32            let mut error = std::ptr::null_mut();
33            let ret = ffi::g_debug_controller_dbus_new(
34                connection.to_glib_none().0,
35                cancellable.map(|p| p.as_ref()).to_glib_none().0,
36                &mut error,
37            );
38            if error.is_null() {
39                Ok(from_glib_full(ret))
40            } else {
41                Err(from_glib_full(error))
42            }
43        }
44    }
45}
46
47pub trait DebugControllerDBusExt: IsA<DebugControllerDBus> + 'static {
48    #[doc(alias = "g_debug_controller_dbus_stop")]
49    fn stop(&self) {
50        unsafe {
51            ffi::g_debug_controller_dbus_stop(self.as_ref().to_glib_none().0);
52        }
53    }
54
55    #[cfg(feature = "v2_72")]
56    #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
57    #[doc(alias = "authorize")]
58    fn connect_authorize<F: Fn(&Self, &DBusMethodInvocation) -> bool + 'static>(
59        &self,
60        f: F,
61    ) -> SignalHandlerId {
62        unsafe extern "C" fn authorize_trampoline<
63            P: IsA<DebugControllerDBus>,
64            F: Fn(&P, &DBusMethodInvocation) -> bool + 'static,
65        >(
66            this: *mut ffi::GDebugControllerDBus,
67            invocation: *mut ffi::GDBusMethodInvocation,
68            f: glib::ffi::gpointer,
69        ) -> glib::ffi::gboolean {
70            let f: &F = &*(f as *const F);
71            f(
72                DebugControllerDBus::from_glib_borrow(this).unsafe_cast_ref(),
73                &from_glib_borrow(invocation),
74            )
75            .into_glib()
76        }
77        unsafe {
78            let f: Box_<F> = Box_::new(f);
79            connect_raw(
80                self.as_ptr() as *mut _,
81                c"authorize".as_ptr() as *const _,
82                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
83                    authorize_trampoline::<Self, F> as *const (),
84                )),
85                Box_::into_raw(f),
86            )
87        }
88    }
89}
90
91impl<O: IsA<DebugControllerDBus>> DebugControllerDBusExt for O {}