Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit 3a1e912

Browse files
committed
Add manual implementation for MainContext::find_source_by_id() because of SourceId newtype
1 parent 1ce0b70 commit 3a1e912

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

Gir.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ concurrency = "send+sync"
239239
# out parameter not marked as such
240240
ignore = true
241241

242+
[[object.function]]
243+
name = "find_source_by_id"
244+
# source id is a newtype
245+
ignore = true
246+
242247
[[object]]
243248
name = "GLib.MainLoop"
244249
status = "generate"

src/auto/main_context.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// This file was generated by gir (7504fb6) from gir-files (71d73f0)
22
// DO NOT EDIT
33

4-
use Source;
54
use ffi;
65
use translate::*;
76

@@ -45,12 +44,6 @@ impl MainContext {
4544
// unsafe { TODO: call ffi::g_main_context_find_source_by_funcs_user_data() }
4645
//}
4746

48-
pub fn find_source_by_id(&self, source_id: u32) -> Option<Source> {
49-
unsafe {
50-
from_glib_none(ffi::g_main_context_find_source_by_id(self.to_glib_none().0, source_id))
51-
}
52-
}
53-
5447
//pub fn find_source_by_user_data<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, user_data: P) -> Option<Source> {
5548
// unsafe { TODO: call ffi::g_main_context_find_source_by_user_data() }
5649
//}

src/main_context.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use ffi::{gpointer, gboolean};
1111
use std::cell::RefCell;
1212

1313
use MainContext;
14+
use Source;
15+
use SourceId;
1416

1517
use source::{CallbackGuard, Priority};
1618

@@ -25,6 +27,12 @@ impl MainContext {
2527
}
2628
}
2729

30+
pub fn find_source_by_id(&self, source_id: SourceId) -> Option<Source> {
31+
unsafe {
32+
from_glib_none(ffi::g_main_context_find_source_by_id(self.to_glib_none().0, source_id.to_glib()))
33+
}
34+
}
35+
2836
// FIXME: These can actually be FnOnce but require FnBox to
2937
// stabilize, or Box<FnOnce()> to be callable otherwise
3038
pub fn invoke<F>(&self, func: F)

0 commit comments

Comments
 (0)