glib/auto/
main_loop.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::*, MainContext};
6
7crate::wrapper! {
8    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9    pub struct MainLoop(Shared<ffi::GMainLoop>);
10
11    match fn {
12        ref => |ptr| ffi::g_main_loop_ref(ptr),
13        unref => |ptr| ffi::g_main_loop_unref(ptr),
14        type_ => || ffi::g_main_loop_get_type(),
15    }
16}
17
18impl MainLoop {
19    #[doc(alias = "g_main_loop_new")]
20    pub fn new(context: Option<&MainContext>, is_running: bool) -> MainLoop {
21        unsafe {
22            from_glib_full(ffi::g_main_loop_new(
23                context.to_glib_none().0,
24                is_running.into_glib(),
25            ))
26        }
27    }
28
29    #[doc(alias = "g_main_loop_get_context")]
30    #[doc(alias = "get_context")]
31    pub fn context(&self) -> MainContext {
32        unsafe { from_glib_none(ffi::g_main_loop_get_context(self.to_glib_none().0)) }
33    }
34
35    #[doc(alias = "g_main_loop_is_running")]
36    pub fn is_running(&self) -> bool {
37        unsafe { from_glib(ffi::g_main_loop_is_running(self.to_glib_none().0)) }
38    }
39
40    #[doc(alias = "g_main_loop_quit")]
41    pub fn quit(&self) {
42        unsafe {
43            ffi::g_main_loop_quit(self.to_glib_none().0);
44        }
45    }
46
47    #[doc(alias = "g_main_loop_run")]
48    pub fn run(&self) {
49        unsafe {
50            ffi::g_main_loop_run(self.to_glib_none().0);
51        }
52    }
53}
54
55unsafe impl Send for MainLoop {}
56unsafe impl Sync for MainLoop {}