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