glib/auto/source.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 crate::{ffi, translate::*};
6
7crate::wrapper! {
8 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9 pub struct Source(Shared<ffi::GSource>);
10
11 match fn {
12 ref => |ptr| ffi::g_source_ref(ptr),
13 unref => |ptr| ffi::g_source_unref(ptr),
14 type_ => || ffi::g_source_get_type(),
15 }
16}
17
18impl Source {
19 //#[doc(alias = "g_source_new")]
20 //pub fn new(source_funcs: /*Ignored*/&mut SourceFuncs, struct_size: u32) -> Source {
21 // unsafe { TODO: call ffi:g_source_new() }
22 //}
23
24 #[doc(alias = "g_source_add_child_source")]
25 pub fn add_child_source(&self, child_source: &Source) {
26 unsafe {
27 ffi::g_source_add_child_source(self.to_glib_none().0, child_source.to_glib_none().0);
28 }
29 }
30
31 //#[doc(alias = "g_source_add_poll")]
32 //pub fn add_poll(&self, fd: /*Ignored*/&mut PollFD) {
33 // unsafe { TODO: call ffi:g_source_add_poll() }
34 //}
35
36 //#[doc(alias = "g_source_add_unix_fd")]
37 //pub fn add_unix_fd(&self, fd: i32, events: IOCondition) -> /*Unimplemented*/Basic: Pointer {
38 // unsafe { TODO: call ffi:g_source_add_unix_fd() }
39 //}
40
41 #[doc(alias = "g_source_destroy")]
42 pub fn destroy(&self) {
43 unsafe {
44 ffi::g_source_destroy(self.to_glib_none().0);
45 }
46 }
47
48 /// Checks whether a source is allowed to be called recursively.
49 ///
50 /// See `GLib::Source::set_can_recurse()`.
51 ///
52 /// # Returns
53 ///
54 /// whether recursion is allowed
55 // rustdoc-stripper-ignore-next-stop
56 /// Checks whether a source is allowed to be called recursively.
57 ///
58 /// See `GLib::Source::set_can_recurse()`.
59 ///
60 /// # Returns
61 ///
62 /// whether recursion is allowed
63 #[doc(alias = "g_source_get_can_recurse")]
64 #[doc(alias = "get_can_recurse")]
65 pub fn can_recurse(&self) -> bool {
66 unsafe { from_glib(ffi::g_source_get_can_recurse(self.to_glib_none().0)) }
67 }
68
69 /// Gets a name for the source, used in debugging and profiling.
70 ///
71 /// The
72 /// name may be `NULL` if it has never been set with `GLib::Source::set_name()`.
73 ///
74 /// # Returns
75 ///
76 /// the name of the source
77 // rustdoc-stripper-ignore-next-stop
78 /// Gets a name for the source, used in debugging and profiling.
79 ///
80 /// The
81 /// name may be `NULL` if it has never been set with `GLib::Source::set_name()`.
82 ///
83 /// # Returns
84 ///
85 /// the name of the source
86 #[doc(alias = "g_source_get_name")]
87 #[doc(alias = "get_name")]
88 pub fn name(&self) -> Option<crate::GString> {
89 unsafe { from_glib_none(ffi::g_source_get_name(self.to_glib_none().0)) }
90 }
91
92 /// Gets the priority of a source.
93 ///
94 /// # Returns
95 ///
96 /// the priority of the source
97 // rustdoc-stripper-ignore-next-stop
98 /// Gets the priority of a source.
99 ///
100 /// # Returns
101 ///
102 /// the priority of the source
103 #[doc(alias = "g_source_get_priority")]
104 #[doc(alias = "get_priority")]
105 pub fn priority(&self) -> i32 {
106 unsafe { ffi::g_source_get_priority(self.to_glib_none().0) }
107 }
108
109 /// of @self, as set by
110 /// `GLib::Source::set_ready_time()`.
111 ///
112 /// Any time before or equal to the current monotonic time (including zero)
113 /// is an indication that the source will fire immediately.
114 ///
115 /// # Returns
116 ///
117 /// never
118 // rustdoc-stripper-ignore-next-stop
119 /// of @self, as set by
120 /// `GLib::Source::set_ready_time()`.
121 ///
122 /// Any time before or equal to the current monotonic time (including zero)
123 /// is an indication that the source will fire immediately.
124 ///
125 /// # Returns
126 ///
127 /// never
128 #[doc(alias = "g_source_get_ready_time")]
129 #[doc(alias = "get_ready_time")]
130 pub fn ready_time(&self) -> i64 {
131 unsafe { ffi::g_source_get_ready_time(self.to_glib_none().0) }
132 }
133
134 /// Gets the time to be used when checking this source.
135 ///
136 /// The advantage of
137 /// calling this function over calling [`monotonic_time()`][crate::monotonic_time()] directly is
138 /// that when checking multiple sources, GLib can cache a single value
139 /// instead of having to repeatedly get the system monotonic time.
140 ///
141 /// The time here is the system monotonic time, if available, or some
142 /// other reasonable alternative otherwise. See [`monotonic_time()`][crate::monotonic_time()].
143 ///
144 /// # Returns
145 ///
146 /// the monotonic time in microseconds
147 // rustdoc-stripper-ignore-next-stop
148 /// Gets the time to be used when checking this source.
149 ///
150 /// The advantage of
151 /// calling this function over calling [`monotonic_time()`][crate::monotonic_time()] directly is
152 /// that when checking multiple sources, GLib can cache a single value
153 /// instead of having to repeatedly get the system monotonic time.
154 ///
155 /// The time here is the system monotonic time, if available, or some
156 /// other reasonable alternative otherwise. See [`monotonic_time()`][crate::monotonic_time()].
157 ///
158 /// # Returns
159 ///
160 /// the monotonic time in microseconds
161 #[doc(alias = "g_source_get_time")]
162 #[doc(alias = "get_time")]
163 pub fn time(&self) -> i64 {
164 unsafe { ffi::g_source_get_time(self.to_glib_none().0) }
165 }
166
167 /// idle_id_mutex);
168 ///
169 /// return FALSE;
170 /// }
171 /// ```text
172 ///
173 /// Calls to this function from a thread other than the one acquired by the
174 /// [`MainContext`][crate::MainContext] the [`Source`][crate::Source] is attached to are typically
175 /// redundant, as the source could be destroyed immediately after this function
176 /// returns. However, once a source is destroyed it cannot be un-destroyed, so
177 /// this function can be used for opportunistic checks from any thread.
178 ///
179 /// # Returns
180 ///
181 /// true if the source has been destroyed, false otherwise
182 // rustdoc-stripper-ignore-next-stop
183 /// idle_id_mutex);
184 ///
185 /// return FALSE;
186 /// }
187 /// ```text
188 ///
189 /// Calls to this function from a thread other than the one acquired by the
190 /// [`MainContext`][crate::MainContext] the [`Source`][crate::Source] is attached to are typically
191 /// redundant, as the source could be destroyed immediately after this function
192 /// returns. However, once a source is destroyed it cannot be un-destroyed, so
193 /// this function can be used for opportunistic checks from any thread.
194 ///
195 /// # Returns
196 ///
197 /// true if the source has been destroyed, false otherwise
198 #[doc(alias = "g_source_is_destroyed")]
199 pub fn is_destroyed(&self) -> bool {
200 unsafe { from_glib(ffi::g_source_is_destroyed(self.to_glib_none().0)) }
201 }
202
203 //#[doc(alias = "g_source_modify_unix_fd")]
204 //pub fn modify_unix_fd(&self, tag: /*Unimplemented*/Basic: Pointer, new_events: IOCondition) {
205 // unsafe { TODO: call ffi:g_source_modify_unix_fd() }
206 //}
207
208 //#[doc(alias = "g_source_query_unix_fd")]
209 //pub fn query_unix_fd(&self, tag: /*Unimplemented*/Basic: Pointer) -> IOCondition {
210 // unsafe { TODO: call ffi:g_source_query_unix_fd() }
211 //}
212
213 /// Detaches @child_source from @self and destroys it.
214 ///
215 /// This API is only intended to be used by implementations of [`Source`][crate::Source].
216 /// Do not call this API on a [`Source`][crate::Source] that you did not create.
217 /// ## `child_source`
218 /// a source previously passed to
219 /// [`add_child_source()`][Self::add_child_source()]
220 // rustdoc-stripper-ignore-next-stop
221 /// Detaches @child_source from @self and destroys it.
222 ///
223 /// This API is only intended to be used by implementations of [`Source`][crate::Source].
224 /// Do not call this API on a [`Source`][crate::Source] that you did not create.
225 /// ## `child_source`
226 /// a source previously passed to
227 /// [`add_child_source()`][Self::add_child_source()]
228 #[doc(alias = "g_source_remove_child_source")]
229 pub fn remove_child_source(&self, child_source: &Source) {
230 unsafe {
231 ffi::g_source_remove_child_source(self.to_glib_none().0, child_source.to_glib_none().0);
232 }
233 }
234
235 //#[doc(alias = "g_source_remove_poll")]
236 //pub fn remove_poll(&self, fd: /*Ignored*/&mut PollFD) {
237 // unsafe { TODO: call ffi:g_source_remove_poll() }
238 //}
239
240 //#[doc(alias = "g_source_remove_unix_fd")]
241 //pub fn remove_unix_fd(&self, tag: /*Unimplemented*/Basic: Pointer) {
242 // unsafe { TODO: call ffi:g_source_remove_unix_fd() }
243 //}
244
245 //#[doc(alias = "g_source_remove_by_funcs_user_data")]
246 //pub fn remove_by_funcs_user_data(funcs: /*Ignored*/&mut SourceFuncs, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> bool {
247 // unsafe { TODO: call ffi:g_source_remove_by_funcs_user_data() }
248 //}
249
250 //#[doc(alias = "g_source_remove_by_user_data")]
251 //pub fn remove_by_user_data(user_data: /*Unimplemented*/Option<Basic: Pointer>) -> bool {
252 // unsafe { TODO: call ffi:g_source_remove_by_user_data() }
253 //}
254}
255
256unsafe impl Send for Source {}
257unsafe impl Sync for Source {}