| 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 |
|
| 5 |
use crate::{Cancellable, DBusConnection, DBusMethodInvocation, DebugController, Initable, ffi}; |
| 6 |
use glib::{ |
| 7 |
object::ObjectType as _, |
| 8 |
prelude::*, |
| 9 |
signal::{SignalHandlerId, connect_raw}, |
| 10 |
translate::*, |
| 11 |
}; |
| 12 |
use std::boxed::Box as Box_; |
| 13 |
|
| 14 |
glib::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 |
|
| 23 |
impl 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 |
|
| 47 |
pub 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 |
unsafe { |
| 71 |
let f: &F = &*(f as *const F); |
| 72 |
f( |
| 73 |
DebugControllerDBus::from_glib_borrow(this).unsafe_cast_ref(), |
| 74 |
&from_glib_borrow(invocation), |
| 75 |
) |
| 76 |
.into_glib() |
| 77 |
} |
| 78 |
} |
| 79 |
unsafe { |
| 80 |
let f: Box_<F> = Box_::new(f); |
| 81 |
connect_raw( |
| 82 |
self.as_ptr() as *mut _, |
| 83 |
c"authorize".as_ptr(), |
| 84 |
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
| 85 |
authorize_trampoline::<Self, F> as *const (), |
| 86 |
)), |
| 87 |
Box_::into_raw(f), |
| 88 |
) |
| 89 |
} |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
impl<O: IsA<DebugControllerDBus>> DebugControllerDBusExt for O {} |