glib/auto/main_context.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use glib_sys;
6use translate::*;
7
8glib_wrapper! {
9 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
10 pub struct MainContext(Shared<glib_sys::GMainContext>);
11
12 match fn {
13 ref => |ptr| glib_sys::g_main_context_ref(ptr),
14 unref => |ptr| glib_sys::g_main_context_unref(ptr),
15 get_type => || glib_sys::g_main_context_get_type(),
16 }
17}
18
19impl MainContext {
20 pub fn new() -> MainContext {
21 unsafe { from_glib_full(glib_sys::g_main_context_new()) }
22 }
23
24 pub fn acquire(&self) -> bool {
25 unsafe { from_glib(glib_sys::g_main_context_acquire(self.to_glib_none().0)) }
26 }
27
28 //pub fn add_poll(&self, fd: /*Ignored*/&mut PollFD, priority: i32) {
29 // unsafe { TODO: call glib_sys:g_main_context_add_poll() }
30 //}
31
32 //pub fn check(&self, max_priority: i32, fds: /*Ignored*/&[&PollFD]) -> bool {
33 // unsafe { TODO: call glib_sys:g_main_context_check() }
34 //}
35
36 pub fn dispatch(&self) {
37 unsafe {
38 glib_sys::g_main_context_dispatch(self.to_glib_none().0);
39 }
40 }
41
42 //pub fn find_source_by_funcs_user_data(&self, funcs: /*Ignored*/&mut SourceFuncs, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Option<Source> {
43 // unsafe { TODO: call glib_sys:g_main_context_find_source_by_funcs_user_data() }
44 //}
45
46 //pub fn find_source_by_user_data(&self, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Option<Source> {
47 // unsafe { TODO: call glib_sys:g_main_context_find_source_by_user_data() }
48 //}
49
50 //pub fn get_poll_func(&self) -> /*Unimplemented*/Fn(/*Ignored*/PollFD, u32, i32) -> i32 {
51 // unsafe { TODO: call glib_sys:g_main_context_get_poll_func() }
52 //}
53
54 pub fn is_owner(&self) -> bool {
55 unsafe { from_glib(glib_sys::g_main_context_is_owner(self.to_glib_none().0)) }
56 }
57
58 pub fn iteration(&self, may_block: bool) -> bool {
59 unsafe {
60 from_glib(glib_sys::g_main_context_iteration(
61 self.to_glib_none().0,
62 may_block.to_glib(),
63 ))
64 }
65 }
66
67 pub fn pending(&self) -> bool {
68 unsafe { from_glib(glib_sys::g_main_context_pending(self.to_glib_none().0)) }
69 }
70
71 pub fn pop_thread_default(&self) {
72 unsafe {
73 glib_sys::g_main_context_pop_thread_default(self.to_glib_none().0);
74 }
75 }
76
77 pub fn push_thread_default(&self) {
78 unsafe {
79 glib_sys::g_main_context_push_thread_default(self.to_glib_none().0);
80 }
81 }
82
83 //pub fn query(&self, max_priority: i32, fds: /*Ignored*/Vec<PollFD>) -> (i32, i32) {
84 // unsafe { TODO: call glib_sys:g_main_context_query() }
85 //}
86
87 pub fn release(&self) {
88 unsafe {
89 glib_sys::g_main_context_release(self.to_glib_none().0);
90 }
91 }
92
93 //pub fn remove_poll(&self, fd: /*Ignored*/&mut PollFD) {
94 // unsafe { TODO: call glib_sys:g_main_context_remove_poll() }
95 //}
96
97 //pub fn set_poll_func(&self, func: /*Unimplemented*/Fn(/*Ignored*/PollFD, u32, i32) -> i32) {
98 // unsafe { TODO: call glib_sys:g_main_context_set_poll_func() }
99 //}
100
101 //#[cfg_attr(feature = "v2_58", deprecated)]
102 //pub fn wait(&self, cond: /*Ignored*/&mut Cond, mutex: /*Ignored*/&mut Mutex) -> bool {
103 // unsafe { TODO: call glib_sys:g_main_context_wait() }
104 //}
105
106 pub fn wakeup(&self) {
107 unsafe {
108 glib_sys::g_main_context_wakeup(self.to_glib_none().0);
109 }
110 }
111
112 pub fn default() -> MainContext {
113 unsafe { from_glib_none(glib_sys::g_main_context_default()) }
114 }
115
116 pub fn get_thread_default() -> Option<MainContext> {
117 unsafe { from_glib_none(glib_sys::g_main_context_get_thread_default()) }
118 }
119
120 pub fn ref_thread_default() -> MainContext {
121 unsafe { from_glib_full(glib_sys::g_main_context_ref_thread_default()) }
122 }
123}
124
125impl Default for MainContext {
126 fn default() -> Self {
127 Self::new()
128 }
129}
130
131unsafe impl Send for MainContext {}
132unsafe impl Sync for MainContext {}