Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.

Commit 3fe856a

Browse files
committed
mainloop: Added MainContext methods invoke and invoke_full
These provide idiomatic support for g_main_context_invoke*().
1 parent f318262 commit 3fe856a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/mainloop.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ impl MainContext {
132132
wrap::from_raw(ffi::g_main_context_default())
133133
}
134134
}
135+
136+
pub fn invoke(&self, callback: SourceCallback) {
137+
self.invoke_full(PRIORITY_DEFAULT, callback)
138+
}
139+
140+
pub fn invoke_full(&self, priority: gint, callback: SourceCallback) {
141+
let raw: RawCallback = callback.into();
142+
unsafe {
143+
ffi::g_main_context_invoke_full(self.as_mut_ptr(),
144+
priority, raw.func, raw.data, Some(raw.destroy));
145+
}
146+
mem::forget(raw);
147+
}
135148
}
136149

137150
impl Refcount for MainContext {

0 commit comments

Comments
 (0)