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