|
2 | 2 |
|
3 | 3 | use std::{boxed::Box as Box_, mem::transmute}; |
4 | 4 |
|
5 | | -use glib::{prelude::*, signal::connect_raw, translate::*, SignalHandlerId}; |
| 5 | +use glib::{prelude::*, signal::connect_raw, translate::*, SignalHandlerId, StrVRef}; |
6 | 6 |
|
7 | 7 | use crate::{ffi, DBusProxy}; |
8 | 8 |
|
9 | 9 | pub trait DBusProxyExtManual: IsA<DBusProxy> + 'static { |
| 10 | + #[doc(alias = "g-properties-changed")] |
| 11 | + fn connect_g_properties_changed< |
| 12 | + F: Fn(&Self, &glib::Variant, &StrVRef) + Send + Sync + 'static, |
| 13 | + >( |
| 14 | + &self, |
| 15 | + f: F, |
| 16 | + ) -> SignalHandlerId { |
| 17 | + unsafe extern "C" fn g_properties_changed_trampoline< |
| 18 | + P: IsA<DBusProxy>, |
| 19 | + F: Fn(&P, &glib::Variant, &StrVRef) + Send + Sync + 'static, |
| 20 | + >( |
| 21 | + this: *mut ffi::GDBusProxy, |
| 22 | + changed_properties: *mut glib::ffi::GVariant, |
| 23 | + invalidated_properties: *const *const libc::c_char, |
| 24 | + f: glib::ffi::gpointer, |
| 25 | + ) { |
| 26 | + let f: &F = &*(f as *const F); |
| 27 | + f( |
| 28 | + DBusProxy::from_glib_borrow(this).unsafe_cast_ref(), |
| 29 | + &from_glib_borrow(changed_properties), |
| 30 | + StrVRef::from_glib_borrow(invalidated_properties), |
| 31 | + ) |
| 32 | + } |
| 33 | + unsafe { |
| 34 | + let f: Box_<F> = Box_::new(f); |
| 35 | + connect_raw( |
| 36 | + self.as_ptr() as *mut _, |
| 37 | + c"g-properties-changed".as_ptr() as *const _, |
| 38 | + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
| 39 | + g_properties_changed_trampoline::<Self, F> as *const (), |
| 40 | + )), |
| 41 | + Box_::into_raw(f), |
| 42 | + ) |
| 43 | + } |
| 44 | + } |
| 45 | + |
10 | 46 | #[cfg(feature = "v2_72")] |
11 | 47 | #[doc(alias = "g-signal")] |
12 | 48 | fn connect_g_signal< |
|
0 commit comments