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::DBusInterface; 6 use glib::object::Cast; 7 use glib::object::IsA; 8 use glib::signal::connect_raw; 9 use glib::signal::SignalHandlerId; 10 use glib::translate::*; 11 use std::boxed::Box as Box_; 12 use std::fmt; 13 use std::mem::transmute; 14 15 glib::wrapper! { 16 #[doc(alias = "GDBusObject")] 17 pub struct DBusObject(Interface<ffi::GDBusObject, ffi::GDBusObjectIface>); 18 19 match fn { 20 type_ => || ffi::g_dbus_object_get_type(), 21 } 22 } 23 24 pub const NONE_DBUS_OBJECT: Option<&DBusObject> = None; 25 26 pub trait DBusObjectExt: 'static { 27 #[doc(alias = "g_dbus_object_get_interface")] 28 #[doc(alias = "get_interface")] interface(&self, interface_name: &str) -> Option<DBusInterface>29 fn interface(&self, interface_name: &str) -> Option<DBusInterface>; 30 31 #[doc(alias = "g_dbus_object_get_interfaces")] 32 #[doc(alias = "get_interfaces")] interfaces(&self) -> Vec<DBusInterface>33 fn interfaces(&self) -> Vec<DBusInterface>; 34 35 #[doc(alias = "g_dbus_object_get_object_path")] 36 #[doc(alias = "get_object_path")] object_path(&self) -> glib::GString37 fn object_path(&self) -> glib::GString; 38 39 #[doc(alias = "interface-added")] connect_interface_added<F: Fn(&Self, &DBusInterface) + 'static>( &self, f: F, ) -> SignalHandlerId40 fn connect_interface_added<F: Fn(&Self, &DBusInterface) + 'static>( 41 &self, 42 f: F, 43 ) -> SignalHandlerId; 44 45 #[doc(alias = "interface-removed")] connect_interface_removed<F: Fn(&Self, &DBusInterface) + 'static>( &self, f: F, ) -> SignalHandlerId46 fn connect_interface_removed<F: Fn(&Self, &DBusInterface) + 'static>( 47 &self, 48 f: F, 49 ) -> SignalHandlerId; 50 } 51 52 impl<O: IsA<DBusObject>> DBusObjectExt for O { interface(&self, interface_name: &str) -> Option<DBusInterface>53 fn interface(&self, interface_name: &str) -> Option<DBusInterface> { 54 unsafe { 55 from_glib_full(ffi::g_dbus_object_get_interface( 56 self.as_ref().to_glib_none().0, 57 interface_name.to_glib_none().0, 58 )) 59 } 60 } 61 interfaces(&self) -> Vec<DBusInterface>62 fn interfaces(&self) -> Vec<DBusInterface> { 63 unsafe { 64 FromGlibPtrContainer::from_glib_full(ffi::g_dbus_object_get_interfaces( 65 self.as_ref().to_glib_none().0, 66 )) 67 } 68 } 69 object_path(&self) -> glib::GString70 fn object_path(&self) -> glib::GString { 71 unsafe { 72 from_glib_none(ffi::g_dbus_object_get_object_path( 73 self.as_ref().to_glib_none().0, 74 )) 75 } 76 } 77 connect_interface_added<F: Fn(&Self, &DBusInterface) + 'static>( &self, f: F, ) -> SignalHandlerId78 fn connect_interface_added<F: Fn(&Self, &DBusInterface) + 'static>( 79 &self, 80 f: F, 81 ) -> SignalHandlerId { 82 unsafe extern "C" fn interface_added_trampoline< 83 P: IsA<DBusObject>, 84 F: Fn(&P, &DBusInterface) + 'static, 85 >( 86 this: *mut ffi::GDBusObject, 87 interface: *mut ffi::GDBusInterface, 88 f: glib::ffi::gpointer, 89 ) { 90 let f: &F = &*(f as *const F); 91 f( 92 DBusObject::from_glib_borrow(this).unsafe_cast_ref(), 93 &from_glib_borrow(interface), 94 ) 95 } 96 unsafe { 97 let f: Box_<F> = Box_::new(f); 98 connect_raw( 99 self.as_ptr() as *mut _, 100 b"interface-added\0".as_ptr() as *const _, 101 Some(transmute::<_, unsafe extern "C" fn()>( 102 interface_added_trampoline::<Self, F> as *const (), 103 )), 104 Box_::into_raw(f), 105 ) 106 } 107 } 108 connect_interface_removed<F: Fn(&Self, &DBusInterface) + 'static>( &self, f: F, ) -> SignalHandlerId109 fn connect_interface_removed<F: Fn(&Self, &DBusInterface) + 'static>( 110 &self, 111 f: F, 112 ) -> SignalHandlerId { 113 unsafe extern "C" fn interface_removed_trampoline< 114 P: IsA<DBusObject>, 115 F: Fn(&P, &DBusInterface) + 'static, 116 >( 117 this: *mut ffi::GDBusObject, 118 interface: *mut ffi::GDBusInterface, 119 f: glib::ffi::gpointer, 120 ) { 121 let f: &F = &*(f as *const F); 122 f( 123 DBusObject::from_glib_borrow(this).unsafe_cast_ref(), 124 &from_glib_borrow(interface), 125 ) 126 } 127 unsafe { 128 let f: Box_<F> = Box_::new(f); 129 connect_raw( 130 self.as_ptr() as *mut _, 131 b"interface-removed\0".as_ptr() as *const _, 132 Some(transmute::<_, unsafe extern "C" fn()>( 133 interface_removed_trampoline::<Self, F> as *const (), 134 )), 135 Box_::into_raw(f), 136 ) 137 } 138 } 139 } 140 141 impl fmt::Display for DBusObject { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result142 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 143 f.write_str("DBusObject") 144 } 145 } 146