Skip to content

Commit 99e103a

Browse files
committed
Manually implement connect_g_properties_changed
1 parent 505b98b commit 99e103a

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

gio/Gir.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,8 @@ concurrency = "send+sync"
742742
manual_traits = ["DBusProxyExtManual"]
743743
[[object.signal]]
744744
name = "g-properties-changed"
745-
# libc::c_char vs str
746-
ignore = true
745+
# **libc::c_char not handled by generator
746+
manual = true
747747
[[object.function]]
748748
pattern = ".+_unix_fd.+"
749749
cfg_condition = "unix"

gio/src/dbus_proxy.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,47 @@
22

33
use std::{boxed::Box as Box_, mem::transmute};
44

5-
use glib::{prelude::*, signal::connect_raw, translate::*, SignalHandlerId};
5+
use glib::{prelude::*, signal::connect_raw, translate::*, SignalHandlerId, StrVRef};
66

77
use crate::{ffi, DBusProxy};
88

99
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+
1046
#[cfg(feature = "v2_72")]
1147
#[doc(alias = "g-signal")]
1248
fn connect_g_signal<

0 commit comments

Comments
 (0)