Skip to content

Commit 420b6be

Browse files
authored
Merge pull request #1017 from jf2048/watch-borrowedobject
glib: implement WatchedObject for BorrowedObject
2 parents 8bf3a36 + 6da3bea commit 420b6be

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

glib-macros/tests/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ fn closure() {
685685

686686
let inc_by = {
687687
let obj = glib::Object::new::<SendObject>();
688+
let obj = obj.imp().obj();
688689
let inc_by = glib::closure!(@watch obj => move |x: i32| {
689690
let old = obj.value();
690691
obj.set_value(x + old);

glib/src/object.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3117,6 +3117,16 @@ impl<T: ObjectType> Watchable<T> for T {
31173117
}
31183118
}
31193119

3120+
#[doc(hidden)]
3121+
impl<'a, T: ObjectType> Watchable<T> for BorrowedObject<'a, T> {
3122+
fn watched_object(&self) -> WatchedObject<T> {
3123+
WatchedObject::new(self)
3124+
}
3125+
fn watch_closure(&self, closure: &impl AsRef<Closure>) {
3126+
ObjectExt::watch_closure(&**self, closure)
3127+
}
3128+
}
3129+
31203130
#[doc(hidden)]
31213131
impl<T: ObjectType> Watchable<T> for &T {
31223132
fn watched_object(&self) -> WatchedObject<T> {

0 commit comments

Comments
 (0)