Skip to main content

atk/auto/
misc.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::{prelude::*, translate::*};
6use std::fmt;
7
8glib::wrapper! {
9    /// A set of ATK utility functions for thread locking
10    ///
11    /// A set of utility functions for thread locking. This interface and
12    /// all his related methods are deprecated since 2.12.
13    ///
14    /// # Implements
15    ///
16    /// [`AtkMiscExt`][trait@crate::prelude::AtkMiscExt], [`trait@glib::ObjectExt`]
17    #[doc(alias = "AtkMisc")]
18    pub struct Misc(Object<ffi::AtkMisc, ffi::AtkMiscClass>);
19
20    match fn {
21        type_ => || ffi::atk_misc_get_type(),
22    }
23}
24
25impl Misc {
26    pub const NONE: Option<&'static Misc> = None;
27
28    /// Obtain the singleton instance of AtkMisc for this application.
29    ///
30    /// # Deprecated
31    ///
32    /// Since 2.12.
33    ///
34    /// # Returns
35    ///
36    /// The singleton instance of AtkMisc for this application.
37    #[doc(alias = "atk_misc_get_instance")]
38    #[doc(alias = "get_instance")]
39    pub fn instance() -> Option<Misc> {
40        assert_initialized_main_thread!();
41        unsafe { from_glib_none(ffi::atk_misc_get_instance()) }
42    }
43}
44
45mod sealed {
46    pub trait Sealed {}
47    impl<T: super::IsA<super::Misc>> Sealed for T {}
48}
49
50/// Trait containing all [`struct@Misc`] methods.
51///
52/// # Implementors
53///
54/// [`Misc`][struct@crate::Misc]
55pub trait AtkMiscExt: IsA<Misc> + sealed::Sealed + 'static {
56    /// Take the thread mutex for the GUI toolkit,
57    /// if one exists.
58    /// (This method is implemented by the toolkit ATK implementation layer;
59    ///  for instance, for GTK+, GAIL implements this via GDK_THREADS_ENTER).
60    ///
61    /// # Deprecated
62    ///
63    /// Since 2.12.
64    #[doc(alias = "atk_misc_threads_enter")]
65    fn threads_enter(&self) {
66        unsafe {
67            ffi::atk_misc_threads_enter(self.as_ref().to_glib_none().0);
68        }
69    }
70
71    /// Release the thread mutex for the GUI toolkit,
72    /// if one exists. This method, and atk_misc_threads_enter,
73    /// are needed in some situations by threaded application code which
74    /// services ATK requests, since fulfilling ATK requests often
75    /// requires calling into the GUI toolkit. If a long-running or
76    /// potentially blocking call takes place inside such a block, it should
77    /// be bracketed by atk_misc_threads_leave/atk_misc_threads_enter calls.
78    /// (This method is implemented by the toolkit ATK implementation layer;
79    ///  for instance, for GTK+, GAIL implements this via GDK_THREADS_LEAVE).
80    ///
81    /// # Deprecated
82    ///
83    /// Since 2.12.
84    #[doc(alias = "atk_misc_threads_leave")]
85    fn threads_leave(&self) {
86        unsafe {
87            ffi::atk_misc_threads_leave(self.as_ref().to_glib_none().0);
88        }
89    }
90}
91
92impl<O: IsA<Misc>> AtkMiscExt for O {}
93
94impl fmt::Display for Misc {
95    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
96        f.write_str("Misc")
97    }
98}