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
93
94
95
96
// 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 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@crate::prelude::AtkMiscExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "AtkMisc")]
    pub struct Misc(Object<ffi::AtkMisc, ffi::AtkMiscClass>);

    match fn {
        type_ => || ffi::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.
    #[doc(alias = "atk_misc_get_instance")]
    #[doc(alias = "get_instance")]
    pub fn instance() -> Option<Misc> {
        assert_initialized_main_thread!();
        unsafe { from_glib_none(ffi::atk_misc_get_instance()) }
    }
}

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

/// Trait containing all [`struct@Misc`] methods.
///
/// # Implementors
///
/// [`Misc`][struct@crate::Misc]
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.
    #[doc(alias = "atk_misc_threads_enter")]
    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.
    #[doc(alias = "atk_misc_threads_leave")]
    fn threads_leave(&self);
}

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

    fn threads_leave(&self) {
        unsafe {
            ffi::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 {
        f.write_str("Misc")
    }
}