1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use atk_sys;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib_wrapper! {
    /// A set of utility functions for thread locking. This interface and
    /// all his related methods are deprecated since 2.12.
    ///
    /// # Implements
    ///
    /// [`AtkMiscExt`](trait.AtkMiscExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html)
    pub struct Misc(Object<atk_sys::AtkMisc, atk_sys::AtkMiscClass, MiscClass>);

    match fn {
        get_type => || atk_sys::atk_misc_get_type(),
    }
}

impl Misc {
    /// Obtain the singleton instance of AtkMisc for this application.
    ///
    /// # Deprecated
    ///
    /// Since 2.12.
    ///
    /// # Returns
    ///
    /// The singleton instance of AtkMisc for this application.
    pub fn get_instance() -> Option<Misc> {
        assert_initialized_main_thread!();
        unsafe { from_glib_none(atk_sys::atk_misc_get_instance()) }
    }
}

pub const NONE_MISC: Option<&Misc> = None;

/// Trait containing all `Misc` methods.
///
/// # Implementors
///
/// [`Misc`](struct.Misc.html)
pub trait AtkMiscExt: 'static {
    /// Take the thread mutex for the GUI toolkit,
    /// if one exists.
    /// (This method is implemented by the toolkit ATK implementation layer;
    ///  for instance, for GTK+, GAIL implements this via GDK_THREADS_ENTER).
    ///
    /// # Deprecated
    ///
    /// Since 2.12.
    fn threads_enter(&self);

    /// Release the thread mutex for the GUI toolkit,
    /// if one exists. This method, and atk_misc_threads_enter,
    /// are needed in some situations by threaded application code which
    /// services ATK requests, since fulfilling ATK requests often
    /// requires calling into the GUI toolkit. If a long-running or
    /// potentially blocking call takes place inside such a block, it should
    /// be bracketed by atk_misc_threads_leave/atk_misc_threads_enter calls.
    /// (This method is implemented by the toolkit ATK implementation layer;
    ///  for instance, for GTK+, GAIL implements this via GDK_THREADS_LEAVE).
    ///
    /// # Deprecated
    ///
    /// Since 2.12.
    fn threads_leave(&self);
}

impl<O: IsA<Misc>> AtkMiscExt for O {
    fn threads_enter(&self) {
        unsafe {
            atk_sys::atk_misc_threads_enter(self.as_ref().to_glib_none().0);
        }
    }

    fn threads_leave(&self) {
        unsafe {
            atk_sys::atk_misc_threads_leave(self.as_ref().to_glib_none().0);
        }
    }
}

impl fmt::Display for Misc {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "Misc")
    }
}